hal/vk: use stencil read/write masks

This commit is contained in:
Dzmitry Malyshau 2022-01-11 13:24:08 -05:00
parent 36220b4da5
commit 6bc896fe8c
2 changed files with 10 additions and 5 deletions

View File

@ -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,
}
}

View File

@ -1470,8 +1470,9 @@ impl crate::Device<super::Api> 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)