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.
Currently, shaders can only read depth data from textures with the
d24s8andd32fs8formats. It could sometimes be useful to read the stencil data as well.We could support this via the following:
aspectoption when creating a texture view. It would be ignored for color textures, but can bedepthorstencilfor depth/stencil textures, defaulting todepth. Alsotexture:getAspect?stencil8format (this isn't actually necessary for this feature, but is just nice for completeness).usamplerandisamplershader resources are supported. We can parse this metadata from SPIR-V, and we have to do it anyway for WebGPU, so may as well.linearfiltering can't be used with integer textures). There could be a texture feature for this, possibly some validation, but maybe unnecessary.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.