[spv-in] Sampling results for depth textures need to be changed to scalar floats #4551
Labels
area: naga front-end
lang: SPIR-V
Vulkan's Shading Language
naga
Shader Translator
type: enhancement
New feature or request
This is a followup to gfx-rs/naga#2341. Consider the following SPIR-V shader snippet:
OpTypeImage
has a1
after2D
to indicate that it is a depth texture. When it is sampled the sample typed is a 4-component vector as required by the spec.This shader doesn't pass naga validation though because the wgsl spec requires that depth textures sample to scalar floats:
If I manually mess with the the SPIR-V assembly to change the result type of the sample to a scalar float then naga processes it fine (note that this fails SPIR-V validation):
What we need to do in the above case is, upon sampling a depth texture, we need to change the sample type to be a scalar float then insert a composite instruction that creates a 4-component vector with each field set to the scalar sample result (to not break later instructions).
The text was updated successfully, but these errors were encountered: