Skip to content

Support #define in shader preprocessor #7494

Closed
@LogicFan

Description

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

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions