Skip to content

Commit df4ae64

Browse files
Check GPUDepthStencilState.format even when neither is enabled (gfx-rs#8766)
Fixes gfx-rs#8736
1 parent 592736e commit df4ae64

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Bottom level categories:
4545

4646
- Added support for cooperative load/store operations in shaders. Currently only WGSL on the input and SPIR-V, METAL, and WGSL on the output are supported. By @kvark in [#8251](https://github.com/gfx-rs/wgpu/issues/8251).
4747

48+
### Bug Fixes
49+
50+
#### General
51+
52+
- Fixed validation of the texture format in GPUDepthStencilState when neither depth nor stencil is actually enabled. By @andyleiserson in [#8766](https://github.com/gfx-rs/wgpu/pull/8766).
53+
4854
### Documentation
4955

5056
#### General

cts_runner/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ webgpu:api,validation,render_pass,render_pass_descriptor:attachments,*
135135
webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,*
136136
webgpu:api,validation,render_pass,render_pass_descriptor:resolveTarget,*
137137
webgpu:api,validation,render_pass,resolve:resolve_attachment:*
138+
webgpu:api,validation,render_pipeline,depth_stencil_state:format:*
138139
webgpu:api,validation,render_pipeline,depth_stencil_state:stencil_write:*
139140
webgpu:api,validation,resource_usages,buffer,in_pass_encoder:*
140141
// FAIL: 2 other cases in resource_usages,texture,in_pass_encoder. https://github.com/gfx-rs/wgpu/issues/3126

wgpu-core/src/device/resource.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4141,6 +4141,14 @@ impl Device {
41414141
if let Some(ds) = depth_stencil_state {
41424142
target_specified = true;
41434143
let error = 'error: {
4144+
if !ds.format.is_depth_stencil_format() {
4145+
// This error case is not redundant with the aspect check below when
4146+
// neither depth nor stencil is enabled at all.
4147+
break 'error Some(pipeline::DepthStencilStateError::FormatNotDepthOrStencil(
4148+
ds.format,
4149+
));
4150+
}
4151+
41444152
let format_features = self.describe_format_features(ds.format)?;
41454153
if !format_features
41464154
.allowed_usages

wgpu-core/src/pipeline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ pub enum ColorStateError {
617617
pub enum DepthStencilStateError {
618618
#[error("Format {0:?} is not renderable")]
619619
FormatNotRenderable(wgt::TextureFormat),
620+
#[error("Format {0:?} is not a depth/stencil format")]
621+
FormatNotDepthOrStencil(wgt::TextureFormat),
620622
#[error("Format {0:?} does not have a depth aspect, but depth test/write is enabled")]
621623
FormatNotDepth(wgt::TextureFormat),
622624
#[error("Format {0:?} does not have a stencil aspect, but stencil test/write is enabled")]

0 commit comments

Comments
 (0)