From fffd6e935ce4953c50075829e94a8d0e53ae2ada Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 29 Nov 2021 13:41:38 +0100 Subject: [PATCH] vkd3d: Add R64_UINT to format compatibility list when needed. For 64-bit image atomics, we should at the very least add 64-bit format to compatibility list to avoid potential problems. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/resource.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 7aa854a6..0bd097ca 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -236,6 +236,24 @@ static bool vkd3d_get_format_compatibility_list(const struct d3d12_device *devic for (i = 0; i < ARRAY_SIZE(r32_uav_formats); i++) vkd3d_format_compatibility_list_add_format(&list, r32_uav_formats[i]); } + + /* 64-bit image atomics in D3D12 are done through RG32_UINT instead. + * We don't actually create 64-bit image views correctly at the moment, + * but adding the alias gives a clear signal to driver that we might use atomics on the image, + * which should disable compression or similar. + * If we can create R32G32_UINT views on this resource, we need to add R64_UINT as well as a potential + * mutable format. */ + if (device->device_info.shader_image_atomic_int64_features.shaderImageInt64Atomics) + { + for (i = 0; i < list.format_count; i++) + { + if (list.vk_formats[i] == VK_FORMAT_R32G32_UINT) + { + vkd3d_format_compatibility_list_add_format(&list, VK_FORMAT_R64_UINT); + break; + } + } + } } if (list.format_count < 2)