Skip to content

Commit

Permalink
vk oit: draw transparent polys in the first frame after (re)init
Browse files Browse the repository at this point in the history
Fixes missing background in progress window in Fighting Force 2
Issue flyinghead#1652
  • Loading branch information
flyinghead committed Sep 29, 2024
1 parent 2653c5e commit 2dd4cbe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
29 changes: 13 additions & 16 deletions core/rend/vulkan/oit/oit_drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion core/rend/vulkan/oit/oit_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions core/rend/vulkan/oit/oit_renderpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2dd4cbe

Please sign in to comment.