]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't create no-op barriers
authorMikko Rasa <tdb@tdb.fi>
Tue, 30 Nov 2021 21:24:04 +0000 (23:24 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 30 Nov 2021 21:31:51 +0000 (23:31 +0200)
source/backends/vulkan/synchronizer.cpp

index 7ce7c08a9d99fcc63763f3bb106e37fd9eb34e0f..c2c245a5a094cec43f7a3ec7a45970361ac64a64 100644 (file)
@@ -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)