]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/texture_backend.cpp
Add support for storage images in Renderer and PipelineState
[libs/gl.git] / source / backends / vulkan / texture_backend.cpp
index 5b73749884892aad06f69589648e4bad16b663aa..1367cc8d46c2a87a24eddb892b93b0d7cb142817 100644 (file)
@@ -49,9 +49,13 @@ void VulkanTexture::allocate()
        const Texture &self = *static_cast<const Texture *>(this);
        const VulkanFunctions &vk = device.get_functions();
 
+       VkFormat vk_format = static_cast<VkFormat>(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<VkFormat>(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;