]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/texture1d_backend.cpp
Store the number of mipmap levels in the Texture base class
[libs/gl.git] / source / backends / vulkan / texture1d_backend.cpp
index d66732bf6b7c62056058b38abf7cfa6e9d01e74d..d74164842960f8189b3398f34a428e6e07624c46 100644 (file)
@@ -19,7 +19,6 @@ void VulkanTexture1D::fill_image_info(void *ii) const
        VkImageCreateInfo *image_info = static_cast<VkImageCreateInfo *>(ii);
        image_info->imageType = VK_IMAGE_TYPE_1D;
        image_info->extent.width = self.width;
-       image_info->mipLevels = self.levels;
 }
 
 void VulkanTexture1D::sub_image(unsigned level, int x, unsigned wd, const void *data)
@@ -32,15 +31,14 @@ void VulkanTexture1D::sub_image(unsigned level, int x, unsigned wd, const void *
        size_t data_size = wd*get_pixel_size(storage_fmt);
        void *staging = device.get_transfer_queue().prepare_transfer(this, false, data_size,
                [this, level, discard](){
-                       unsigned n_levels = static_cast<const Texture1D *>(this)->levels;
-                       change_layout(n_levels, level, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, discard);
+                       change_layout(level, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, discard);
                },
                [this, level, x, wd](VkCommandBuffer cmd_buf, VkBuffer staging_buf, size_t src_off){
                        const VulkanFunctions &vk = device.get_functions();
 
                        VkBufferImageCopy region = { };
                        region.bufferOffset = src_off;
-                       region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+                       region.imageSubresource.aspectMask = get_vulkan_aspect(get_components(storage_fmt));
                        region.imageSubresource.mipLevel = level;
                        region.imageSubresource.baseArrayLayer = 0;
                        region.imageSubresource.layerCount = 1;
@@ -49,13 +47,7 @@ void VulkanTexture1D::sub_image(unsigned level, int x, unsigned wd, const void *
                        vk.CmdCopyBufferToImage(cmd_buf, staging_buf, handle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
                });
 
-       const char *src = static_cast<const char *>(data);
-       copy(src, src+data_size, static_cast<char *>(staging));
-}
-
-void VulkanTexture1D::generate_mipmap()
-{
-       generate_mipmap_levels(static_cast<const Texture1D *>(this)->levels);
+       stage_pixels(staging, data, wd);
 }
 
 void VulkanTexture1D::fill_mipmap_blit(unsigned level, void *b)