Fix Cycles CUDA transparent shadow error after recent fix in c22b52c.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 24 Aug 2017 01:33:33 +0000 (03:33 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 24 Aug 2017 01:43:02 +0000 (03:43 +0200)
Fishy cat benchmark was rendering with wrong shadows. Cause is unclear,
adding printf or rearranging code seems to avoid this issue, possibly a
compiler bug. This reverts the fix and solves the OSL bug elsewhere.

intern/cycles/kernel/bvh/bvh_traversal.h
intern/cycles/kernel/bvh/qbvh_traversal.h
intern/cycles/kernel/osl/osl_services.cpp

index bdf43dcac18342ed20943c613ffa39f03dbd3aef..ae8f54821f225c055bc5db2926fc01a98e30450d 100644 (file)
@@ -244,14 +244,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                {
                                                                        /* shadow ray early termination */
 #if defined(__KERNEL_SSE2__)
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
                                                                        tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
 #  if BVH_FEATURE(BVH_HAIR)
                                                                        tfar = ssef(isect->t);
 #  endif
 #else
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
 #endif
                                                                }
@@ -274,14 +274,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                {
                                                                        /* shadow ray early termination */
 #  if defined(__KERNEL_SSE2__)
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
                                                                        tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
 #    if BVH_FEATURE(BVH_HAIR)
                                                                        tfar = ssef(isect->t);
 #    endif
 #  else
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
 #  endif
                                                                }
@@ -328,14 +328,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
                                                                if(hit) {
                                                                        /* shadow ray early termination */
 #  if defined(__KERNEL_SSE2__)
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
                                                                        tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t);
 #    if BVH_FEATURE(BVH_HAIR)
                                                                        tfar = ssef(isect->t);
 #    endif
 #  else
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE)))
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE)
                                                                                return true;
 #  endif
                                                                }
index 3ee3bf578997b7b0bc4ca0a6d719638278683ff5..335a4afd47a3957ef2c02486f029b8b4ab11377f 100644 (file)
@@ -340,7 +340,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                                      prim_addr)) {
                                                                        tfar = ssef(isect->t);
                                                                        /* Shadow ray early termination. */
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE))) {
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE) {
                                                                                return true;
                                                                        }
                                                                }
@@ -362,7 +362,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                                             prim_addr)) {
                                                                        tfar = ssef(isect->t);
                                                                        /* Shadow ray early termination. */
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE))) {
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE) {
                                                                                return true;
                                                                        }
                                                                }
@@ -409,7 +409,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
                                                                if(hit) {
                                                                        tfar = ssef(isect->t);
                                                                        /* Shadow ray early termination. */
-                                                                       if(!(visibility & (PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE))) {
+                                                                       if(visibility & PATH_RAY_SHADOW_OPAQUE) {
                                                                                return true;
                                                                        }
                                                                }
index 1535496c73dc8d0ea088a924a53c97adfdbb7907..8ad2e12b0678c256d64926000a6e7fb10f71f17c 100644 (file)
@@ -1197,8 +1197,9 @@ bool OSLRenderServices::trace(TraceOpt &options, OSL::ShaderGlobals *sg,
        tracedata->init = true;
        tracedata->sd.osl_globals = sd->osl_globals;
 
-       /* raytrace */
-       return scene_intersect(sd->osl_globals, ray, PATH_RAY_ALL_VISIBILITY, &tracedata->isect, NULL, 0.0f, 0.0f);
+       /* Raytrace, leaving out shadow opaque to avoid early exit. */
+       uint visibility = PATH_RAY_ALL_VISIBILITY - PATH_RAY_SHADOW_OPAQUE;
+       return scene_intersect(sd->osl_globals, ray, visibility, &tracedata->isect, NULL, 0.0f, 0.0f);
 }