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
This commit is contained in:
Patrick Mours 2020-12-08 15:42:00 +01:00
parent 9962e5936d
commit 612b83bbd1
Notes: blender-bot 2023-02-14 03:00:45 +01:00
Referenced by issue #83429, some times texture baking button disappear
Referenced by issue #69800, Cycles Optix feature completeness
2 changed files with 14 additions and 7 deletions

View File

@ -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")

View File

@ -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);