From 4d752ad123bca223a61be3afcc5ee9738c67df72 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Sat, 24 May 2025 20:26:31 -0400 Subject: [PATCH] nvk: Disable R64_[US]INT formats when shaderImageInt64Atomics isn't supported Part-of: --- src/nouveau/vulkan/nvk_buffer_view.c | 4 ++-- src/nouveau/vulkan/nvk_format.c | 20 ++++++++++++++++++-- src/nouveau/vulkan/nvk_format.h | 6 +++++- src/nouveau/vulkan/nvk_image.c | 4 ++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/nouveau/vulkan/nvk_buffer_view.c b/src/nouveau/vulkan/nvk_buffer_view.c index 6c625a39e88..fcd8e79ce59 100644 --- a/src/nouveau/vulkan/nvk_buffer_view.c +++ b/src/nouveau/vulkan/nvk_buffer_view.c @@ -28,14 +28,14 @@ nvk_get_buffer_format_features(const struct nvk_physical_device *pdev, if (nil_format_supports_buffer(&pdev->info, p_format)) { features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT; - if (nil_format_supports_storage(&pdev->info, p_format)) { + if (nvk_format_supports_storage(pdev, p_format)) { features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT | VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT; if (pdev->info.cls_eng3d >= MAXWELL_A) features |= VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT; } - if (nvk_format_supports_atomics(&pdev->info, p_format)) + if (nvk_format_supports_atomics(pdev, p_format)) features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; } diff --git a/src/nouveau/vulkan/nvk_format.c b/src/nouveau/vulkan/nvk_format.c index 5f8aa9958b9..6aecfe39939 100644 --- a/src/nouveau/vulkan/nvk_format.c +++ b/src/nouveau/vulkan/nvk_format.c @@ -18,20 +18,36 @@ #include "cl90c0.h" bool -nvk_format_supports_atomics(const struct nv_device_info *dev, +nvk_format_supports_atomics(const struct nvk_physical_device *pdev, enum pipe_format p_format) { switch (p_format) { case PIPE_FORMAT_R32_UINT: case PIPE_FORMAT_R32_SINT: + return true; case PIPE_FORMAT_R64_UINT: case PIPE_FORMAT_R64_SINT: - return true; + return pdev->vk.supported_features.shaderImageInt64Atomics; default: return false; } } +bool +nvk_format_supports_storage(const struct nvk_physical_device *pdev, + enum pipe_format p_format) +{ + /* Unfortunately, the SPIR-V cap associated with 64-bit storage images (and + * formatted buffers) is gated by the atomics feature so if we have to + * disable the formats when the Vulkan feature isn't exposed. + */ + if (!pdev->vk.supported_features.shaderImageInt64Atomics && + util_format_get_max_channel_size(p_format) == 64) + return false; + + return nil_format_supports_storage(&pdev->info, p_format); +} + #define VA_FMT(vk_fmt, widths, swap_rb, type) \ [VK_FORMAT_##vk_fmt] = \ { NV9097_SET_VERTEX_ATTRIBUTE_A_COMPONENT_BIT_WIDTHS_##widths, \ diff --git a/src/nouveau/vulkan/nvk_format.h b/src/nouveau/vulkan/nvk_format.h index 43846cbde8b..c5a6ceccb4e 100644 --- a/src/nouveau/vulkan/nvk_format.h +++ b/src/nouveau/vulkan/nvk_format.h @@ -20,7 +20,11 @@ struct nvk_va_format { }; bool -nvk_format_supports_atomics(const struct nv_device_info *dev, +nvk_format_supports_atomics(const struct nvk_physical_device *pdev, + enum pipe_format p_format); + +bool +nvk_format_supports_storage(const struct nvk_physical_device *pdev, enum pipe_format p_format); const struct nvk_va_format * diff --git a/src/nouveau/vulkan/nvk_image.c b/src/nouveau/vulkan/nvk_image.c index 70f89dd9e24..62ac4d0a3a1 100644 --- a/src/nouveau/vulkan/nvk_image.c +++ b/src/nouveau/vulkan/nvk_image.c @@ -76,14 +76,14 @@ nvk_get_image_plane_format_features(const struct nvk_physical_device *pdev, features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; } - if (nil_format_supports_storage(&pdev->info, p_format)) { + if (nvk_format_supports_storage(pdev, p_format)) { features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT | VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT; if (pdev->info.cls_eng3d >= MAXWELL_A) features |= VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT; } - if (nvk_format_supports_atomics(&pdev->info, p_format)) + if (nvk_format_supports_atomics(pdev, p_format)) features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT; if (p_format == PIPE_FORMAT_R8_UINT && tiling == VK_IMAGE_TILING_OPTIMAL)