]> git.tdb.fi Git - libs/gl.git/commitdiff
Synchronize sampled images in addition to storage images
authorMikko Rasa <tdb@tdb.fi>
Thu, 6 Oct 2022 10:15:57 +0000 (13:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 6 Oct 2022 10:15:57 +0000 (13:15 +0300)
The same image may alternate between sampled and storage for successive
compute dispatches, and different layouts are needed for each usage.

source/backends/vulkan/pipelinestate_backend.cpp

index 5d1139b8762ad8bee543f6aebe2039fce890282a..d8e4d4a1978504373e5614aad6e59555d358e955 100644 (file)
@@ -460,8 +460,13 @@ void VulkanPipelineState::synchronize_resources() const
        const PipelineState &self = *static_cast<const PipelineState *>(this);
 
        for(const PipelineState::BoundResource &r: self.resources)
-               if(r.type==PipelineState::STORAGE_TEXTURE)
-                       r.texture->change_layout(-1, VK_IMAGE_LAYOUT_GENERAL, false);
+               if(r.used)
+               {
+                       if(r.type==PipelineState::STORAGE_TEXTURE)
+                               r.texture->change_layout(-1, VK_IMAGE_LAYOUT_GENERAL, false);
+                       else if(r.type==PipelineState::SAMPLED_TEXTURE)
+                               r.texture->change_layout(-1, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, false);
+               }
 }
 
 void VulkanPipelineState::apply(const VulkanCommandRecorder &vkCmd, const VulkanPipelineState *last, unsigned frame, bool negative_viewport) const