Fix depth textures being bound as float textures

Webgpu defines that a texture depth format can only be sampled as a
depth texture or as an "unfilterable-float", however both the clouds and
postprocess pipeline were declaring in their bind group that the depth
source was a texture with a sample type of float (filterable).

This is forbidden by the webgpu specification and should be caught by
validation, but the version of wgpu we are using doesn't have that check
(older versions have the check), so we can only assume that this is
undefined behavior.

Relevant sources:
- [Bind Group Creation](https://gpuweb.github.io/gpuweb/#bind-group-creation)
includes the rules that explicitly forbid this situation
- [Depth-stencil formats](https://gpuweb.github.io/gpuweb/#depth-formats)
defines which sample types we are allowed to use with depth textures
This commit is contained in:
João Capucho 2023-01-31 16:46:24 +00:00
parent ba2f51e5e0
commit 277528355b
No known key found for this signature in database
GPG Key ID: 217CDF64C83185E7
2 changed files with 4 additions and 4 deletions

View File

@ -62,7 +62,7 @@ impl CloudsLayout {
binding: 2, binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Texture { ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float { filterable: true }, sample_type: wgpu::TextureSampleType::Float { filterable: false },
view_dimension: wgpu::TextureViewDimension::D2, view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false, multisampled: false,
}, },
@ -72,7 +72,7 @@ impl CloudsLayout {
binding: 3, binding: 3,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { ty: wgpu::BindingType::Sampler {
filtering: true, filtering: false,
comparison: false, comparison: false,
}, },
count: None, count: None,

View File

@ -58,7 +58,7 @@ impl PostProcessLayout {
binding: 2, binding: 2,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Texture { ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float { filterable: true }, sample_type: wgpu::TextureSampleType::Float { filterable: false },
view_dimension: wgpu::TextureViewDimension::D2, view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false, multisampled: false,
}, },
@ -68,7 +68,7 @@ impl PostProcessLayout {
binding: 3, binding: 3,
visibility: wgpu::ShaderStage::FRAGMENT, visibility: wgpu::ShaderStage::FRAGMENT,
ty: wgpu::BindingType::Sampler { ty: wgpu::BindingType::Sampler {
filtering: true, filtering: false,
comparison: false, comparison: false,
}, },
count: None, count: None,