From e688c927eb3a82b21ba744ec57540ea2cd4f44c8 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Mon, 13 Dec 2021 22:20:16 +0000 Subject: Fix T94022: Both options GPU/CPU checked under preferences cause viewport render crash. (ARM/Metal) This fixes crash T94022 when selecting live viewport render with both GPU & CPU devices selected. It is caused by incorrect `KernelBVHLayout` assignment. Similar to `BVH_LAYOUT_MULTI_OPTIX` for Optix, this patch adds a `BVH_LAYOUT_MULTI_METAL` to correctly redirect to the correct Metal BVH layout type. Reviewed By: brecht Differential Revision: https://developer.blender.org/D13561 --- intern/cycles/device/multi/device.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'intern/cycles/device') diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index baab84f4035..5ec3ef1b785 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -124,6 +124,11 @@ class MultiDevice : public Device { return BVH_LAYOUT_MULTI_OPTIX; } + /* With multiple Metal devices, every device needs its own acceleration structure */ + if (bvh_layout_mask == BVH_LAYOUT_METAL) { + return BVH_LAYOUT_MULTI_METAL; + } + /* When devices do not share a common BVH layout, fall back to creating one for each */ const BVHLayoutMask BVH_LAYOUT_OPTIX_EMBREE = (BVH_LAYOUT_OPTIX | BVH_LAYOUT_EMBREE); if ((bvh_layout_mask_all & BVH_LAYOUT_OPTIX_EMBREE) == BVH_LAYOUT_OPTIX_EMBREE) { @@ -155,6 +160,7 @@ class MultiDevice : public Device { } assert(bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX || + bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL || bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE || bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE); @@ -179,6 +185,8 @@ class MultiDevice : public Device { BVHParams params = bvh->params; if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) params.bvh_layout = BVH_LAYOUT_OPTIX; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) + params.bvh_layout = BVH_LAYOUT_METAL; else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) params.bvh_layout = sub.device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : BVH_LAYOUT_EMBREE; -- cgit v1.2.3