X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Ftexture2d_backend.cpp;h=518f4c2ea54d552e0d50113f8c75a7f813d6e51c;hb=d2a23243b7f25e56ef098196b2962c103989143f;hp=2d6ee131056b8975512b8a0b82c1e1e66cbb4145;hpb=a16145549dc87c3b12671f797bd77b14bcc7786b;p=libs%2Fgl.git diff --git a/source/backends/vulkan/texture2d_backend.cpp b/source/backends/vulkan/texture2d_backend.cpp index 2d6ee131..518f4c2e 100644 --- a/source/backends/vulkan/texture2d_backend.cpp +++ b/source/backends/vulkan/texture2d_backend.cpp @@ -28,10 +28,14 @@ void VulkanTexture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsig const Texture2D &self = *static_cast(this); auto level_size = self.get_level_size(level); - synchronize(-1, 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, + void *staging = device.get_transfer_queue().prepare_transfer(this, false, data_size, + [this, level, discard](){ + unsigned n_levels = static_cast(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(); @@ -50,6 +54,23 @@ void VulkanTexture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsig copy(src, src+data_size, static_cast(staging)); } +void VulkanTexture2D::generate_mipmap() +{ + generate_mipmap_levels(static_cast(this)->levels); +} + +void VulkanTexture2D::fill_mipmap_blit(unsigned level, void *b) +{ + const Texture2D &self = *static_cast(this); + VkImageBlit &blit = *static_cast(b); + + auto src_size = self.get_level_size(level); + auto dst_size = self.get_level_size(level+1); + + blit.srcOffsets[1] = { static_cast(src_size.x), static_cast(src_size.y), 1 }; + blit.dstOffsets[1] = { static_cast(dst_size.x), static_cast(dst_size.y), 1 }; +} + Resource::AsyncLoader *VulkanTexture2D::load(IO::Seekable &, const Resources *) { throw logic_error("Texture2D::load is unimplemented");