Cycles: Reorder ShaderData elements to improve cache utilization

Profiling on Arc B580 shown that sd->num_closure queries were often
stalling.
Packing it closer to other often accessed elements within ShaderData
(type, flag..) does speedup rendering by ~5% in most scenes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135980
This commit is contained in:
Xavier Hallade
2025-03-14 09:50:25 +01:00
committed by Gitea
parent 200e26ed15
commit 0ebce03d41

View File

@@ -1122,6 +1122,10 @@ struct ccl_align(16) ShaderData
float3 Ng;
/* view/incoming direction */
float3 wi;
/* combined type and curve segment for hair */
int type;
/* shader id */
int shader;
/* booleans describing shader, see ShaderDataFlag */
@@ -1129,12 +1133,13 @@ struct ccl_align(16) ShaderData
/* booleans describing object of the shader, see ShaderDataObjectFlag */
int object_flag;
/* Closure data, we store a fixed array of closures */
int num_closure;
int num_closure_left;
/* primitive id if there is one, ~0 otherwise */
int prim;
/* combined type and curve segment for hair */
int type;
/* parametric coordinates
* - barycentric weights for triangles */
float u;
@@ -1178,10 +1183,6 @@ struct ccl_align(16) ShaderData
/* LCG state for closures that require additional random numbers. */
uint lcg_state;
/* Closure data, we store a fixed array of closures */
int num_closure;
int num_closure_left;
/* Closure weights summed directly, so we can evaluate
* emission and shadow transparency with MAX_CLOSURE 0. */
Spectrum closure_emission_background;