You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|variable| has type `texture_depth_2d`, `texture_depth_2d_array`,
6066
+
|variable| has type `texture_2d<f32>`, `texture_depth_2d`, `texture_depth_2d_array`,
6067
6067
`texture_depth_cube`, `texture_depth_cube_array`, or `texture_depth_multisampled_2d`.
6068
6068
</dl>
6069
6069
::
@@ -13264,22 +13264,33 @@ be used with {{GPUSamplerBindingType/"comparison"}} samplers (which may use filt
13264
13264
13265
13265
#### Reading and Sampling Depth/Stencil Textures #### {#reading-depth-stencil}
13266
13266
13267
-
When reading or sampling a depth component via a `texture_depth_*`-typed binding, the value is
13268
-
returned as an `f32` value.
13267
+
It is possible to bind a depth-aspect {{GPUTextureView}} to either a `texture_depth_*` binding
13268
+
or a `texture_2d<f32>` binding. In both cases, the {{GPUTextureBindingLayout/sampleType}} must
13269
+
be {{GPUTextureSampleType/"depth"}}.
13269
13270
13270
-
Issue(gpuweb/gpuweb#2094): Depending on the resolution of this issue, allow reading/sampling via
13271
-
`texture_2d` etc. in the table above and specify the behavior. (`vec4<f32>(D, X, X, X)`?)
13272
-
Update the note below which would become slightly outdated.
13271
+
When reading or sampling a depth aspect via a binding with type `texture_2d<f32>`,
13272
+
it behaves as if the texture contains the values `(D, X, X, X)`, where D is the depth value
13273
+
and each X is an implementation-defined unspecified value.
13273
13274
13274
-
Reading or sampling a stencil component must be done via a normal texture binding
13275
-
(`texture_2d`, `texture_2d_array`, `texture_cube`, or `texture_cube_array`).
13276
-
When doing so, the value is returned as `vec4<u32>(S, X, X, X)`, where S is the stencil value and each X is an implementation-defined unspecified value.
13277
-
Authors must not rely on these `.y`, `.z`, and `.w` components, as their behavior is non-portable.
13275
+
Reading or sampling a stencil aspect must be done via a normal texture binding
13276
+
(`texture_2d`, `texture_2d_array`, `texture_cube`, or `texture_cube_array`). When doing so,
13277
+
it behaves as if the texture contains the values `(S, X, X, X)`, where S is the stencil value
13278
+
and each X is an implementation-defined unspecified value.
13279
+
13280
+
<div class=example>
13281
+
If a depth texture is bound to `tex` with type `texture_2d<f32>`:
13282
+
13283
+
- `textureSample(tex, ...)` will return `vec4<f32>(D, X, X, X)`.
13284
+
- `textureGather(0, tex, ...)` will return `vec4<f32>(D1, D2, D3, D4)`.
13285
+
- `textureGather(2, tex, ...)` will return `vec4<f32>(X1, X2, X3, X4)` (a completely unspecified value).
13286
+
</div>
13278
13287
13279
13288
Note:
13280
-
Short of adding a new more constrained stencil sampler type (like depth), it's infeasible for implementations to efficiently paper over the driver differences for stencil reads.
13289
+
Short of adding a new more constrained stencil sampler type (like depth), it's infeasible for
13290
+
implementations to efficiently paper over the driver differences for depth/stencil reads.
13281
13291
As this was not a portability pain point for WebGL, it's not expected to be problematic in WebGPU.
13282
-
In practice, expect either `vec4<u32>(S, S, S, S)` or `vec4<u32>(S, 0, 0, 1)`, depending on hardware.
13292
+
In practice, expect either `(V, V, V, V)` or `(V, 0, 0, 1)` (where `V` is the depth or stencil
0 commit comments