mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 14:23:32 +00:00
WIP: feat: only require depth config. for fmts. w/ depth
TODO: Ensure that the following changes and discussion get represented in code: - https://github.com/gpuweb/gpuweb/pull/4318/files - https://github.com/gpuweb/gpuweb/issues/3905 - https://github.com/gpuweb/gpuweb/pull/3849/files#r1122411287
This commit is contained in:
parent
ea75a8ced4
commit
ca767f7d74
@ -3146,8 +3146,23 @@ impl Device {
|
||||
}
|
||||
|
||||
let aspect = hal::FormatAspects::from(ds.format);
|
||||
if ds.is_depth_enabled() && !aspect.contains(hal::FormatAspects::DEPTH) {
|
||||
break 'error Some(pipeline::DepthStencilStateError::FormatNotDepth(ds.format));
|
||||
match (
|
||||
aspect.contains(hal::FormatAspects::DEPTH),
|
||||
ds.depth_write_enabled.zip(ds.depth_compare),
|
||||
) {
|
||||
(true, Some(_)) | (false, None) => (),
|
||||
(true, None) => {
|
||||
break 'error Some(pipeline::DepthStencilStateError::DepthOpsNotSpecified {
|
||||
format: ds.format,
|
||||
depth_write_enabled: ds.depth_write_enabled,
|
||||
depth_compare: ds.depth_compare,
|
||||
})
|
||||
}
|
||||
(false, Some(_)) => {
|
||||
break 'error Some(pipeline::DepthStencilStateError::FormatNotDepth(
|
||||
ds.format,
|
||||
))
|
||||
}
|
||||
}
|
||||
if ds.stencil.is_enabled() && !aspect.contains(hal::FormatAspects::STENCIL) {
|
||||
break 'error Some(pipeline::DepthStencilStateError::FormatNotStencil(
|
||||
|
@ -4884,10 +4884,12 @@ pub struct DepthStencilState {
|
||||
///
|
||||
/// [CEbrp]: ../wgpu/struct.CommandEncoder.html#method.begin_render_pass
|
||||
pub format: TextureFormat,
|
||||
/// If disabled, depth will not be written to.
|
||||
pub depth_write_enabled: bool,
|
||||
/// Comparison function used to compare depth values in the depth test.
|
||||
pub depth_compare: CompareFunction,
|
||||
/// If disabled, depth will not be written to. Must be specified if `format` has a depth
|
||||
/// component.
|
||||
pub depth_write_enabled: Option<bool>,
|
||||
/// Comparison function used to compare depth values in the depth test. Must be specified if
|
||||
/// `format` has a depth component.
|
||||
pub depth_compare: Option<CompareFunction>,
|
||||
/// Stencil state.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub stencil: StencilState,
|
||||
@ -4900,13 +4902,15 @@ impl DepthStencilState {
|
||||
/// Returns true if the depth testing is enabled.
|
||||
#[must_use]
|
||||
pub fn is_depth_enabled(&self) -> bool {
|
||||
self.depth_compare != CompareFunction::Always || self.depth_write_enabled
|
||||
self.depth_compare
|
||||
.map_or(false, |dc| dc != CompareFunction::Always)
|
||||
|| self.depth_write_enabled
|
||||
}
|
||||
|
||||
/// Returns true if the state doesn't mutate the depth buffer.
|
||||
#[must_use]
|
||||
pub fn is_depth_read_only(&self) -> bool {
|
||||
!self.depth_write_enabled
|
||||
self.depth_write_enabled.map_or(false, |enabled| !enabled)
|
||||
}
|
||||
|
||||
/// Returns true if the state doesn't mutate the stencil.
|
||||
|
Loading…
Reference in New Issue
Block a user