From c7da76a4c6aa80602e2184977feebcde6d7392aa Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Fri, 11 Aug 2023 22:34:35 +0200 Subject: [PATCH] Validate `DownlevelFlags::READ_ONLY_DEPTH_STENCIL` (#4031) --- CHANGELOG.md | 1 + wgpu-core/src/command/render.rs | 8 +++++++- wgpu-types/src/lib.rs | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a97d995..9ce67f6e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ By @Valaphee in [#3402](https://github.com/gfx-rs/wgpu/pull/3402) ### Changes - Omit texture store bound checks since they are no-ops if out of bounds on all APIs. By @teoxoy in [#3975](https://github.com/gfx-rs/wgpu/pull/3975) +- Validate `DownlevelFlags::READ_ONLY_DEPTH_STENCIL`. By @teoxoy in [#4031](https://github.com/gfx-rs/wgpu/pull/4031) ### Bug Fixes diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 4066bb3a0..3a303cb5a 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -960,7 +960,13 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> { (is_depth_read_only, is_stencil_read_only) = at.depth_stencil_read_only(ds_aspects)?; - let usage = if is_depth_read_only && is_stencil_read_only { + let usage = if is_depth_read_only + && is_stencil_read_only + && device + .downlevel + .flags + .contains(wgt::DownlevelFlags::READ_ONLY_DEPTH_STENCIL) + { hal::TextureUses::DEPTH_STENCIL_READ | hal::TextureUses::RESOURCE } else { hal::TextureUses::DEPTH_STENCIL_WRITE diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 8b493968d..310e10a6c 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1269,8 +1269,8 @@ bitflags::bitflags! { const INDIRECT_EXECUTION = 1 << 2; /// Supports non-zero `base_vertex` parameter to indexed draw calls. const BASE_VERTEX = 1 << 3; - /// Supports reading from a depth/stencil buffer while using as a read-only depth/stencil - /// attachment. + /// Supports reading from a depth/stencil texture while using it as a read-only + /// depth/stencil attachment. /// /// The WebGL2 and GLES backends do not support RODS. const READ_ONLY_DEPTH_STENCIL = 1 << 4;