Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace MESH_BINDGROUP_1 with a ShaderDefVal #9256

Closed
nicopap opened this issue Jul 23, 2023 · 3 comments
Closed

Replace MESH_BINDGROUP_1 with a ShaderDefVal #9256

nicopap opened this issue Jul 23, 2023 · 3 comments
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@nicopap
Copy link
Contributor

nicopap commented Jul 23, 2023

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>;
@nicopap nicopap added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change labels Jul 23, 2023
@JMS55
Copy link
Contributor

JMS55 commented Jul 23, 2023

I use the same pattern in bevy_solari, I'm in favor :)

@JMS55 JMS55 added the D-Trivial Nice and easy! A great choice to get started with Bevy label Jul 23, 2023
@robtfm
Copy link
Contributor

robtfm commented Jul 24, 2023

I didn’t do this originally because I didn’t want to force every pipeline author to include a def which would 95% of the time be the same thing (i.e. 2) …
As long as we have 2 as the default for when it’s not defined, it sounds good.

@JMS55
Copy link
Contributor

JMS55 commented Feb 5, 2024

MESH_BIND_GROUP_1 was removed #10485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants