From 9f1a7dba362eba36554516f5ca0e12374942031c Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 11 Nov 2026 11:02:31 -0800 Subject: [PATCH] Lane dont_care_depth_stencil: no stencil writes in a pass without a stencil The writing draw's state replaced the stencil in the Depth32Float and Depth16Unorm passes too, which have no stencil attachment: the runtime refuses such a draw (NotImplemented(HiddenDepthStencil), m3-max-16748 on the M3 Max). Metal's probe passes of those formats wrote the depth alone. The state now writes the stencil only where the pass has one. --- .../runtime_lane/dont_care_depth_stencil.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/dont_care_depth_stencil.rs b/crates/metal2vulkan-validation/src/runtime_lane/dont_care_depth_stencil.rs index 42a9d0e21..1aafae66c 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/dont_care_depth_stencil.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/dont_care_depth_stencil.rs @@ -215,13 +215,15 @@ impl Lane { .unwrap() } - /// A depth/stencil state testing the depth with `compare` and writing it where `write`, its - /// stencil test `Always` and replacing where `write`. - fn state(&self, compare: CompareFunction, write: bool) -> DepthStencilState { + /// A depth/stencil state testing the depth with `compare` and writing it where `write`, and + /// where the pass has a `stencil` too, its stencil test `Always` and replacing: a state that + /// writes a stencil the pass lacks is not this lane's (the runtime renders it through a + /// hidden attachment it does not make). + fn state(&self, compare: CompareFunction, write: bool, stencil: bool) -> DepthStencilState { let mut descriptor = DepthStencilDescriptor::default(); descriptor.depth_compare_function = compare; descriptor.depth_write_enabled = write; - if write { + if write && stencil { for face in [ &mut descriptor.front_face_stencil, &mut descriptor.back_face_stencil, @@ -458,7 +460,7 @@ fn separate_depth_and_stencil_loaded_dont_care_and_stored_hold_metal_s_tiles() { let mut failures = Vec::new(); for arrangement in [SEPARATE, COMBINED] { let pipeline = lane.pipeline(arrangement); - let writes = lane.state(CompareFunction::Always, true); + let writes = lane.state(CompareFunction::Always, true, true); let textures = lane.textures(arrangement, 128); let rects = RECTS .iter() @@ -584,7 +586,7 @@ fn a_dont_care_load_s_clear_depth_outside_0_1_or_nan_is_clamped_or_announced() { let mut failures = Vec::new(); for arrangement in [D32, D16, COMBINED, SEPARATE] { let pipeline = lane.pipeline(arrangement); - let writes = lane.state(CompareFunction::Always, true); + let writes = lane.state(CompareFunction::Always, true, arrangement.stencil.is_some()); let textures = lane.textures(arrangement, side); for (name, value) in values { // Metal's held depth, and the runtime's word for it in a stored texel. @@ -655,7 +657,7 @@ fn a_dont_care_load_s_clear_depth_outside_0_1_or_nan_is_clamped_or_announced() { // Not stored, under each depth test. let mut outcomes = Vec::new(); for (test, compare, z) in TESTS { - let state = lane.state(compare, false); + let state = lane.state(compare, false, false); let command_buffer = textures.poison(&lane); let descriptor = textures.pass( LoadAction::Load, @@ -719,7 +721,7 @@ fn a_dont_care_load_s_depth16_clear_announces_the_device_s_rounding() { let messages = Messages::default(); let lane = Lane::new(true, &messages, &cache); let pipeline = lane.pipeline(D16); - let untested = lane.state(CompareFunction::Always, false); + let untested = lane.state(CompareFunction::Always, false, false); let textures = lane.textures(D16, 64); for (clear, rounds) in [(0.0, false), (0.5, true)] { let command_buffer = textures.poison(&lane);