From df2e07ad29284bac890428a7020ff063e160f910 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 16 Nov 2022 19:12:05 +0100 Subject: [PATCH] VideoBackends:Vulkan: Fix incorrect barriers in StagingBuffer HOST barriers need to be issued regardless of whether the memory type is coherent and we need to properly synchronize writes to the buffer. --- .../VideoBackends/Vulkan/StagingBuffer.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/Source/Core/VideoBackends/Vulkan/StagingBuffer.cpp b/Source/Core/VideoBackends/Vulkan/StagingBuffer.cpp index 19ca7dc8dd..c053ced700 100644 --- a/Source/Core/VideoBackends/Vulkan/StagingBuffer.cpp +++ b/Source/Core/VideoBackends/Vulkan/StagingBuffer.cpp @@ -73,11 +73,6 @@ void StagingBuffer::InvalidateGPUCache(VkCommandBuffer command_buffer, VkPipelineStageFlagBits dest_pipeline_stage, VkDeviceSize offset, VkDeviceSize size) { - VkMemoryPropertyFlags flags = 0; - vmaGetAllocationMemoryProperties(g_vulkan_context->GetMemoryAllocator(), m_alloc, &flags); - if (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) [[likely]] - return; - ASSERT((offset + size) <= m_size || (offset < m_size && size == VK_WHOLE_SIZE)); BufferMemoryBarrier(command_buffer, m_buffer, VK_ACCESS_HOST_WRITE_BIT, dest_access_flags, offset, size, VK_PIPELINE_STAGE_HOST_BIT, dest_pipeline_stage); @@ -88,25 +83,15 @@ void StagingBuffer::PrepareForGPUWrite(VkCommandBuffer command_buffer, VkPipelineStageFlagBits dst_pipeline_stage, VkDeviceSize offset, VkDeviceSize size) { - VkMemoryPropertyFlags flags = 0; - vmaGetAllocationMemoryProperties(g_vulkan_context->GetMemoryAllocator(), m_alloc, &flags); - if (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) [[likely]] - return; - ASSERT((offset + size) <= m_size || (offset < m_size && size == VK_WHOLE_SIZE)); - BufferMemoryBarrier(command_buffer, m_buffer, 0, dst_access_flags, offset, size, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, dst_pipeline_stage); + BufferMemoryBarrier(command_buffer, m_buffer, VK_ACCESS_MEMORY_WRITE_BIT, dst_access_flags, + offset, size, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, dst_pipeline_stage); } void StagingBuffer::FlushGPUCache(VkCommandBuffer command_buffer, VkAccessFlagBits src_access_flags, VkPipelineStageFlagBits src_pipeline_stage, VkDeviceSize offset, VkDeviceSize size) { - VkMemoryPropertyFlags flags = 0; - vmaGetAllocationMemoryProperties(g_vulkan_context->GetMemoryAllocator(), m_alloc, &flags); - if (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) [[likely]] - return; - ASSERT((offset + size) <= m_size || (offset < m_size && size == VK_WHOLE_SIZE)); BufferMemoryBarrier(command_buffer, m_buffer, src_access_flags, VK_ACCESS_HOST_READ_BIT, offset, size, src_pipeline_stage, VK_PIPELINE_STAGE_HOST_BIT);