From 773cb5fa70ecb34e9a70b6ec855b0c2db5fd6eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 21 Aug 2019 21:13:56 +0200 Subject: [PATCH] Stop renderpass merging at readbacks. --- ext/native/thin3d/VulkanQueueRunner.cpp | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ext/native/thin3d/VulkanQueueRunner.cpp b/ext/native/thin3d/VulkanQueueRunner.cpp index 4021e93d62..b2468b556c 100644 --- a/ext/native/thin3d/VulkanQueueRunner.cpp +++ b/ext/native/thin3d/VulkanQueueRunner.cpp @@ -380,7 +380,6 @@ void VulkanQueueRunner::RunSteps(VkCommandBuffer cmd, std::vector &st // Planned optimizations: // * Create copies of render target that are rendered to multiple times and textured from in sequence, and push those render passes // as early as possible in the frame (Wipeout billboards). - // * Merge subsequent render passes to the same target that are interspersed with unrelated draws to other render targets (God of War). for (int j = 0; j < (int)steps.size(); j++) { if (steps[j]->stepType == VKRStepType::RENDER && @@ -721,10 +720,10 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { snprintf(buffer, sizeof(buffer), "Blit (%dx%d->%dx%d)", step.blit.srcRect.extent.width, step.blit.srcRect.extent.height, step.blit.dstRect.extent.width, step.blit.dstRect.extent.height); break; case VKRStepType::READBACK: - snprintf(buffer, sizeof(buffer), "Readback (%dx%d)", step.readback.srcRect.extent.width, step.readback.srcRect.extent.height); + snprintf(buffer, sizeof(buffer), "Readback (%dx%d, fb: %p)", step.readback.srcRect.extent.width, step.readback.srcRect.extent.height, step.readback.src); break; case VKRStepType::READBACK_IMAGE: - snprintf(buffer, sizeof(buffer), "ReadbackImage"); + snprintf(buffer, sizeof(buffer), "ReadbackImage (%dx%d)", step.readback_image.srcRect.extent.width, step.readback_image.srcRect.extent.height); break; case VKRStepType::RENDER_SKIP: snprintf(buffer, sizeof(buffer), "(SKIPPED RenderPass)"); @@ -740,7 +739,6 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { // much a guaranteed neutral or win in terms of GPU power. However, dependency calculation really // must be perfect! void VulkanQueueRunner::ApplyRenderPassMerge(std::vector &steps) { - return; // First let's count how many times each framebuffer is rendered to. // If it's more than one, let's do our best to merge them. This can help God of War quite a bit. @@ -784,6 +782,11 @@ void VulkanQueueRunner::ApplyRenderPassMerge(std::vector &steps) { goto done_fb; } break; + case VKRStepType::READBACK: + if (steps[j]->readback.src == fb) { + goto done_fb; + } + break; } } done_fb: @@ -864,20 +867,20 @@ void VulkanQueueRunner::LogRenderPass(const VKRStep &pass) { ILOG("RenderPass End(%x)", fb); } -void VulkanQueueRunner::LogCopy(const VKRStep &pass) { - ILOG("Copy()"); +void VulkanQueueRunner::LogCopy(const VKRStep &step) { + ILOG("%s", StepToString(step).c_str()); } -void VulkanQueueRunner::LogBlit(const VKRStep &pass) { - ILOG("Blit()"); +void VulkanQueueRunner::LogBlit(const VKRStep &step) { + ILOG("%s", StepToString(step).c_str()); } -void VulkanQueueRunner::LogReadback(const VKRStep &pass) { - ILOG("Readback"); +void VulkanQueueRunner::LogReadback(const VKRStep &step) { + ILOG("%s", StepToString(step).c_str()); } -void VulkanQueueRunner::LogReadbackImage(const VKRStep &pass) { - ILOG("ReadbackImage"); +void VulkanQueueRunner::LogReadbackImage(const VKRStep &step) { + ILOG("%s", StepToString(step).c_str()); } void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer cmd) {