Fix T83925: Crash when rendering on the CPU with OptiX denoiser enabled

Rendering on the CPU uses the Embree BVH layout, whether the OptiX denoiser is enabled or not.
This means the "build_bvh" function gets a "BVHEmbree" object to fill and not a "BVHMulti" as it
was assuming before, which caused crashes due to memory geting overwritten incorrectly. This
fixes that by redirecting Embree BVH builds to the Embree device.

Manifest Tasks: T83925
This commit is contained in:
Patrick Mours 2021-01-05 18:37:31 +01:00
parent 491a9e9ec4
commit 3373d14b1b
Notes: blender-bot 2023-02-14 03:13:26 +01:00
Referenced by issue #83925, Crash when rendering with OptiX denoiser enabled
1 changed files with 4 additions and 1 deletions

View File

@ -248,11 +248,14 @@ class MultiDevice : public Device {
void build_bvh(BVH *bvh, Progress &progress, bool refit) override
{
/* Try to build and share a single acceleration structure, if possible */
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) {
if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) {
devices.back().device->build_bvh(bvh, progress, refit);
return;
}
assert(bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX ||
bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE);
BVHMulti *const bvh_multi = static_cast<BVHMulti *>(bvh);
bvh_multi->sub_bvhs.resize(devices.size());