Skip to content

F1 2017 creates invalid sRGB images #504

@gfxstrand

Description

@gfxstrand

F1 2017 running through DXVK creates an image with VK_IMAGE_USAGE_STORAGE_BIT set and then creates a view of that image with a format of VK_FORMAT_R8G8B8A8_SRGB. This is illegal according to the Vulkan spec:

If image was created with VK_IMAGE_TILING_OPTIMAL, and format is not VK_FORMAT_UNDEFINED, and usage contains VK_IMAGE_USAGE_STORAGE_BIT, format must be supported for storage images, as specified by the VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT flag in VkFormatProperties::optimalTilingFeatures returned by vkGetPhysicalDeviceFormatProperties with the same value of format.

What F1 and DXVK are trying to do is sensible and that's why we added support for this with VK_KHR_maintenance2. What you need to do is the following:

  1. Create the image with VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR and all of the possible usages of the image even if they aren't supported by the format.
  2. Chain a VkImageViewUsageCreateInfoKHR struct into VkImageViewCreateInfo and provide a view-specific usage whenever you create an image view. For a UAV, for instance, it would just be VK_IMAGE_USAGE_STORAGE_BIT.

This should also slightly improve memory usage on Intel because we create different hardware surface states for storage vs. texture so right now the texture surface state is unnecessarily being created for UAVs and the storage surface state is unnecessarily being created for sampler views.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions