Skip to content

Reading Stencil Data in Shaders #869

Open
@bjornbytes

Description

@bjornbytes

Currently, shaders can only read depth data from textures with the d24s8 and d32fs8 formats. It could sometimes be useful to read the stencil data as well.

We could support this via the following:

  • Add an aspect option when creating a texture view. It would be ignored for color textures, but can be depth or stencil for depth/stencil textures, defaulting to depth. Also texture:getAspect?
  • Add a stencil8 format (this isn't actually necessary for this feature, but is just nice for completeness).
  • Ensure that usampler and isampler shader resources are supported. We can parse this metadata from SPIR-V, and we have to do it anyway for WebGPU, so may as well.
  • Something something linear sampling for integer formats (samplers with linear filtering can't be used with integer textures). There could be a texture feature for this, possibly some validation, but maybe unnecessary.
  • Double check we're not missing anything to support stencil storage textures.

Hopefully we can get away with all this without actually adding integer texture formats.

There's an entire rabbit hole of other depth vs. stencil stuff we could do, but just sampling stencil data in shaders is a good start.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions