From 277528355b3dde08073ede514884b3d66b64de94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Capucho?= Date: Tue, 31 Jan 2023 16:46:24 +0000 Subject: [PATCH] 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 --- voxygen/src/render/pipelines/clouds.rs | 4 ++-- voxygen/src/render/pipelines/postprocess.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/voxygen/src/render/pipelines/clouds.rs b/voxygen/src/render/pipelines/clouds.rs index 2b7cc2da0c..498704a8b0 100644 --- a/voxygen/src/render/pipelines/clouds.rs +++ b/voxygen/src/render/pipelines/clouds.rs @@ -62,7 +62,7 @@ impl CloudsLayout { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::Texture { - sample_type: wgpu::TextureSampleType::Float { filterable: true }, + sample_type: wgpu::TextureSampleType::Float { filterable: false }, view_dimension: wgpu::TextureViewDimension::D2, multisampled: false, }, @@ -72,7 +72,7 @@ impl CloudsLayout { binding: 3, visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::Sampler { - filtering: true, + filtering: false, comparison: false, }, count: None, diff --git a/voxygen/src/render/pipelines/postprocess.rs b/voxygen/src/render/pipelines/postprocess.rs index 5f069db833..4733a04690 100644 --- a/voxygen/src/render/pipelines/postprocess.rs +++ b/voxygen/src/render/pipelines/postprocess.rs @@ -58,7 +58,7 @@ impl PostProcessLayout { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::Texture { - sample_type: wgpu::TextureSampleType::Float { filterable: true }, + sample_type: wgpu::TextureSampleType::Float { filterable: false }, view_dimension: wgpu::TextureViewDimension::D2, multisampled: false, }, @@ -68,7 +68,7 @@ impl PostProcessLayout { binding: 3, visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::Sampler { - filtering: true, + filtering: false, comparison: false, }, count: None,