Adjust cuts on depth draws

This commit is contained in:
CamilleLaVey
2026-09-25 19:03:42 -04:00
parent 63ce0a0527
commit ccbaa75e5e
4 changed files with 17 additions and 1 deletions
@@ -264,6 +264,8 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, bool skip_empty, Func&& draw
pipeline->SetEngine(maxwell3d, gpu_memory); pipeline->SetEngine(maxwell3d, gpu_memory);
if (!pipeline->Configure(is_indexed)) if (!pipeline->Configure(is_indexed))
return; return;
scheduler.MarkDepthWrites(maxwell3d->regs.depth_test_enable != 0 &&
maxwell3d->regs.depth_write_enabled != 0);
UpdateDynamicStates(pipeline->HasDynamicVertexInput()); UpdateDynamicStates(pipeline->HasDynamicVertexInput());
@@ -583,6 +585,7 @@ void RasterizerVulkan::Clear(u32 layer_count) {
if (aspect_flags == 0) { if (aspect_flags == 0) {
return; return;
} }
scheduler.MarkDepthWrites(!can_defer_clear && (aspect_flags & VK_IMAGE_ASPECT_DEPTH_BIT) != 0);
if (use_stencil && framebuffer->HasAspectStencilBit() && regs.stencil_front_mask != 0xFF && if (use_stencil && framebuffer->HasAspectStencilBit() && regs.stencil_front_mask != 0xFF &&
regs.stencil_front_mask != 0) { regs.stencil_front_mask != 0) {
@@ -99,6 +99,7 @@ void Scheduler::BeginRenderPassImpl(const Framebuffer* framebuffer, VkRenderPass
state.framebuffer = framebuffer_handle; state.framebuffer = framebuffer_handle;
state.render_area = render_area; state.render_area = render_area;
++renderpass_serial; ++renderpass_serial;
renderpass_depth_writes = false;
if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) {
const std::string render_pass_info = const std::string render_pass_info =
@@ -161,6 +162,7 @@ void Scheduler::RealizeDeferredClear() {
dc.color_clear_mask, dc.depth_stencil, color_discard_mask, depth_stencil_discard); dc.color_clear_mask, dc.depth_stencil, color_discard_mask, depth_stencil_discard);
EndRenderPass(); EndRenderPass();
BeginRenderPassImpl(dc.framebuffer, renderpass, clear_values.data(), count); BeginRenderPassImpl(dc.framebuffer, renderpass, clear_values.data(), count);
renderpass_depth_writes = dc.depth_stencil;
} }
bool Scheduler::DeferColorClear(const Framebuffer* framebuffer, u32 rt_slot, bool Scheduler::DeferColorClear(const Framebuffer* framebuffer, u32 rt_slot,
@@ -97,6 +97,14 @@ public:
renderpass_writes = true; renderpass_writes = true;
} }
void MarkDepthWrites(bool writes) noexcept {
renderpass_depth_writes |= writes;
}
bool HasDepthWrites() const noexcept {
return renderpass_depth_writes;
}
/// Update the pipeline to the current execution context. /// Update the pipeline to the current execution context.
bool UpdateGraphicsPipeline(GraphicsPipeline* pipeline); bool UpdateGraphicsPipeline(GraphicsPipeline* pipeline);
@@ -334,6 +342,7 @@ private:
u64 renderpass_serial = 0; u64 renderpass_serial = 0;
u64 wfi_serial = 0; u64 wfi_serial = 0;
bool renderpass_writes = false; bool renderpass_writes = false;
bool renderpass_depth_writes = false;
u32 num_renderpass_images = 0; u32 num_renderpass_images = 0;
std::array<VkImage, 9> renderpass_images{}; std::array<VkImage, 9> renderpass_images{};
std::array<VkImageSubresourceRange, 9> renderpass_image_ranges{}; std::array<VkImageSubresourceRange, 9> renderpass_image_ranges{};
@@ -1210,7 +1210,9 @@ void TextureCacheRuntime::EraseResolveShadow(VkImage msaa_image) {
} }
void TextureCacheRuntime::BarrierFeedbackLoop() { void TextureCacheRuntime::BarrierFeedbackLoop() {
scheduler.RequestOutsideRenderPassOperationContext(); if (scheduler.HasDepthWrites()) {
scheduler.RequestOutsideRenderPassOperationContext();
}
} }
void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src,