From d3337cbd2ec9fd06682c2cd9f52ff9f014f5f9db Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 30 Nov 2021 23:24:04 +0200 Subject: [PATCH] Don't create no-op barriers --- source/backends/vulkan/synchronizer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/backends/vulkan/synchronizer.cpp b/source/backends/vulkan/synchronizer.cpp index 7ce7c08a..c2c245a5 100644 --- a/source/backends/vulkan/synchronizer.cpp +++ b/source/backends/vulkan/synchronizer.cpp @@ -80,6 +80,9 @@ void Synchronizer::barrier(VkCommandBuffer command_buffer) buffer_barriers.reserve(buffer_accesses.size()); for(BufferAccess &b: buffer_accesses) { + if(b.pending_write==b.was_written) + continue; + buffer_barriers.emplace_back(VkBufferMemoryBarrier{ }); VkBufferMemoryBarrier &barrier = buffer_barriers.back(); @@ -105,6 +108,9 @@ void Synchronizer::barrier(VkCommandBuffer command_buffer) image_barriers.reserve(image_accesses.size()); for(const ImageAccess &i: image_accesses) { + if(i.pending_layout==i.current_layout) + continue; + image_barriers.emplace_back(VkImageMemoryBarrier{ }); VkImageMemoryBarrier &barrier = image_barriers.back(); @@ -135,6 +141,9 @@ void Synchronizer::barrier(VkCommandBuffer command_buffer) dst_stage |= (is_write_layout(i.pending_layout) ? image_write_stages : image_read_stages); } + if(buffer_barriers.empty() && image_barriers.empty()) + return; + if(!src_stage) src_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; if(!dst_stage) -- 2.45.2