Cycles: slightly improve OpenCL performance by reordering SVM enum values
authorBrecht Van Lommel <brecht@blender.org>
Mon, 23 Mar 2020 23:09:06 +0000 (00:09 +0100)
committerBrecht Van Lommel <brecht@blender.org>
Tue, 24 Mar 2020 15:49:46 +0000 (16:49 +0100)
Ref T71479

intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h

index 0b2cbad4ff88f43e50e45cd9a3eb3eb7f3af288c..abeb8fa74574c1b9ab83edc66f6c6ea53c7ffc48 100644 (file)
@@ -231,6 +231,8 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
     uint4 node = read_node(kg, &offset);
 
     switch (node.x) {
+      case NODE_END:
+        return;
 #if NODES_GROUP(NODE_GROUP_LEVEL_0)
       case NODE_SHADER_JUMP: {
         if (type == SHADER_TYPE_SURFACE)
@@ -539,8 +541,6 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
         svm_node_aov_value(kg, sd, stack, node, buffer);
         break;
 #endif /* NODES_GROUP(NODE_GROUP_LEVEL_4) */
-      case NODE_END:
-        return;
       default:
         kernel_assert(!"Unknown node type was passed to the SVM machine");
         return;
index 86e5a52174a886f4b93d2cf9bfc907febbdf4597..85ede7770e93998a0d23f323bd52cb3daa4b4194 100644 (file)
@@ -63,98 +63,98 @@ CCL_NAMESPACE_BEGIN
 
 typedef enum ShaderNodeType {
   NODE_END = 0,
+  NODE_SHADER_JUMP,
   NODE_CLOSURE_BSDF,
   NODE_CLOSURE_EMISSION,
   NODE_CLOSURE_BACKGROUND,
   NODE_CLOSURE_SET_WEIGHT,
   NODE_CLOSURE_WEIGHT,
+  NODE_EMISSION_WEIGHT,
   NODE_MIX_CLOSURE,
   NODE_JUMP_IF_ZERO,
   NODE_JUMP_IF_ONE,
-  NODE_TEX_IMAGE,
-  NODE_TEX_IMAGE_BOX,
-  NODE_TEX_SKY,
   NODE_GEOMETRY,
-  NODE_GEOMETRY_DUPLI,
-  NODE_LIGHT_PATH,
+  NODE_CONVERT,
+  NODE_TEX_COORD,
   NODE_VALUE_F,
   NODE_VALUE_V,
-  NODE_MIX,
   NODE_ATTR,
-  NODE_CONVERT,
-  NODE_FRESNEL,
-  NODE_WIREFRAME,
-  NODE_WAVELENGTH,
-  NODE_BLACKBODY,
-  NODE_EMISSION_WEIGHT,
-  NODE_TEX_GRADIENT,
-  NODE_TEX_VORONOI,
-  NODE_TEX_MUSGRAVE,
-  NODE_TEX_WAVE,
-  NODE_TEX_MAGIC,
-  NODE_TEX_NOISE,
-  NODE_SHADER_JUMP,
-  NODE_SET_DISPLACEMENT,
+  NODE_VERTEX_COLOR,
   NODE_GEOMETRY_BUMP_DX,
   NODE_GEOMETRY_BUMP_DY,
+  NODE_SET_DISPLACEMENT,
+  NODE_DISPLACEMENT,
+  NODE_VECTOR_DISPLACEMENT,
+  NODE_TEX_IMAGE,
+  NODE_TEX_IMAGE_BOX,
+  NODE_TEX_NOISE,
   NODE_SET_BUMP,
-  NODE_MATH,
-  NODE_VECTOR_MATH,
-  NODE_VECTOR_TRANSFORM,
-  NODE_MAPPING,
-  NODE_TEX_COORD,
-  NODE_TEX_COORD_BUMP_DX,
-  NODE_TEX_COORD_BUMP_DY,
   NODE_ATTR_BUMP_DX,
   NODE_ATTR_BUMP_DY,
-  NODE_TEX_ENVIRONMENT,
+  NODE_VERTEX_COLOR_BUMP_DX,
+  NODE_VERTEX_COLOR_BUMP_DY,
+  NODE_TEX_COORD_BUMP_DX,
+  NODE_TEX_COORD_BUMP_DY,
+  NODE_CLOSURE_SET_NORMAL,
+  NODE_ENTER_BUMP_EVAL,
+  NODE_LEAVE_BUMP_EVAL,
+  NODE_HSV,
   NODE_CLOSURE_HOLDOUT,
+  NODE_FRESNEL,
   NODE_LAYER_WEIGHT,
   NODE_CLOSURE_VOLUME,
-  NODE_SEPARATE_VECTOR,
-  NODE_COMBINE_VECTOR,
-  NODE_SEPARATE_HSV,
-  NODE_COMBINE_HSV,
-  NODE_HSV,
-  NODE_CAMERA,
-  NODE_INVERT,
-  NODE_NORMAL,
+  NODE_PRINCIPLED_VOLUME,
+  NODE_MATH,
+  NODE_VECTOR_MATH,
+  NODE_RGB_RAMP,
   NODE_GAMMA,
-  NODE_TEX_CHECKER,
   NODE_BRIGHTCONTRAST,
-  NODE_RGB_RAMP,
-  NODE_RGB_CURVES,
-  NODE_VECTOR_CURVES,
-  NODE_MIN_MAX,
-  NODE_LIGHT_FALLOFF,
+  NODE_LIGHT_PATH,
   NODE_OBJECT_INFO,
   NODE_PARTICLE_INFO,
+  NODE_HAIR_INFO,
+  NODE_TEXTURE_MAPPING,
+  NODE_MAPPING,
+  NODE_MIN_MAX,
+  NODE_CAMERA,
+  NODE_TEX_ENVIRONMENT,
+  NODE_TEX_SKY,
+  NODE_TEX_GRADIENT,
+  NODE_TEX_VORONOI,
+  NODE_TEX_MUSGRAVE,
+  NODE_TEX_WAVE,
+  NODE_TEX_MAGIC,
+  NODE_TEX_CHECKER,
   NODE_TEX_BRICK,
-  NODE_CLOSURE_SET_NORMAL,
-  NODE_AMBIENT_OCCLUSION,
+  NODE_TEX_WHITE_NOISE,
+  NODE_NORMAL,
+  NODE_LIGHT_FALLOFF,
+  NODE_IES,
+  NODE_RGB_CURVES,
+  NODE_VECTOR_CURVES,
   NODE_TANGENT,
   NODE_NORMAL_MAP,
-  NODE_HAIR_INFO,
-  NODE_UVMAP,
-  NODE_TEX_VOXEL,
-  NODE_ENTER_BUMP_EVAL,
-  NODE_LEAVE_BUMP_EVAL,
-  NODE_BEVEL,
-  NODE_DISPLACEMENT,
-  NODE_VECTOR_DISPLACEMENT,
-  NODE_PRINCIPLED_VOLUME,
-  NODE_IES,
+  NODE_INVERT,
+  NODE_MIX,
+  NODE_SEPARATE_VECTOR,
+  NODE_COMBINE_VECTOR,
+  NODE_SEPARATE_HSV,
+  NODE_COMBINE_HSV,
+  NODE_VECTOR_ROTATE,
+  NODE_VECTOR_TRANSFORM,
+  NODE_WIREFRAME,
+  NODE_WAVELENGTH,
+  NODE_BLACKBODY,
   NODE_MAP_RANGE,
   NODE_CLAMP,
-  NODE_TEXTURE_MAPPING,
-  NODE_TEX_WHITE_NOISE,
-  NODE_VERTEX_COLOR,
-  NODE_VERTEX_COLOR_BUMP_DX,
-  NODE_VERTEX_COLOR_BUMP_DY,
+  NODE_BEVEL,
+  NODE_AMBIENT_OCCLUSION,
+  NODE_TEX_VOXEL,
   NODE_AOV_START,
-  NODE_AOV_VALUE,
   NODE_AOV_COLOR,
-  NODE_VECTOR_ROTATE,
+  NODE_AOV_VALUE,
+  /* NOTE: for best OpenCL performance, item definition in the enum must
+   * match the switch case order in svm.h. */
 } ShaderNodeType;
 
 typedef enum NodeAttributeType {