Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cts_runner/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ webgpu:api,operation,memory_sync,texture,readonly_depth_stencil:sampling_while_t
webgpu:api,operation,memory_sync,texture,readonly_depth_stencil:sampling_while_testing:format="depth32float-stencil8";depthReadOnly=true;stencilReadOnly=true
webgpu:api,operation,memory_sync,texture,readonly_depth_stencil:sampling_while_testing:format="stencil8";*

webgpu:api,operation,render_pass,storeOp:*
webgpu:api,operation,render_pass,*
webgpu:api,operation,render_pipeline,overrides:*
webgpu:api,operation,render_pipeline,pipeline_output_targets:color,component_count,blend:*
webgpu:api,operation,rendering,basic:clear:*
Expand Down
18 changes: 15 additions & 3 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ fn store_hal_ops(store: StoreOp) -> hal::AttachmentOps {
}
}

// Stencil clear and reference value should take the LSBs.
//
// Currently only 8-bit stencil formats are supported, so `value & 255` is OK.
//
// This fixes CTS `webgpu:api,operation,render_pass,clear_value:stencil_clear_value:*`
// on metal and buggy drivers.
Comment thread
beicause marked this conversation as resolved.
Outdated
fn truncate_stencil_value(value: u32) -> u32 {
value & 255
}
Comment thread
beicause marked this conversation as resolved.
Outdated

/// Describes an individual channel within a render pass, such as color, depth, or stencil.
///
/// A channel must either be read-only, or it must specify both load and store
Expand Down Expand Up @@ -1833,7 +1843,7 @@ impl Global {
}

arc_desc.depth_stencil_attachment =
// https://gpuweb.github.io/gpuweb/#abstract-opdef-gpurenderpassdepthstencilattachment-gpurenderpassdepthstencilattachment-valid-usage
// https://gpuweb.github.io/gpuweb/#abstract-opdef-gpurenderpassdepthstencilattachment-gpurenderpassdepthstencilattachment-valid-usage
if let Some(depth_stencil_attachment) = desc.depth_stencil_attachment {
let view = texture_views.get(depth_stencil_attachment.view).get()?;
view.same_device(device)?;
Expand Down Expand Up @@ -1868,7 +1878,9 @@ impl Global {
ResolvedPassChannel::ReadOnly
},
stencil: if format.has_stencil_aspect() {
depth_stencil_attachment.stencil.resolve(|clear| Ok(clear.unwrap_or_default()))?
depth_stencil_attachment.stencil.resolve(|clear| {
Ok(truncate_stencil_value(clear.unwrap_or_default()))
})?
} else {
if depth_stencil_attachment.stencil.load_op.is_some() || depth_stencil_attachment.stencil.store_op.is_some() {
return Err(RenderPassErrorInner::InvalidAttachment(AttachmentError::StencilOpsWithoutAspect {
Expand Down Expand Up @@ -3502,7 +3514,7 @@ impl Global {
) -> Result<(), PassStateError> {
let scope = PassErrorScope::SetStencilReference;
let base = pass_base!(pass, scope);

let value = truncate_stencil_value(value);
base.commands
.push(ArcRenderCommand::SetStencilReference(value));

Expand Down
Loading