From: Mikko Rasa Date: Thu, 9 Dec 2021 13:23:21 +0000 (+0200) Subject: Don't remove individual mipmap levels from Synchronizer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d011ee2084d610c711ab7ed82e1f7a2337f6cba2;p=libs%2Fgl.git Don't remove individual mipmap levels from Synchronizer Keep them around until all levels have been transitioned to shader read only optimal, to ensure that changing the layout of a split image as a whole works correctly. --- diff --git a/source/backends/vulkan/synchronizer.cpp b/source/backends/vulkan/synchronizer.cpp index 3ec04026..93f48b84 100644 --- a/source/backends/vulkan/synchronizer.cpp +++ b/source/backends/vulkan/synchronizer.cpp @@ -212,29 +212,28 @@ void Synchronizer::barrier(VkCommandBuffer command_buffer) } } - bool sparse_levels = false; for(auto i=image_accesses.begin(); i!=image_accesses.end(); ) { - if(i->level==-2) - { - sparse_levels = true; - ++i; - } - else if(i->pending_layout==VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) + if(i->level!=-1) { - VkImage image = i->image; - i = image_accesses.erase(i); - if(i->image!=image) + auto j = i; + if(j->level==-2) + ++j; + + bool remove_image = true; + for(; (j!=image_accesses.end() && j->image==i->image); ++j) + remove_image &= (j->pending_layout==VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + + if(remove_image) + i = image_accesses.erase(i, j); + else { - if(sparse_levels) - { - auto j = prev(i); - if(j->level==-2) - i = image_accesses.erase(j); - } - sparse_levels = false; + for(; i!=j; ++i) + i->current_layout = i->pending_layout; } } + else if(i->pending_layout==VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) + i = image_accesses.erase(i); else { i->current_layout = i->pending_layout;