Fix #135194: Deleting the last object in a scene leaves it visible in the viewport with MetalRT

TLAS wasn't being refreshed when empty.

This PR removes a spurious early-exit during BVH build that was preventing
the TLAS from being recreated when it was empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/141215
This commit is contained in:
Michael Jones
2025-07-01 14:25:09 +02:00
committed by Sergey Sharybin
parent c261718085
commit 03183c3328
2 changed files with 6 additions and 8 deletions

View File

@@ -1048,10 +1048,6 @@ bool BVHMetal::build_TLAS(Progress &progress,
}
}
if (num_instances == 0) {
return false;
}
const bool use_instance_motion = motion_blur && num_motion_instances;
const bool use_fast_trace_bvh = (params.bvh_type == BVH_TYPE_STATIC) || !support_refit_blas();

View File

@@ -509,11 +509,13 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
if (id<MTLAccelerationStructure> accel_struct = metal_device_->accel_struct) {
/* Mark all Accelerations resources as used */
[mtlComputeCommandEncoder useResource:accel_struct usage:MTLResourceUsageRead];
[mtlComputeCommandEncoder useResource:metal_device_->blas_buffer
usage:MTLResourceUsageRead];
if (metal_device_->blas_buffer) {
[mtlComputeCommandEncoder useResource:metal_device_->blas_buffer
usage:MTLResourceUsageRead];
}
[mtlComputeCommandEncoder useResources:metal_device_->unique_blas_array.data()
count:metal_device_->unique_blas_array.size()
usage:MTLResourceUsageRead];
count:metal_device_->unique_blas_array.size()
usage:MTLResourceUsageRead];
}
}
}