Skip to content

Per-pipeline binding points #4459

@martinfouilleul

Description

@martinfouilleul

Currently it seems binding points can only be specified at the module level. This means you can't really have multiple pipelines defined in a single module, unless they have exactly the same binding points with the same read/write attributes.

For instance, say you have two shaders sharing common data structures and utility functions, and shader A uses a buffer as a read/write atomic, and shader B later needs only to read the results. These two shaders can't really be defined in the same module, unless you needlessly force B to use the buffer as read/write atomic even though it only reads from it.

You can of course split your code into multiple fragments, manually append the common parts, and compile to different modules, but this has some downsides:

  • it forces compiling the common code multiple times
  • the burden is now on the user to have the scaffolding in place to combine code fragments and keep track of source locations (especially since there's no #line directive)
  • Having all your shaders in the same file, especially if they are supposed to cooperate on data structs and logic, would be a nice quality of life improvement.

Are there plans to scope binding points to specific entry-points (e.g. similar to what MSL does)? It seems this would let users organize their shader code as they see fit, without having to unnecessarily share binding points or write a preprocessor and duplicate compiler work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions