From f4b01bbfe7dc2d9f2cebebcc6410eff512ed3670 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 16 Jul 2025 19:47:19 -0400 Subject: [PATCH] nvk: Add an nvk_is_conformant() helper The checks are getting more complicated so it's better to have a helper than a simple boolean with a complex expression. Backport-to: 25.2 Part-of: --- src/nouveau/vulkan/nvk_physical_device.c | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 1106296ca96..e0fe019c7bd 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -82,6 +82,20 @@ nvk_get_vk_version(const struct nv_device_info *info) return VK_MAKE_VERSION(1, 4, VK_HEADER_VERSION); } +static bool +nvk_is_conformant(const struct nv_device_info *info) +{ + /* Tegra is not currently supported */ + if (info->type != NV_DEVICE_TYPE_DIS) + return false; + + /* Everything Maxwell through Ada is conformant */ + if (info->cls_eng3d >= MAXWELL_A && info->cls_eng3d <= ADA_A) + return true; + + return false; +} + static void nvk_get_device_extensions(const struct nvk_instance *instance, const struct nv_device_info *info, @@ -709,7 +723,6 @@ nvk_get_device_features(const struct nv_device_info *info, static void nvk_get_device_properties(const struct nvk_instance *instance, const struct nv_device_info *info, - bool conformant, struct vk_properties *properties) { const VkSampleCountFlagBits sample_counts = VK_SAMPLE_COUNT_1_BIT | @@ -885,8 +898,8 @@ nvk_get_device_properties(const struct nvk_instance *instance, .independentResolve = true, .driverID = VK_DRIVER_ID_MESA_NVK, .conformanceVersion = - conformant ? (VkConformanceVersion) { 1, 4, 3, 0 } - : (VkConformanceVersion) { 0, 0, 0, 0 }, + nvk_is_conformant(info) ? (VkConformanceVersion) { 1, 4, 3, 0 } + : (VkConformanceVersion) { 0, 0, 0, 0 }, .denormBehaviorIndependence = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL, .roundingModeIndependence = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL, .shaderSignedZeroInfNanPreserveFloat16 = true, @@ -1318,11 +1331,7 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, goto fail_nvkmd; } - bool conformant = - nvkmd->dev_info.type == NV_DEVICE_TYPE_DIS && - nvkmd->dev_info.cls_eng3d <= ADA_A; - - if (!conformant && + if (!nvk_is_conformant(&nvkmd->dev_info) && !debug_get_bool_option("NVK_I_WANT_A_BROKEN_VULKAN_DRIVER", false)) { #ifdef NDEBUG result = VK_ERROR_INCOMPATIBLE_DRIVER; @@ -1336,7 +1345,7 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, goto fail_nvkmd; } - if (!conformant) + if (!nvk_is_conformant(&nvkmd->dev_info)) vk_warn_non_conformant_implementation("NVK"); struct nvk_physical_device *pdev = @@ -1364,8 +1373,7 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, &supported_features); struct vk_properties properties; - nvk_get_device_properties(instance, &nvkmd->dev_info, conformant, - &properties); + nvk_get_device_properties(instance, &nvkmd->dev_info, &properties); if (nvkmd->drm.render_dev) { properties.drmHasRender = true;