From 2dd4cbe33d24dcb9f40ec9b623d788e3291dc4d6 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 29 Sep 2024 16:01:39 +0200 Subject: [PATCH] vk oit: draw transparent polys in the first frame after (re)init Fixes missing background in progress window in Fighting Force 2 Issue #1652 --- core/rend/vulkan/oit/oit_drawer.cpp | 29 +++++++++++-------------- core/rend/vulkan/oit/oit_pipeline.cpp | 2 +- core/rend/vulkan/oit/oit_renderpass.cpp | 4 ++++ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/rend/vulkan/oit/oit_drawer.cpp b/core/rend/vulkan/oit/oit_drawer.cpp index 81a3c0d4c6..5483ea79d4 100644 --- a/core/rend/vulkan/oit/oit_drawer.cpp +++ b/core/rend/vulkan/oit/oit_drawer.cpp @@ -401,11 +401,21 @@ bool OITDrawer::Draw(const Texture *fogTexture, const Texture *paletteTexture) DrawList(cmdBuffer, ListType_Punch_Through, false, Pass::Color, pvrrc.global_param_pt, previous_pass.pt_count, current_pass.pt_count); // TR - if (current_pass.autosort) + if (firstFrameAfterInit) { - if (!firstFrameAfterInit) - DrawList(cmdBuffer, ListType_Translucent, true, Pass::OIT, pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count); + // Clear abuffers + cmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelineManager->GetClearPipeline()); + quadBuffer->Bind(cmdBuffer); + quadBuffer->Draw(cmdBuffer); + + vk::MemoryBarrier memoryBarrier(vk::AccessFlagBits::eShaderWrite, vk::AccessFlagBits::eShaderRead); + cmdBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader, vk::PipelineStageFlagBits::eFragmentShader, + vk::DependencyFlagBits::eByRegion, memoryBarrier, nullptr, nullptr); + cmdBuffer.bindVertexBuffers(0, curMainBuffer, {0}); + firstFrameAfterInit = false; } + if (current_pass.autosort) + DrawList(cmdBuffer, ListType_Translucent, true, Pass::OIT, pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count); else DrawList(cmdBuffer, ListType_Translucent, false, Pass::Color, pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count); @@ -423,19 +433,6 @@ bool OITDrawer::Draw(const Texture *fogTexture, const Texture *paletteTexture) } SetScissor(cmdBuffer, baseScissor); - if (firstFrameAfterInit) - { - // missing the transparent stuff on the first frame cuz I'm lazy - // Clear - cmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelineManager->GetClearPipeline()); - quadBuffer->Bind(cmdBuffer); - quadBuffer->Draw(cmdBuffer); - - vk::MemoryBarrier memoryBarrier(vk::AccessFlagBits::eShaderWrite, vk::AccessFlagBits::eShaderRead); - cmdBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader, vk::PipelineStageFlagBits::eFragmentShader, - vk::DependencyFlagBits::eByRegion, memoryBarrier, nullptr, nullptr); - firstFrameAfterInit = false; - } // Tr modifier volumes if (GetContext()->GetVendorID() != VulkanContext::VENDOR_QUALCOMM) // Adreno bug { diff --git a/core/rend/vulkan/oit/oit_pipeline.cpp b/core/rend/vulkan/oit/oit_pipeline.cpp index 6c5a6e106f..cb0ecd2cc5 100644 --- a/core/rend/vulkan/oit/oit_pipeline.cpp +++ b/core/rend/vulkan/oit/oit_pipeline.cpp @@ -336,7 +336,7 @@ void OITPipelineManager::CreateClearPipeline() &pipelineDynamicStateCreateInfo, // pDynamicState *pipelineLayout, // layout renderPasses->GetRenderPass(true, true), // renderPass - 2 // subpass + 1 // subpass ); clearPipeline = GetContext()->GetDevice().createGraphicsPipelineUnique(GetContext()->GetPipelineCache(), graphicsPipelineCreateInfo).value; diff --git a/core/rend/vulkan/oit/oit_renderpass.cpp b/core/rend/vulkan/oit/oit_renderpass.cpp index 2619f90cd6..484ace4ff8 100644 --- a/core/rend/vulkan/oit/oit_renderpass.cpp +++ b/core/rend/vulkan/oit/oit_renderpass.cpp @@ -89,6 +89,10 @@ vk::UniqueRenderPass RenderPasses::MakeRenderPass(bool initial, bool last, bool vk::AccessFlagBits::eInputAttachmentRead | vk::AccessFlagBits::eShaderRead, vk::AccessFlagBits::eDepthStencilAttachmentRead | vk::AccessFlagBits::eDepthStencilAttachmentWrite, vk::DependencyFlagBits::eByRegion); + dependencies.emplace_back(1, 1, vk::PipelineStageFlagBits::eFragmentShader, vk::PipelineStageFlagBits::eFragmentShader, + vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite, + vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite, + vk::DependencyFlagBits::eByRegion); dependencies.emplace_back(2, 2, vk::PipelineStageFlagBits::eFragmentShader, vk::PipelineStageFlagBits::eFragmentShader, vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite, vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eShaderWrite,