Skip to content

Commit

Permalink
hal/vk: use stencil read/write masks
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jan 11, 2022
1 parent 36220b4 commit 6bc896f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions wgpu-hal/src/vulkan/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
5 changes: 3 additions & 2 deletions wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6bc896f

Please sign in to comment.