diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index df05b73a..f8efd9b8 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -161,10 +161,18 @@ RenderState Rasterizer::PrepareRenderState(u32 mrt_mask) { state.depth_attachment = { .imageView = *image_view.image_view, .imageLayout = vk::ImageLayout::eUndefined, - .loadOp = is_clear ? vk::AttachmentLoadOp::eClear : vk::AttachmentLoadOp::eLoad, + .loadOp = is_clear && regs.depth_control.depth_enable ? vk::AttachmentLoadOp::eClear + : vk::AttachmentLoadOp::eLoad, .storeOp = vk::AttachmentStoreOp::eStore, - .clearValue = vk::ClearValue{.depthStencil = {.depth = regs.depth_clear, - .stencil = regs.stencil_clear}}, + .clearValue = vk::ClearValue{.depthStencil = {.depth = regs.depth_clear}}, + }; + state.stencil_attachment = { + .imageView = *image_view.image_view, + .imageLayout = vk::ImageLayout::eUndefined, + .loadOp = is_clear && regs.depth_control.stencil_enable ? vk::AttachmentLoadOp::eClear + : vk::AttachmentLoadOp::eLoad, + .storeOp = vk::AttachmentStoreOp::eStore, + .clearValue = vk::ClearValue{.depthStencil = {.stencil = regs.stencil_clear}}, }; texture_cache.TouchMeta(htile_address, slice, false); state.has_depth = @@ -778,6 +786,7 @@ void Rasterizer::BeginRendering(const GraphicsPipeline& pipeline, RenderState& s desc.view_info.range); } state.depth_attachment.imageLayout = image.last_state.layout; + state.stencil_attachment.imageLayout = image.last_state.layout; image.usage.depth_target = true; image.usage.stencil = has_stencil; } diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index 2c4e7a3c..81415f8b 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -47,7 +47,7 @@ void Scheduler::BeginRendering(const RenderState& new_state) { ? render_state.color_attachments.data() : nullptr, .pDepthAttachment = render_state.has_depth ? &render_state.depth_attachment : nullptr, - .pStencilAttachment = render_state.has_stencil ? &render_state.depth_attachment : nullptr, + .pStencilAttachment = render_state.has_stencil ? &render_state.stencil_attachment : nullptr, }; current_cmdbuf.beginRendering(rendering_info); diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index cdd33745..fd5e6837 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -21,6 +21,7 @@ class Instance; struct RenderState { std::array color_attachments{}; vk::RenderingAttachmentInfo depth_attachment{}; + vk::RenderingAttachmentInfo stencil_attachment{}; u32 num_color_attachments{}; bool has_depth{}; bool has_stencil{};