[Bf-blender-cvs] [f169ff8b886] master: Fix T50925: Add AO approximation to split kernel

Hristo Gueorguiev noreply at git.blender.org
Mon Mar 13 11:16:07 CET 2017


Commit: f169ff8b8861309bc8a3916f156b0e487795b6be
Author: Hristo Gueorguiev
Date:   Sun Mar 12 22:41:11 2017 +0100
Branches: master
https://developer.blender.org/rBf169ff8b8861309bc8a3916f156b0e487795b6be

Fix T50925: Add AO approximation to split kernel

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

M	intern/cycles/kernel/split/kernel_indirect_background.h
M	intern/cycles/kernel/split/kernel_scene_intersect.h

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

diff --git a/intern/cycles/kernel/split/kernel_indirect_background.h b/intern/cycles/kernel/split/kernel_indirect_background.h
index e314a98105e..96ca0f094b1 100644
--- a/intern/cycles/kernel/split/kernel_indirect_background.h
+++ b/intern/cycles/kernel/split/kernel_indirect_background.h
@@ -18,40 +18,39 @@ CCL_NAMESPACE_BEGIN
 
 ccl_device void kernel_indirect_background(KernelGlobals *kg)
 {
-	/*
-	ccl_local unsigned int local_queue_atomics;
-	if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) {
-		local_queue_atomics = 0;
+
+	ccl_global char *ray_state = kernel_split_state.ray_state;
+
+	int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
+	int ray_index;
+
+	if(kernel_data.integrator.ao_bounces) {
+		ray_index = get_ray_index(kg, thread_index,
+		                          QUEUE_ACTIVE_AND_REGENERATED_RAYS,
+		                          kernel_split_state.queue_data,
+		                          kernel_split_params.queue_size,
+		                          0);
+
+		if(ray_index != QUEUE_EMPTY_SLOT) {
+			if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
+				ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
+				if(state->bounce > kernel_data.integrator.ao_bounces) {
+					ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
+				}
+			}
+		}
 	}
-	ccl_barrier(CCL_LOCAL_MEM_FENCE);
-	// */
 
-	int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
-	ray_index = get_ray_index(kg, ray_index,
+	ray_index = get_ray_index(kg, thread_index,
 	                          QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS,
 	                          kernel_split_state.queue_data,
 	                          kernel_split_params.queue_size,
 	                          0);
 
-#ifdef __COMPUTE_DEVICE_GPU__
-	/* If we are executing on a GPU device, we exit all threads that are not
-	 * required.
-	 *
-	 * If we are executing on a CPU device, then we need to keep all threads
-	 * active since we have barrier() calls later in the kernel. CPU devices,
-	 * expect all threads to execute barrier statement.
-	 */
 	if(ray_index == QUEUE_EMPTY_SLOT) {
 		return;
 	}
-#endif
 
-#ifndef __COMPUTE_DEVICE_GPU__
-	if(ray_index != QUEUE_EMPTY_SLOT) {
-#endif
-
-
-	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];
 	ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
@@ -78,9 +77,6 @@ ccl_device void kernel_indirect_background(KernelGlobals *kg)
 		}
 	}
 
-#ifndef __COMPUTE_DEVICE_GPU__
-	}
-#endif
 
 }
 
diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h
index 144cba67e23..f6fc370060e 100644
--- a/intern/cycles/kernel/split/kernel_scene_intersect.h
+++ b/intern/cycles/kernel/split/kernel_scene_intersect.h
@@ -116,6 +116,11 @@ ccl_device void kernel_scene_intersect(KernelGlobals *kg)
 		lcg_state = lcg_state_init(&rng, &state, 0x51633e2d);
 	}
 
+	if(state.bounce > kernel_data.integrator.ao_bounces) {
+		visibility = PATH_RAY_SHADOW;
+		ray.t = kernel_data.background.ao_distance;
+	}
+
 	bool hit = scene_intersect(kg, ray, visibility, &isect, &lcg_state, difl, extmax);
 #else
 	bool hit = scene_intersect(kg, ray, visibility, &isect, NULL, 0.0f, 0.0f);




More information about the Bf-blender-cvs mailing list