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

Support #define in shader preprocessor #7494

Closed
LogicFan opened this issue Feb 3, 2023 · 2 comments
Closed

Support #define in shader preprocessor #7494

LogicFan opened this issue Feb 3, 2023 · 2 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@LogicFan
Copy link
Contributor

LogicFan commented Feb 3, 2023

What problem does this solve or what need does it fill?

if we have 3 shader files common.wgsl, util1.wgsl, util2.wgsl, and if both util1.wgsl and util2.wgsl includes common.wgsl, then if the main shader file include both util1.wgsl and util2.wgsl, it will cause a problem, because function re-definition (i.e. common.wgsl imported twice).

What solution would you like?

one solution would be to support #define in the shader preprocess (i.e. define a label used for #ifdef #ifndef). Then we can write an include guard similar to the include file in C.

What alternative(s) have you considered?

there could be several other method,

  1. have #import once declarative indicate this file should only be imported once.
  2. bevy preprocessor automatically remove the duplicate function (however, how to define duplicate function is questionable)
  3. do nothing, and let user keep track of import and make sure no duplicate imports happen.

Additional context

@LogicFan LogicFan added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 3, 2023
@james7132 james7132 added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Feb 4, 2023
@LogicFan
Copy link
Contributor Author

LogicFan commented Feb 4, 2023

I think this feature is already added by PR #5900.

@LogicFan LogicFan closed this as completed Feb 4, 2023
@mockersf
Copy link
Member

mockersf commented Feb 4, 2023

Not yet, but I plan on adding it!

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-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants