[Bf-blender-cvs] [8945f4f] cycles_kernel_split: Cycles kernel split: Avoid storing size of structures in device members

Sergey Sharybin noreply at git.blender.org
Fri May 8 17:51:43 CEST 2015


Commit: 8945f4f23f7fb0a41be14789481dc88dd0642d86
Author: Sergey Sharybin
Date:   Fri May 8 20:49:02 2015 +0500
Branches: cycles_kernel_split
https://developer.blender.org/rB8945f4f23f7fb0a41be14789481dc88dd0642d86

Cycles kernel split: Avoid storing size of structures in device members

Not sure why it might be considered preferable way, changing those types will
be real pain and really unlikely to happen.

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

M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 2aa271d..2ba696f 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -1427,7 +1427,6 @@ public:
 	cl_mem use_queues_flag;
 
 	/* Required-memory size */
-	size_t rng_size;
 	size_t throughput_size;
 	size_t L_transparent_size;
 	size_t rayState_size;
@@ -1435,24 +1434,9 @@ public:
 	size_t work_element_size;
 	size_t ISLamp_size;
 
-	/* size of structures declared in kernel_types.h */
-	size_t PathRadiance_size;
-	size_t Ray_size;
-	size_t PathState_size;
-	size_t Intersection_size;
-
 	/* Sizes of memory required for shadow blocked function */
 	size_t AOAlpha_size;
 	size_t AOBSDF_size;
-	size_t AOLightRay_size;
-	size_t LightRay_size;
-	size_t BSDFEval_size;
-	size_t Intersection_coop_AO_size;
-	size_t Intersection_coop_DL_size;
-
-#ifdef WITH_CYCLES_DEBUG
-	size_t debugdata_size;
-#endif
 
 	/* Amount of memory in output buffer associated with one pixel/thread */
 	size_t per_thread_output_buffer_size;
@@ -1610,7 +1594,6 @@ public:
 		per_sample_output_buffers = NULL;
 
 		/* Initialize required memory size */
-		rng_size = sizeof(RNG);
 		throughput_size = sizeof(float3);
 		L_transparent_size = sizeof(float);
 		rayState_size = sizeof(char);
@@ -1618,30 +1601,9 @@ public:
 		work_element_size = sizeof(unsigned int);
 		ISLamp_size = sizeof(int);
 
-		/* Initialize size of structures declared in kernel_types.h */
-		PathRadiance_size = sizeof(PathRadiance);
-		Ray_size = sizeof(Ray);
-		PathState_size = sizeof(PathState);
-		Intersection_size = sizeof(Intersection);
-
-		/* Initialize sizes of memory required for shadow blocked function */
-		LightRay_size = sizeof(Ray);
-		BSDFEval_size = sizeof(BsdfEval);
-		Intersection_coop_AO_size = sizeof(Intersection);
-		Intersection_coop_DL_size = sizeof(Intersection);
-
 		/* Initialize sizes of memory required for shadow blocked function */
 		AOAlpha_size = sizeof(float3);
 		AOBSDF_size = sizeof(float3);
-		AOLightRay_size = sizeof(Ray);
-		LightRay_size = sizeof(Ray);
-		BSDFEval_size = sizeof(BsdfEval);
-		Intersection_coop_AO_size = sizeof(Intersection);
-		Intersection_coop_DL_size = sizeof(Intersection);
-
-#ifdef WITH_CYCLES_DEBUG
-		debugdata_size = sizeof(DebugData);
-#endif
 
 		per_thread_output_buffer_size = 0;
 		hostRayStateArray = NULL;
@@ -2404,24 +2366,24 @@ public:
 			ray_dP_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(differential3));
 
 			/* creation of global memory buffers which are shared among the kernels */
-			rng_coop = mem_alloc(num_global_elements * rng_size);
+			rng_coop = mem_alloc(num_global_elements * sizeof(RNG));
 			throughput_coop = mem_alloc(num_global_elements * throughput_size);
 			L_transparent_coop = mem_alloc(num_global_elements * L_transparent_size);
-			PathRadiance_coop = mem_alloc(num_global_elements * PathRadiance_size);
-			Ray_coop = mem_alloc(num_global_elements * Ray_size);
-			PathState_coop = mem_alloc(num_global_elements * PathState_size);
-			Intersection_coop = mem_alloc(num_global_elements * Intersection_size);
+			PathRadiance_coop = mem_alloc(num_global_elements * sizeof(PathRadiance));
+			Ray_coop = mem_alloc(num_global_elements * sizeof(Ray));
+			PathState_coop = mem_alloc(num_global_elements * sizeof(PathState));
+			Intersection_coop = mem_alloc(num_global_elements * sizeof(Intersection));
 			AOAlpha_coop = mem_alloc(num_global_elements * AOAlpha_size);
 			AOBSDF_coop = mem_alloc(num_global_elements * AOBSDF_size);
-			AOLightRay_coop = mem_alloc(num_global_elements * AOLightRay_size);
-			BSDFEval_coop = mem_alloc(num_global_elements * BSDFEval_size);
+			AOLightRay_coop = mem_alloc(num_global_elements * sizeof(Ray));
+			BSDFEval_coop = mem_alloc(num_global_elements * sizeof(BsdfEval));
 			ISLamp_coop = mem_alloc(num_global_elements * ISLamp_size);
-			LightRay_coop = mem_alloc(num_global_elements * LightRay_size);
-			Intersection_coop_AO = mem_alloc(num_global_elements * Intersection_coop_AO_size);
-			Intersection_coop_DL = mem_alloc(num_global_elements * Intersection_coop_DL_size);
+			LightRay_coop = mem_alloc(num_global_elements * sizeof(Ray));
+			Intersection_coop_AO = mem_alloc(num_global_elements * sizeof(Intersection));
+			Intersection_coop_DL = mem_alloc(num_global_elements * sizeof(Intersection));
 
 #ifdef WITH_CYCLES_DEBUG
-			debugdata_coop = mem_alloc(num_global_elements * debugdata_size);
+			debugdata_coop = mem_alloc(num_global_elements * sizeof(DebugData));
 #endif
 
 			ray_state = mem_alloc(num_global_elements * rayState_size);
@@ -2900,14 +2862,14 @@ public:
 		 */
 		shaderdata_volume = get_shader_data_size(shader_closure_size);
 
-		size_t retval = rng_size + throughput_size + L_transparent_size + rayState_size + work_element_size
-			+ ISLamp_size + PathRadiance_size + Ray_size + PathState_size
-			+ Intersection_size                  /* Overall isect */
-			+ Intersection_coop_AO_size          /* Instersection_coop_AO */
-			+ Intersection_coop_DL_size          /* Intersection coop DL */
+		size_t retval = sizeof(RNG) + throughput_size + L_transparent_size + rayState_size + work_element_size
+			+ ISLamp_size + sizeof(PathRadiance) + sizeof(Ray) + sizeof(PathState)
+			+ sizeof(Intersection)    /* Overall isect */
+			+ sizeof(Intersection)    /* Instersection_coop_AO */
+			+ sizeof(Intersection)    /* Intersection coop DL */
 			+ shaderdata_volume       /* Overall ShaderData */
 			+ (shaderdata_volume * 2) /* ShaderData : DL and shadow */
-			+ LightRay_size + BSDFEval_size + AOAlpha_size + AOBSDF_size + AOLightRay_size
+			+ sizeof(Ray) + sizeof(BsdfEval) + AOAlpha_size + AOBSDF_size + sizeof(Ray)
 			+ (sizeof(int)* NUM_QUEUES)
 			+ per_thread_output_buffer_size;




More information about the Bf-blender-cvs mailing list