Cycles: OpenCL Performance

When using OpenCL with Cycles the rendering time increased substantial.
After doing some tests the bottleneck was found in 4d voronoi and 2d and
3d smooth voronoi.

This change will hide these behind a specific compile directive so the
speed will improve.

AMD RX480 + BMW scene

    2.80 (3:10)
    2.81 (5:48)
    2.81 excluding 4d voronoi+2d/3d smooth (3:50)

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D6231
This commit is contained in:
Jeroen Bakker 2019-11-13 08:03:44 +01:00 committed by Jeroen Bakker
parent ca1721270a
commit e527544b76
Notes: blender-bot 2023-02-14 05:59:31 +01:00
Referenced by issue #71479, Blender 2.81/2.82 - OpenCL - Significan slow render times
4 changed files with 25 additions and 7 deletions

View File

@ -214,9 +214,6 @@ CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN
#define NODES_GROUP(group) ((group) <= __NODES_MAX_GROUP__)
#define NODES_FEATURE(feature) ((__NODES_FEATURES__ & (feature)) != 0)
/* Main Interpreter Loop */
ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
ShaderData *sd,
@ -545,9 +542,6 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg,
}
}
#undef NODES_GROUP
#undef NODES_FEATURE
CCL_NAMESPACE_END
#endif /* __SVM_H__ */

View File

@ -48,12 +48,17 @@ CCL_NAMESPACE_BEGIN
#define NODE_FEATURE_HAIR (1 << 1)
#define NODE_FEATURE_BUMP (1 << 2)
#define NODE_FEATURE_BUMP_STATE (1 << 3)
#define NODE_FEATURE_VORONOI_EXTRA (1 << 4)
/* TODO(sergey): Consider using something like ((uint)(-1)).
* Need to check carefully operand types around usage of this
* define first.
*/
#define NODE_FEATURE_ALL \
(NODE_FEATURE_VOLUME | NODE_FEATURE_HAIR | NODE_FEATURE_BUMP | NODE_FEATURE_BUMP_STATE)
(NODE_FEATURE_VOLUME | NODE_FEATURE_HAIR | NODE_FEATURE_BUMP | NODE_FEATURE_BUMP_STATE | \
NODE_FEATURE_VORONOI_EXTRA)
#define NODES_GROUP(group) ((group) <= __NODES_MAX_GROUP__)
#define NODES_FEATURE(feature) ((__NODES_FEATURES__ & (feature)) != 0)
typedef enum ShaderNodeType {
NODE_END = 0,

View File

@ -986,6 +986,7 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
&color_out,
&position_out_2d);
break;
#if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA)
case NODE_VORONOI_SMOOTH_F1:
voronoi_smooth_f1_2d(coord_2d,
smoothness,
@ -996,6 +997,7 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
&color_out,
&position_out_2d);
break;
#endif
case NODE_VORONOI_F2:
voronoi_f2_2d(coord_2d,
exponent,
@ -1029,6 +1031,7 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
&color_out,
&position_out);
break;
#if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA)
case NODE_VORONOI_SMOOTH_F1:
voronoi_smooth_f1_3d(coord,
smoothness,
@ -1039,6 +1042,7 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
&color_out,
&position_out);
break;
#endif
case NODE_VORONOI_F2:
voronoi_f2_3d(coord,
exponent,
@ -1060,6 +1064,8 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
position_out = safe_divide_float3_float(position_out, scale);
break;
}
#if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA)
case 4: {
float4 coord_4d = make_float4(coord.x, coord.y, coord.z, w);
float4 position_out_4d;
@ -1106,6 +1112,7 @@ ccl_device void svm_node_tex_voronoi(KernelGlobals *kg,
w_out = position_out_4d.w;
break;
}
#endif
default:
kernel_assert(0);
}

View File

@ -220,6 +220,18 @@ class VoronoiTextureNode : public TextureNode {
return NODE_GROUP_LEVEL_2;
}
virtual int get_feature()
{
int result = ShaderNode::get_feature();
if (dimensions == 4) {
result |= NODE_FEATURE_VORONOI_EXTRA;
}
else if (dimensions >= 2 && feature == NODE_VORONOI_SMOOTH_F1) {
result |= NODE_FEATURE_VORONOI_EXTRA;
}
return result;
}
int dimensions;
NodeVoronoiDistanceMetric metric;
NodeVoronoiFeature feature;