Using MESH_BINDGROUP_1 as a define results duplicate code. And sometimes nested #ifdef in bevy shader code.
#ifdef MESH_BINDGROUP_1
@group(1) @binding(0)
var<storage> mesh: array<Mesh>;
#else // MESH_BINDGROUP_1
@group(2) @binding(0)
var<storage> mesh: array<Mesh>;
#endif // MESH_BINDGROUP_1
Duplicate code has been a source of programming bumps when developing rendering features. We should aim to reduce it.
What solution would you like?
Use a ShaderDefVal instead of a define for MESH_BINDGROUP.
The previous code would become:
@group(#{MESH_BINDGROUP}) @binding(0)
var<storage> mesh: array<Mesh>;
Using
MESH_BINDGROUP_1as a define results duplicate code. And sometimes nested#ifdefin bevy shader code.Duplicate code has been a source of programming bumps when developing rendering features. We should aim to reduce it.
What solution would you like?
Use a
ShaderDefValinstead of a define forMESH_BINDGROUP.The previous code would become:
@group(#{MESH_BINDGROUP}) @binding(0) var<storage> mesh: array<Mesh>;