Skip to content

Texture binding sampleType for "float or depth" #3115

Closed

Description

@kainino0x

Originally posted by @kainino0x in #2094 (comment)

OK, here's the proposal, which you can also see in graphical/table form. This should be a non-breaking enhancement that we can do after option 2, and after v1.


Add a new texture binding sampleType "float-or-depth". It is used with texture_2d<f32>. On the color-depth axis it lies between "unfilterable-float" and "depth":

  • float - unfilterable-float - float-or-depth - depth

Compared to `"unfilterable-float", it has two differences:

  • A bind group created against this BGL can bind a depth-format texture here.
  • A pipeline created against this BGL must not use certain ops on the corresponding texture in its shader. An example of such an op could be textureGather(1, ...) (1 here is a compile-time constant according to WGSL)

The benefit of this is that, unlike "depth", "float-or-depth" is compatible with color textures. Therefore, you can use this when you can't determine far enough ahead of time which it is going to be used with, but don't happen to use it with operations forbidden on depth textures (which probably aren't too common).


FWIW, I think this idea could be extended to a "uint-or-stencil" type if we really wanted it, but we don't even have a "stencil" binding type right now, and adding one would be a breaking change. I do have a small concern about new ops being added which don't support stencil textures, but I suspect the reason this is fine (and Metal doesn't have any distinction) is that stencil8 is fundamentally identical to uint8 whereas depth gets much funkier (with depth24unorm and restricted-range depth32float).

Activity

  1. added this to the post-V1 milestone on Jun 29, 2022
  2. kainino0x commented on Jul 23, 2022

    @kainino0x
    ContributorAuthor

    I think this is obsolete with the reconsideration of #2094.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions