[Bf-blender-cvs] [41bca5a3eed] master: Fix T83581: "Only local" ambient occlusion option causes error on OptiX 2.92

Patrick Mours noreply at git.blender.org
Wed Dec 9 17:07:01 CET 2020


Commit: 41bca5a3eed81d79a62899fcb04fa76674f09c88
Author: Patrick Mours
Date:   Wed Dec 9 17:06:28 2020 +0100
Branches: master
https://developer.blender.org/rB41bca5a3eed81d79a62899fcb04fa76674f09c88

Fix T83581: "Only local" ambient occlusion option causes error on OptiX 2.92

The SVM AO node calls "scene_intersect_local" with a NULL pointer for the intersection
information, which caused a crash with OptiX since it was not checking for this case and
always dereferencing this pointer. This fixes that by checking whether any hit information
was requested first (like is done in the BVH2 intersection routines).

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

M	intern/cycles/kernel/kernels/optix/kernel_optix.cu

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

diff --git a/intern/cycles/kernel/kernels/optix/kernel_optix.cu b/intern/cycles/kernel/kernels/optix/kernel_optix.cu
index fd9065098dd..8ccd2555091 100644
--- a/intern/cycles/kernel/kernels/optix/kernel_optix.cu
+++ b/intern/cycles/kernel/kernels/optix/kernel_optix.cu
@@ -118,12 +118,18 @@ extern "C" __global__ void __anyhit__kernel_optix_local_hit()
     return optixIgnoreIntersection();
   }
 
+  const uint max_hits = optixGetPayload_5();
+  if (max_hits == 0) {
+    // Special case for when no hit information is requested, just report that something was hit
+    optixSetPayload_5(true);
+    return optixTerminateRay();
+  }
+
   int hit = 0;
   uint *const lcg_state = get_payload_ptr_0<uint>();
   LocalIntersection *const local_isect = get_payload_ptr_2<LocalIntersection>();
 
   if (lcg_state) {
-    const uint max_hits = optixGetPayload_5();
     for (int i = min(max_hits, local_isect->num_hits) - 1; i >= 0; --i) {
       if (optixGetRayTmax() == local_isect->hits[i].t) {
         return optixIgnoreIntersection();



More information about the Bf-blender-cvs mailing list