Skip to content

Replace MESH_BINDGROUP_1 with a ShaderDefVal #9256

Closed
@nicopap

Description

@nicopap

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>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-Code-QualityA section of code that is hard to understand or changeD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions