diff options
author | Patrick Mours <pmours@nvidia.com> | 2019-09-12 15:50:06 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-13 12:50:11 +0300 |
commit | a2b52dc5716a97e5413acbd6eefc9ce3788b6456 (patch) | |
tree | 7e6d6c17b73671e67c1f7fbdadd821b4541f820f /intern/cycles/blender/addon | |
parent | 53932f1f068501bfb095c407a7777a964dc5ec1c (diff) |
Cycles: add Optix device backend
This uses hardware-accelerated raytracing on NVIDIA RTX graphics cards.
It is still currently experimental. Most features are supported, but a few
are still missing like baking, branched path tracing and using CPU memory.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.81/Cycles#NVIDIA_RTX
For building with Optix support, the Optix SDK must be installed. See here for
build instructions:
https://wiki.blender.org/wiki/Building_Blender/CUDA
Differential Revision: https://developer.blender.org/D5363
Diffstat (limited to 'intern/cycles/blender/addon')
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 46 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 23 |
2 files changed, 51 insertions, 18 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 93f8f76cd6a..8623b38a271 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -137,6 +137,7 @@ enum_world_mis = ( enum_device_type = ( ('CPU', "CPU", "CPU", 0), ('CUDA', "CUDA", "CUDA", 1), + ('OPTIX', "OptiX", "OptiX", 3), ('OPENCL', "OpenCL", "OpenCL", 2) ) @@ -740,6 +741,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): debug_use_cuda_adaptive_compile: BoolProperty(name="Adaptive Compile", default=False) debug_use_cuda_split_kernel: BoolProperty(name="Split Kernel", default=False) + debug_optix_cuda_streams: IntProperty(name="CUDA Streams", default=1, min=1) + debug_opencl_kernel_type: EnumProperty( name="OpenCL Kernel Type", default='DEFAULT', @@ -1400,10 +1403,12 @@ class CyclesPreferences(bpy.types.AddonPreferences): def get_device_types(self, context): import _cycles - has_cuda, has_opencl = _cycles.get_device_types() + has_cuda, has_optix, has_opencl = _cycles.get_device_types() list = [('NONE', "None", "Don't use compute device", 0)] if has_cuda: list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1)) + if has_optix: + list.append(('OPTIX', "OptiX", "Use OptiX for GPU acceleration", 3)) if has_opencl: list.append(('OPENCL', "OpenCL", "Use OpenCL for GPU acceleration", 2)) return list @@ -1424,7 +1429,7 @@ class CyclesPreferences(bpy.types.AddonPreferences): def update_device_entries(self, device_list): for device in device_list: - if not device[1] in {'CUDA', 'OPENCL', 'CPU'}: + if not device[1] in {'CUDA', 'OPTIX', 'OPENCL', 'CPU'}: continue # Try to find existing Device entry entry = self.find_existing_device_entry(device) @@ -1439,8 +1444,8 @@ class CyclesPreferences(bpy.types.AddonPreferences): # Update name in case it changed entry.name = device[0] - # Gets all devices types by default. - def get_devices(self, compute_device_type=''): + # Gets all devices types for a compute device type. + def get_devices_for_type(self, compute_device_type): import _cycles # Layout of the device tuples: (Name, Type, Persistent ID) device_list = _cycles.available_devices(compute_device_type) @@ -1449,20 +1454,23 @@ class CyclesPreferences(bpy.types.AddonPreferences): # hold pointers to a resized array. self.update_device_entries(device_list) # Sort entries into lists - cuda_devices = [] - opencl_devices = [] + devices = [] cpu_devices = [] for device in device_list: entry = self.find_existing_device_entry(device) - if entry.type == 'CUDA': - cuda_devices.append(entry) - elif entry.type == 'OPENCL': - opencl_devices.append(entry) + if entry.type == compute_device_type: + devices.append(entry) elif entry.type == 'CPU': cpu_devices.append(entry) # Extend all GPU devices with CPU. - cuda_devices.extend(cpu_devices) - opencl_devices.extend(cpu_devices) + if compute_device_type in ('CUDA', 'OPENCL'): + devices.extend(cpu_devices) + return devices + + # For backwards compatibility, only has CUDA and OpenCL. + def get_devices(self, compute_device_type=''): + cuda_devices = self.get_devices_for_type('CUDA') + opencl_devices = self.get_devices_for_type('OPENCL') return cuda_devices, opencl_devices def get_num_gpu_devices(self): @@ -1498,16 +1506,24 @@ class CyclesPreferences(bpy.types.AddonPreferences): for device in devices: box.prop(device, "use", text=device.name) + if device_type == 'OPTIX': + col = box.column(align=True) + col.label(text="OptiX support is experimental", icon='INFO') + col.label(text="Not all Cycles features are supported yet", icon='BLANK1') + + def draw_impl(self, layout, context): row = layout.row() row.prop(self, "compute_device_type", expand=True) - cuda_devices, opencl_devices = self.get_devices(self.compute_device_type) + devices = self.get_devices_for_type(self.compute_device_type) row = layout.row() if self.compute_device_type == 'CUDA': - self._draw_devices(row, 'CUDA', cuda_devices) + self._draw_devices(row, 'CUDA', devices) + elif self.compute_device_type == 'OPTIX': + self._draw_devices(row, 'OPTIX', devices) elif self.compute_device_type == 'OPENCL': - self._draw_devices(row, 'OPENCL', opencl_devices) + self._draw_devices(row, 'OPENCL', devices) def draw(self, context): self.draw_impl(self.layout, context) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 200b08f93cb..44ed28e9e02 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -88,10 +88,16 @@ def use_cuda(context): return (get_device_type(context) == 'CUDA' and cscene.device == 'GPU') +def use_optix(context): + cscene = context.scene.cycles + + return (get_device_type(context) == 'OPTIX' and cscene.device == 'GPU') + + def use_branched_path(context): cscene = context.scene.cycles - return (cscene.progressive == 'BRANCHED_PATH') + return (cscene.progressive == 'BRANCHED_PATH' and not use_optix(context)) def use_sample_all_lights(context): @@ -168,7 +174,8 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel): layout.use_property_split = True layout.use_property_decorate = False - layout.prop(cscene, "progressive") + if not use_optix(context): + layout.prop(cscene, "progressive") if cscene.progressive == 'PATH' or use_branched_path(context) is False: col = layout.column(align=True) @@ -1763,6 +1770,10 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel): bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'CYCLES'} + @classmethod + def poll(cls, context): + return not use_optix(context) + def draw(self, context): layout = self.layout layout.use_property_split = True @@ -1947,7 +1958,13 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel): col.separator() col = layout.column() - col.label(text='OpenCL Flags:') + col.label(text="OptiX Flags:") + col.prop(cscene, "debug_optix_cuda_streams") + + col.separator() + + col = layout.column() + col.label(text="OpenCL Flags:") col.prop(cscene, "debug_opencl_device_type", text="Device") col.prop(cscene, "debug_use_opencl_debug", text="Debug") col.prop(cscene, "debug_opencl_mem_limit") |