diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index b77ef051b6..9d91ea054c 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -698,14 +698,18 @@ pub fn map_stencil_op(op: wgt::StencilOperation) -> vk::StencilOp { } } -pub fn map_stencil_face(face: &wgt::StencilFaceState) -> vk::StencilOpState { +pub fn map_stencil_face( + face: &wgt::StencilFaceState, + compare_mask: u32, + write_mask: u32, +) -> vk::StencilOpState { vk::StencilOpState { fail_op: map_stencil_op(face.fail_op), pass_op: map_stencil_op(face.pass_op), depth_fail_op: map_stencil_op(face.depth_fail_op), compare_op: map_comparison(face.compare), - compare_mask: !0, - write_mask: !0, + compare_mask, + write_mask, reference: 0, } } diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 5af777e595..56354ef690 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -1470,8 +1470,9 @@ impl crate::Device for super::Device { .depth_compare_op(conv::map_comparison(ds.depth_compare)); } if ds.stencil.is_enabled() { - let front = conv::map_stencil_face(&ds.stencil.front); - let back = conv::map_stencil_face(&ds.stencil.back); + let s = &ds.stencil; + let front = conv::map_stencil_face(&s.front, s.read_mask, s.write_mask); + let back = conv::map_stencil_face(&s.back, s.read_mask, s.write_mask); vk_depth_stencil = vk_depth_stencil .stencil_test_enable(true) .front(front)