[Bf-blender-cvs] [ebf61d94] cycles_kernel_split: Cycles kernel split: Simplify code around kernel function loading

Sergey Sharybin noreply at git.blender.org
Fri May 8 18:32:11 CEST 2015


Commit: ebf61d9489cc5accfeadd10826afb5ce33312604
Author: Sergey Sharybin
Date:   Fri May 8 21:27:47 2015 +0500
Branches: cycles_kernel_split
https://developer.blender.org/rBebf61d9489cc5accfeadd10826afb5ce33312604

Cycles kernel split: Simplify code around kernel function loading

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

M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 3327d95..88c2fbc 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -1812,52 +1812,34 @@ public:
 
 #undef LOAD_KERNEL
 
-		current_clos_max = max_closure;
-
-		/* find kernels */
-		ckPathTraceKernel_DataInit = clCreateKernel(dataInit_program, "kernel_ocl_path_trace_data_initialization", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_SceneIntersect = clCreateKernel(sceneIntersect_program, "kernel_ocl_path_trace_SceneIntersect", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_LampEmission = clCreateKernel(lampEmission_program, "kernel_ocl_path_trace_LampEmission", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_QueueEnqueue = clCreateKernel(QueueEnqueue_program, "kernel_ocl_path_trace_QueueEnqueue", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_BG_BufferUpdate = clCreateKernel(background_BufferUpdate_program, "kernel_ocl_path_trace_Background_BufferUpdate", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_Shader_Lighting = clCreateKernel(shaderEval_program, "kernel_ocl_path_trace_ShaderEvaluation", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_Holdout_Emission_Blurring_Pathtermination_AO = clCreateKernel(holdout_emission_blurring_termination_ao_program, "kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_AO", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_DirectLighting = clCreateKernel(directLighting_program, "kernel_ocl_path_trace_DirectLighting", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
-
-		ckPathTraceKernel_ShadowBlocked_DirectLighting = clCreateKernel(shadowBlocked_program, "kernel_ocl_path_trace_ShadowBlocked_DirectLighting", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
+#define GLUE(a, b) a ## b
+#define FIND_KERNEL(kernel, program, function) \
+	do { \
+		GLUE(ckPathTraceKernel_, kernel) = \
+			clCreateKernel(GLUE(program, _program), \
+			               "kernel_ocl_path_trace_"  function, &ciErr); \
+		if(opencl_error(ciErr)) { \
+			return false; \
+		} \
+	} while(false)
 
-		ckPathTraceKernel_SetUpNextIteration = clCreateKernel(nextIterationSetUp_program, "kernel_ocl_path_trace_SetupNextIteration", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
+		FIND_KERNEL(DataInit, dataInit, "data_initialization");
+		FIND_KERNEL(SceneIntersect, sceneIntersect, "SceneIntersect");
+		FIND_KERNEL(LampEmission, lampEmission, "LampEmission");
+		FIND_KERNEL(QueueEnqueue, QueueEnqueue, "QueueEnqueue");
+		FIND_KERNEL(BG_BufferUpdate, background_BufferUpdate, "Background_BufferUpdate");
+		FIND_KERNEL(Shader_Lighting, shaderEval, "ShaderEvaluation");
+		FIND_KERNEL(Holdout_Emission_Blurring_Pathtermination_AO,
+		            holdout_emission_blurring_termination_ao,
+		            "holdout_emission_blurring_pathtermination_AO");
+		FIND_KERNEL(DirectLighting, directLighting, "DirectLighting");
+		FIND_KERNEL(ShadowBlocked_DirectLighting, shadowBlocked, "ShadowBlocked_DirectLighting");
+		FIND_KERNEL(SetUpNextIteration, nextIterationSetUp, "SetupNextIteration");
+		FIND_KERNEL(SumAllRadiance, sumAllRadiance, "SumAllRadiance");
+#undef FIND_KERNEL
+#undef GLUE
 
-		ckPathTraceKernel_SumAllRadiance = clCreateKernel(sumAllRadiance_program, "kernel_ocl_path_trace_SumAllRadiance", &ciErr);
-		if(opencl_error(ciErr))
-			return false;
+		current_clos_max = max_closure;
 
 		return true;
 	}




More information about the Bf-blender-cvs mailing list