From 4369f481b06d28056deceecbfcb69550a65c92dc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 6 Oct 2022 13:15:57 +0300 Subject: [PATCH] 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. --- source/backends/vulkan/pipelinestate_backend.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.43.0