From: Mikko Rasa Date: Thu, 6 Oct 2022 10:15:57 +0000 (+0300) Subject: Synchronize sampled images in addition to storage images X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4369f481b06d28056deceecbfcb69550a65c92dc;p=libs%2Fgl.git Synchronize sampled images in addition to storage images The same image may alternate between sampled and storage for successive compute dispatches, and different layouts are needed for each usage. --- diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index 5d1139b8..d8e4d4a1 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -460,8 +460,13 @@ void VulkanPipelineState::synchronize_resources() const const PipelineState &self = *static_cast(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