Open
Description
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 bedepth
orstencil
for depth/stencil textures, defaulting todepth
. Alsotexture:getAspect
? - Add a
stencil8
format (this isn't actually necessary for this feature, but is just nice for completeness). - Ensure that
usampler
andisampler
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.