Skip to content

Commit

Permalink
Vulkan: Experimental fix for self-dependency barriers during renderpa…
Browse files Browse the repository at this point in the history
…ss (#431)
  • Loading branch information
goeiecool9999 authored Nov 2, 2022
1 parent d4e14d2 commit a129d22
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,30 +1196,15 @@ void VulkanRenderer::draw_setRenderPass()
// update self-dependency flag
if (m_state.descriptorSetsChanged || m_state.activeRenderpassFBO != fboVk)
{
bool hadDep = m_state.hasRenderSelfDependency;
m_state.hasRenderSelfDependency = fboVk->CheckForCollision(m_state.activeVertexDS, m_state.activeGeometryDS, m_state.activePixelDS);
}

auto vkObjRenderPass = fboVk->GetRenderPassObj();
auto vkObjFramebuffer = fboVk->GetFramebufferObj();

if (m_state.hasRenderSelfDependency)
{
bool triggerBarrier = GetConfig().vk_accurate_barriers || m_state.activePipelineInfo->neverSkipAccurateBarrier;
if (triggerBarrier)
{
VkMemoryBarrier memoryBarrier{};
memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
memoryBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
memoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStage, dstStage, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr);
performanceMonitor.vk.numDrawBarriersPerFrame.increment();
}
}
bool overridePassReuse = m_state.hasRenderSelfDependency && (GetConfig().vk_accurate_barriers || m_state.activePipelineInfo->neverSkipAccurateBarrier);

if (m_state.activeRenderpassFBO == fboVk)
if (!overridePassReuse && m_state.activeRenderpassFBO == fboVk)
{
if (m_state.descriptorSetsChanged)
sync_inputTexturesChanged();
Expand Down

0 comments on commit a129d22

Please sign in to comment.