From bf8d3a044f3bab251394e6d83ca102508fae4dc5 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 23 Sep 2022 23:04:53 +1000 Subject: [PATCH] GS/Vulkan: Fix redundant constant buffer reuploads Also the redundant descriptor set binds. --- pcsx2/GS/Renderers/DX12/GSDevice12.cpp | 2 +- pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 4bad6e4adb..8579de944a 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -2180,7 +2180,7 @@ bool GSDevice12::ApplyTFXState(bool already_execed) return true; u32 flags = m_dirty_flags; - m_dirty_flags &= ~DIRTY_TFX_STATE | DIRTY_CONSTANT_BUFFER_STATE; + m_dirty_flags &= ~(DIRTY_TFX_STATE | DIRTY_CONSTANT_BUFFER_STATE); // do cbuffer first, because it's the most likely to cause an exec if (flags & DIRTY_FLAG_VS_CONSTANT_BUFFER) diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index 987e45f436..ddcad27440 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -2527,7 +2527,7 @@ bool GSDeviceVK::ApplyTFXState(bool already_execed) const VkDevice dev = g_vulkan_context->GetDevice(); const VkCommandBuffer cmdbuf = g_vulkan_context->GetCurrentCommandBuffer(); u32 flags = m_dirty_flags; - m_dirty_flags &= ~DIRTY_TFX_STATE | DIRTY_CONSTANT_BUFFER_STATE; + m_dirty_flags &= ~(DIRTY_TFX_STATE | DIRTY_CONSTANT_BUFFER_STATE | DIRTY_FLAG_TFX_DYNAMIC_OFFSETS); // do cbuffer first, because it's the most likely to cause an exec if (flags & DIRTY_FLAG_VS_CONSTANT_BUFFER) @@ -2548,6 +2548,7 @@ bool GSDeviceVK::ApplyTFXState(bool already_execed) std::memcpy(m_vertex_uniform_stream_buffer.GetCurrentHostPointer(), &m_vs_cb_cache, sizeof(m_vs_cb_cache)); m_tfx_dynamic_offsets[0] = m_vertex_uniform_stream_buffer.GetCurrentOffset(); m_vertex_uniform_stream_buffer.CommitMemory(sizeof(m_vs_cb_cache)); + flags |= DIRTY_FLAG_TFX_DYNAMIC_OFFSETS; } if (flags & DIRTY_FLAG_PS_CONSTANT_BUFFER) @@ -2568,6 +2569,7 @@ bool GSDeviceVK::ApplyTFXState(bool already_execed) std::memcpy(m_fragment_uniform_stream_buffer.GetCurrentHostPointer(), &m_ps_cb_cache, sizeof(m_ps_cb_cache)); m_tfx_dynamic_offsets[1] = m_fragment_uniform_stream_buffer.GetCurrentOffset(); m_fragment_uniform_stream_buffer.CommitMemory(sizeof(m_ps_cb_cache)); + flags |= DIRTY_FLAG_TFX_DYNAMIC_OFFSETS; } Vulkan::DescriptorSetUpdateBuilder dsub;