[Bf-blender-cvs] [612b83bbd18] master: Cycles: Enable baking panel in OptiX and redirect those requests to CUDA for now

Patrick Mours noreply at git.blender.org
Tue Dec 8 16:09:47 CET 2020


Commit: 612b83bbd183c214b2d252cf19cdf581f3d9cede
Author: Patrick Mours
Date:   Tue Dec 8 15:42:00 2020 +0100
Branches: master
https://developer.blender.org/rB612b83bbd183c214b2d252cf19cdf581f3d9cede

Cycles: Enable baking panel in OptiX and redirect those requests to CUDA for now

This enables support for baking when OptiX is active, but uses CUDA for that behind the scenes, since
the way baking is currently implemented does not work well with OptiX.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D9784

===================================================================

M	intern/cycles/blender/addon/ui.py
M	intern/cycles/device/device_optix.cpp

===================================================================

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 623e5cf9e37..f24265d256a 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1822,10 +1822,6 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
     bl_options = {'DEFAULT_CLOSED'}
     COMPAT_ENGINES = {'CYCLES'}
 
-    @classmethod
-    def poll(cls, context):
-        return CyclesButtonsPanel.poll(context) and not use_optix(context)
-
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
@@ -1836,6 +1832,9 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
         cbk = scene.render.bake
         rd = scene.render
 
+        if use_optix(context):
+            layout.label(text="Baking is performed using CUDA instead of OptiX", icon='INFO')
+
         if rd.use_bake_multires:
             layout.operator("object.bake_image", icon='RENDER_STILL')
             layout.prop(rd, "use_bake_multires")
diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index 682540a51fd..c6276c1e955 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -297,6 +297,10 @@ class OptiXDevice : public CUDADevice {
 
   BVHLayoutMask get_bvh_layout_mask() const override
   {
+    // CUDA kernels are used when doing baking, so need to build a BVH those can understand too!
+    if (optix_module == NULL)
+      return CUDADevice::get_bvh_layout_mask();
+
     // OptiX has its own internal acceleration structure format
     return BVH_LAYOUT_OPTIX;
   }
@@ -330,10 +334,9 @@ class OptiXDevice : public CUDADevice {
       return false;
     }
 
-    // Disable baking for now, since its kernel is not well-suited for inlining and is very slow
+    // Baking is currently performed using CUDA, so no need to load OptiX kernels
     if (requested_features.use_baking) {
-      set_error("OptiX backend does not support baking yet");
-      return false;
+      return true;
     }
 
     const CUDAContextScope scope(cuContext);
@@ -700,6 +703,11 @@ class OptiXDevice : public CUDADevice {
       while (task.acquire_tile(this, tile, task.tile_types)) {
         if (tile.task == RenderTile::PATH_TRACE)
           launch_render(task, tile, thread_index);
+        else if (tile.task == RenderTile::BAKE) {
+          // Perform baking using CUDA, since it is not currently implemented in OptiX
+          device_vector<WorkTile> work_tiles(this, "work_tiles", MEM_READ_ONLY);
+          CUDADevice::render(task, tile, work_tiles);
+        }
         else if (tile.task == RenderTile::DENOISE)
           launch_denoise(task, tile);
         task.release_tile(tile);



More information about the Bf-blender-cvs mailing list