From: Mikko Rasa Date: Tue, 30 Nov 2021 21:24:04 +0000 (+0200) Subject: Don't create no-op barriers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d3337cbd2ec9fd06682c2cd9f52ff9f014f5f9db;p=libs%2Fgl.git Don't create no-op barriers --- 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)