Cycles: Fix handling of barriers
authorMai Lavelle <mai.lavelle@gmail.com>
Thu, 16 Mar 2017 06:16:02 +0000 (02:16 -0400)
committerMai Lavelle <mai.lavelle@gmail.com>
Fri, 17 Mar 2017 05:54:04 +0000 (01:54 -0400)
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/split/kernel_shader_eval.h
intern/cycles/kernel/split/kernel_subsurface_scatter.h

index b6b8916..245832a 100644 (file)
 #  define ccl_addr_space
 #endif
 
-#if defined(__SPLIT_KERNEL__) && !defined(__COMPUTE_DEVICE_GPU__)
-/* TODO(mai): need to investigate how this effects the kernel, as cpu kernel crashes without this right now */
-#define __COMPUTE_DEVICE_GPU__
-#endif
-
 CCL_NAMESPACE_BEGIN
 
 /* constants */
index fc966b7..b739f86 100644 (file)
@@ -38,11 +38,11 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg,
                                  kernel_split_params.queue_size,
                                  0);
 
-       if(ray_index == QUEUE_EMPTY_SLOT) {
-               return;
+       char enqueue_flag = 0;
+       if((ray_index != QUEUE_EMPTY_SLOT) && IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) {
+               enqueue_flag = 1;
        }
 
-       char enqueue_flag = (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_TO_REGENERATE)) ? 1 : 0;
        enqueue_ray_index_local(ray_index,
                                QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS,
                                enqueue_flag,
@@ -52,7 +52,7 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg,
                                kernel_split_params.queue_index);
 
        /* Continue on with shader evaluation. */
-       if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
+       if((ray_index != QUEUE_EMPTY_SLOT) && IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
                Intersection isect = kernel_split_state.isect[ray_index];
                ccl_global uint *rng = &kernel_split_state.rng[ray_index];
                ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
index 709a296..4eaa7f5 100644 (file)
@@ -46,12 +46,12 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg,
        }
 #endif
 
+       char enqueue_flag = 0;
+
 #ifndef __COMPUTE_DEVICE_GPU__
        if(ray_index != QUEUE_EMPTY_SLOT) {
 #endif
 
-
-       char enqueue_flag = 0;
        ccl_global char *ray_state = kernel_split_state.ray_state;
        ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
        PathRadiance *L = &kernel_split_state.path_radiance[ray_index];