dzn: Take VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT into account
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 30 Jun 2022 13:55:23 +0000 (06:55 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Jul 2022 06:15:46 +0000 (06:15 +0000)
Use a typeless format when VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is
set, so we can cast to compatible types at least. Still doesn't
work when formats are of the same size but from incompatible
types (like R32_FLOAT and RGBA8_UNORM), which Vulkan considers
as compatible while D3D12 doesn't, but it gets us closer to what
the Vulkan API wants.

D3D12_FEATURE_DATA_D3D12_OPTIONS12::RelaxedFormatCastingSupported
should address the remaining limitations.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17368>

src/microsoft/vulkan/dzn_image.c

index 16d6f78..5bbef22 100644 (file)
@@ -169,6 +169,9 @@ dzn_image_create(struct dzn_device *device,
       image->desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
    }
 
+   if (image->vk.create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)
+      image->desc.Format = dzn_get_typeless_dxgi_format(image->desc.Format);
+
    if (image->desc.SampleDesc.Count > 1)
       image->desc.Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
    else