+ unsigned n_levels = static_cast<const Texture *>(this)->n_levels;
+
+ TransferQueue &tq = device.get_transfer_queue();
+ for(unsigned i=0; i+1<n_levels; ++i)
+ {
+ tq.prepare_transfer(this, true, 0,
+ [this, i](){
+ change_layout(i, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, false);
+ change_layout(i+1, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, true);
+ },
+ [this, i](VkCommandBuffer cmd_buf, VkBuffer, size_t){
+ const VulkanFunctions &vk = device.get_functions();
+
+ VkImageBlit region = { };
+ region.srcSubresource.aspectMask = get_vulkan_aspect(get_components(static_cast<const Texture *>(this)->storage_fmt));
+ region.srcSubresource.mipLevel = i;
+ region.srcSubresource.baseArrayLayer = 0;
+ region.srcSubresource.layerCount = 1;
+ region.dstSubresource = region.srcSubresource;
+ ++region.dstSubresource.mipLevel;
+
+ fill_mipmap_blit(i, ®ion);
+
+ vk.CmdBlitImage(cmd_buf, handle, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, handle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ 1, ®ion, VK_FILTER_LINEAR);
+ });
+ }