]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/texture2d_backend.cpp
Use another callback for pre-transfer synchronization
[libs/gl.git] / source / backends / vulkan / texture2d_backend.cpp
index d3db86d3ae27efe214ec2acd6586e96350ad4599..e568d14f75843ea7ae57e6a6bbb520a777ed5712 100644 (file)
@@ -28,10 +28,14 @@ void VulkanTexture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsig
        const Texture2D &self = *static_cast<const Texture2D *>(this);
 
        auto level_size = self.get_level_size(level);
-       change_layout(self.levels, level, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (x==0 && y==0 && wd==level_size.x && ht==level_size.y));
+       bool discard = (x==0 && y==0 && wd==level_size.x && ht==level_size.y);
 
        size_t data_size = wd*ht*get_pixel_size(storage_fmt);
        void *staging = device.get_transfer_queue().prepare_transfer(data_size,
+               [this, level, discard](){
+                       unsigned n_levels = static_cast<const Texture2D *>(this)->levels;
+                       change_layout(n_levels, level, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, discard);
+               },
                [this, level, x, y, wd, ht](VkCommandBuffer cmd_buf, VkBuffer staging_buf, size_t src_off){
                        const VulkanFunctions &vk = device.get_functions();