Fix stencil buffer not being used (#464)

This commit is contained in:
Vladislav Mikhalin 2024-08-18 20:37:29 +03:00 committed by GitHub
parent 63938ba8dd
commit 1c898d0842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 6 deletions

View File

@ -452,7 +452,7 @@ struct Liverpool {
BitField<11, 1, u32> enable_polygon_offset_front; BitField<11, 1, u32> enable_polygon_offset_front;
BitField<12, 1, u32> enable_polygon_offset_back; BitField<12, 1, u32> enable_polygon_offset_back;
BitField<13, 1, u32> enable_polygon_offset_para; BitField<13, 1, u32> enable_polygon_offset_para;
BitField<13, 1, u32> enable_window_offset; BitField<16, 1, u32> enable_window_offset;
BitField<19, 1, ProvokingVtxLast> provoking_vtx_last; BitField<19, 1, ProvokingVtxLast> provoking_vtx_last;
PolygonMode PolyMode() const { PolygonMode PolyMode() const {

View File

@ -172,10 +172,17 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.reference = key.stencil_ref_front.stencil_test_val, .reference = key.stencil_ref_front.stencil_test_val,
}, },
.back{ .back{
.failOp = LiverpoolToVK::StencilOp(key.stencil.stencil_fail_back), .failOp = LiverpoolToVK::StencilOp(key.depth.backface_enable
.passOp = LiverpoolToVK::StencilOp(key.stencil.stencil_zpass_back), ? key.stencil.stencil_fail_back
.depthFailOp = LiverpoolToVK::StencilOp(key.stencil.stencil_zfail_back), : key.stencil.stencil_fail_front),
.compareOp = LiverpoolToVK::CompareOp(key.depth.stencil_bf_func), .passOp = LiverpoolToVK::StencilOp(key.depth.backface_enable
? key.stencil.stencil_zpass_back
: key.stencil.stencil_zpass_front),
.depthFailOp = LiverpoolToVK::StencilOp(key.depth.backface_enable
? key.stencil.stencil_zfail_back
: key.stencil.stencil_zfail_front),
.compareOp = LiverpoolToVK::CompareOp(
key.depth.backface_enable ? key.depth.stencil_bf_func : key.depth.stencil_ref_func),
.compareMask = key.stencil_ref_back.stencil_mask, .compareMask = key.stencil_ref_back.stencil_mask,
.writeMask = key.stencil_ref_back.stencil_write_mask, .writeMask = key.stencil_ref_back.stencil_write_mask,
.reference = key.stencil_ref_back.stencil_test_val, .reference = key.stencil_ref_back.stencil_test_val,
@ -207,7 +214,8 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
.colorAttachmentCount = num_color_formats, .colorAttachmentCount = num_color_formats,
.pColorAttachmentFormats = key.color_formats.data(), .pColorAttachmentFormats = key.color_formats.data(),
.depthAttachmentFormat = key.depth_format, .depthAttachmentFormat = key.depth_format,
.stencilAttachmentFormat = vk::Format::eUndefined, .stencilAttachmentFormat =
key.depth.stencil_enable ? key.depth_format : vk::Format::eUndefined,
}; };
std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments; std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments;

View File

@ -39,6 +39,7 @@ void Scheduler::BeginRendering(const RenderState& new_state) {
.colorAttachmentCount = render_state.num_color_attachments, .colorAttachmentCount = render_state.num_color_attachments,
.pColorAttachments = render_state.color_attachments.data(), .pColorAttachments = render_state.color_attachments.data(),
.pDepthAttachment = render_state.has_depth ? &render_state.depth_attachment : nullptr, .pDepthAttachment = render_state.has_depth ? &render_state.depth_attachment : nullptr,
.pStencilAttachment = render_state.has_stencil ? &render_state.depth_attachment : nullptr,
}; };
current_cmdbuf.beginRendering(rendering_info); current_cmdbuf.beginRendering(rendering_info);