Skip to content

Support BindingType StorageTexture in AsBindGroup #7640

Closed

Description

@pkupper

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

Currently the AsBindGroup macro supports the BindingTypes Uniform, Texture, Sampler and Storage.
Wgpu also has the BindingType type StorageTexture which enables direct read/write access to textures without sampling (e.g. from a compute shader where samplers are not supported). This is currently not supported by the AsBindGroup macro.

For an example use case check out Bevy's compute_shader_game_of_life example. This example currently cannot be written using AsBindGroup.

What solution would you like?

The AsBindGroup derive macro should support the BindingType StorageTexture in ReadOnly, ReadWrite and WriteOnly configurations in order to enable compute shader processing of textures.

What alternative(s) have you considered?

Continue constructing BindGroups and BindGroupLayouts manually for this use case.

Additional context

The BindingType Storage was added in #6129. This PR could perhaps serve as reference for implementing the BindingType StorageTexture

Activity

  1. added
    C-FeatureA new feature, making something new possible
    S-Needs-TriageThis issue needs to be labelled
    on Feb 12, 2023
  2. Patryk27 commented on Feb 13, 2023

    @Patryk27

    e.g. from a compute shader where samplers are not supported

    fwiw, compute shaders support samplers - you just have to provide explicit LOD 🙂

  3. pkupper commented on Feb 13, 2023

    @pkupper
    ContributorAuthor

    Thank you @Patryk27, that's good to know!
    Unfortunately, I also need to write to a texture which cannot be done with a regular Texture binding. That still requires a StorageTexture binding.

  4. added
    A-RenderingDrawing game state to the screen
    and removed
    S-Needs-TriageThis issue needs to be labelled
    on Feb 17, 2023
  5. MMukundi commented on Apr 26, 2023

    @MMukundi

    Hi all!
    I'm new to the repo (and open source in general actually), but I came across this issue myself after reading over the compute_shader_game_of_life example, and was inspired to take a look. I have a functioning implementation in a fork I've been toying around with locally and would be happy to contribute it to the main repo!
    I would appreciate some guidance on what the process looks like though if possible: should I just open the PR from my fork and go from there?

  6. kristoff3r commented on Feb 19, 2024

    @kristoff3r
    Contributor

    This was introduced in #9943, so this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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