X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Ftexture_backend.cpp;h=1367cc8d46c2a87a24eddb892b93b0d7cb142817;hb=2a70fecfbbe8708be2bdaa75d222dd5a889a8ed3;hp=bf2692172c922295c835012ccc0637ab2d909aa8;hpb=50492d9a5106b3dd76e3d6fa5ac88d9f97ba3c47;p=libs%2Fgl.git diff --git a/source/backends/vulkan/texture_backend.cpp b/source/backends/vulkan/texture_backend.cpp index bf269217..1367cc8d 100644 --- a/source/backends/vulkan/texture_backend.cpp +++ b/source/backends/vulkan/texture_backend.cpp @@ -49,9 +49,13 @@ void VulkanTexture::allocate() const Texture &self = *static_cast(this); const VulkanFunctions &vk = device.get_functions(); + VkFormat vk_format = static_cast(get_vulkan_pixelformat(self.storage_fmt)); + VkFormatProperties props; + vk.GetPhysicalDeviceFormatProperties(vk_format, props); + VkImageCreateInfo image_info = { }; image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - image_info.format = static_cast(get_vulkan_pixelformat(self.storage_fmt)); + image_info.format = vk_format; image_info.extent.width = 1; image_info.extent.height = 1; image_info.extent.depth = 1; @@ -63,6 +67,9 @@ void VulkanTexture::allocate() image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; image_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT; + if(props.optimalTilingFeatures&VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) + image_info.usage |= VK_IMAGE_USAGE_STORAGE_BIT; + PixelComponents comp = get_components(self.storage_fmt); if(comp==DEPTH_COMPONENT || comp==STENCIL_INDEX) image_info.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; @@ -146,9 +153,8 @@ void VulkanTexture::generate_mipmap() 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){ + [this, i](const VulkanCommandRecorder &vkCmd, VkBuffer, size_t){ const Texture &self = *static_cast(this); - const VulkanFunctions &vk = device.get_functions(); VkImageBlit region = { }; region.srcSubresource.aspectMask = get_vulkan_aspect(get_components(self.storage_fmt)); @@ -160,7 +166,7 @@ void VulkanTexture::generate_mipmap() fill_mipmap_blit(i, ®ion); - vk.CmdBlitImage(cmd_buf, handle, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, handle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + vkCmd.BlitImage(handle, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, handle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion, VK_FILTER_LINEAR); }); }