From d5ed4df2547a56c9bf3526e49c0b08f8e1d70f69 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Thu, 12 Dec 2024 21:02:33 +0100 Subject: [PATCH] tests/shader_runner: Add a "mesa<23.3" tag. --- tests/d3d12_crosstest.h | 41 ++++++++++++++++----------------- tests/shader_runner.c | 2 +- tests/shader_runner.h | 2 +- tests/shader_runner_d3d12.c | 12 +++++++--- tests/shader_runner_vulkan.c | 14 +++++++++--- tests/vulkan_utils.h | 44 +++++++++++++++++++++++++++++++++++- 6 files changed, 85 insertions(+), 30 deletions(-) diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index e82bb06a..95ce9d23 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -480,6 +480,11 @@ static inline bool is_mesa_device(ID3D12Device *device) return false; } +static inline bool is_mesa_device_lt(ID3D12Device *device, uint32_t major, uint32_t minor, uint32_t patch) +{ + return false; +} + static inline bool is_mesa_intel_device(ID3D12Device *device) { return false; @@ -531,10 +536,12 @@ static inline bool is_depth_clip_enable_supported(ID3D12Device *device) #define VKD3D_AGILITY_SDK_EXPORTS +#include "vulkan_utils.h" #define DECLARE_VK_PFN(name) static PFN_##name name; DECLARE_VK_PFN(vkGetInstanceProcAddr) #define VK_INSTANCE_PFN DECLARE_VK_PFN #include "vulkan_procs.h" +#undef DECLARE_VK_PFN static bool check_device_extension(VkPhysicalDevice vk_physical_device, const char *name) { @@ -750,9 +757,17 @@ static inline bool is_mesa_device(ID3D12Device *device) VkPhysicalDeviceDriverPropertiesKHR properties; get_driver_properties(device, NULL, &properties); - return properties.driverID == VK_DRIVER_ID_MESA_RADV_KHR - || properties.driverID == VK_DRIVER_ID_MESA_LLVMPIPE - || properties.driverID == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR; + return is_mesa_vulkan_driver(&properties); +} + +static inline bool is_mesa_device_lt(ID3D12Device *device, uint32_t major, uint32_t minor, uint32_t patch) +{ + VkPhysicalDeviceDriverPropertiesKHR driver_properties; + VkPhysicalDeviceProperties device_properties; + + get_driver_properties(device, &device_properties, &driver_properties); + return is_mesa_vulkan_driver(&driver_properties) + && !is_vulkan_driver_version_ge(&device_properties, &driver_properties, major, minor, patch); } static inline bool is_mesa_intel_device(ID3D12Device *device) @@ -778,24 +793,8 @@ static inline bool is_llvmpipe_device_gte(ID3D12Device *device, VkPhysicalDeviceProperties device_properties; get_driver_properties(device, &device_properties, &driver_properties); - if (driver_properties.driverID != VK_DRIVER_ID_MESA_LLVMPIPE) - return false; - - if (device_properties.driverVersion == 1) - { - uint32_t driver_major, driver_minor, driver_patch; - - /* llvmpipe doesn't provide a valid driverVersion value, so we resort to parsing the - * driverInfo string. */ - if (sscanf(driver_properties.driverInfo, "Mesa %u.%u.%u", - &driver_major, &driver_minor, &driver_patch) == 3) - { - device_properties.driverVersion = VK_MAKE_API_VERSION(0, - driver_major, driver_minor, driver_patch); - } - } - - return device_properties.driverVersion >= VK_MAKE_API_VERSION(0, major, minor, patch); + return driver_properties.driverID == VK_DRIVER_ID_MESA_LLVMPIPE + && is_vulkan_driver_version_ge(&device_properties, &driver_properties, major, minor, patch); } static inline bool is_nvidia_device(ID3D12Device *device) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 8bbbdfab..92e0f4f7 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -143,7 +143,7 @@ static bool match_tag(struct shader_runner *runner, const char *tag) static bool check_qualifier_args_conjunction(struct shader_runner *runner, const char *line, const char **const rest, uint32_t *model_mask) { - static const char *const valid_tags[] = {"d3d12", "glsl", "llvmpipe", "msl", "mvk", "vulkan"}; + static const char *const valid_tags[] = {"d3d12", "glsl", "llvmpipe", "msl", "mvk", "vulkan", "mesa<23.3"}; bool holds = true; *model_mask = ~0u; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index f64bc8c0..786b2a5c 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -155,7 +155,7 @@ enum shader_cap struct shader_runner_caps { const char *runner; - const char *tags[2]; + const char *tags[3]; size_t tag_count; enum shader_model minimum_shader_model; enum shader_model maximum_shader_model; diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 15188801..f4f685bd 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -1037,11 +1037,17 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner, runner->caps.tag_count = 0; runner->caps.tags[runner->caps.tag_count++] = "d3d12"; - if (is_mvk_device(device)) + { runner->caps.tags[runner->caps.tag_count++] = "mvk"; - else if (is_llvmpipe_device(device)) - runner->caps.tags[runner->caps.tag_count++] = "llvmpipe"; + } + else + { + if (is_llvmpipe_device(device)) + runner->caps.tags[runner->caps.tag_count++] = "llvmpipe"; + if (is_mesa_device_lt(device, 23, 3, 0)) + runner->caps.tags[runner->caps.tag_count++] = "mesa<23.3"; + } for (unsigned int i = 0; i < ARRAY_SIZE(formats); ++i) { diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 28391ba1..3d525025 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -1720,11 +1720,19 @@ static bool init_vulkan_runner(struct vulkan_shader_runner *runner) runner->caps.tag_count = 0; runner->caps.tags[runner->caps.tag_count++] = "vulkan"; - if (device_info.driver_properties.driverID == VK_DRIVER_ID_MOLTENVK) + { runner->caps.tags[runner->caps.tag_count++] = "mvk"; - else if (device_info.driver_properties.driverID == VK_DRIVER_ID_MESA_LLVMPIPE) - runner->caps.tags[runner->caps.tag_count++] = "llvmpipe"; + } + else + { + if (device_info.driver_properties.driverID == VK_DRIVER_ID_MESA_LLVMPIPE) + runner->caps.tags[runner->caps.tag_count++] = "llvmpipe"; + if (is_mesa_vulkan_driver(&device_info.driver_properties) + && !is_vulkan_driver_version_ge(&device_info.properties2.properties, + &device_info.driver_properties, 23, 3, 0)) + runner->caps.tags[runner->caps.tag_count++] = "mesa<23.3"; + } runner->caps.shader_caps[SHADER_CAP_CLIP_PLANES] = true; runner->caps.shader_caps[SHADER_CAP_FOG] = true; diff --git a/tests/vulkan_utils.h b/tests/vulkan_utils.h index 5f55625b..4f45bc20 100644 --- a/tests/vulkan_utils.h +++ b/tests/vulkan_utils.h @@ -49,6 +49,8 @@ struct vulkan_test_context #include "vulkan_procs.h" }; +#undef DECLARE_VK_PFN + #define VK_CALL(f) (context->f) static inline void begin_command_buffer(const struct vulkan_test_context *context) @@ -265,7 +267,7 @@ static inline bool vulkan_test_context_init_instance(struct vulkan_test_context { VkInstanceCreateInfo instance_desc = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO}; struct vulkan_extension_list enabled_extensions; - DECLARE_VK_PFN(vkGetInstanceProcAddr) + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; void *libvulkan; uint32_t count; VkResult vr; @@ -417,4 +419,44 @@ static inline void vulkan_test_context_destroy(const struct vulkan_test_context VK_CALL(vkDestroyInstance(context->instance, NULL)); } +/* This doesn't work for NVIDIA, because they use a different bit pattern. */ +static inline bool is_vulkan_driver_version_ge(const VkPhysicalDeviceProperties *device_properties, + const VkPhysicalDeviceDriverPropertiesKHR *driver_properties, + uint32_t major, uint32_t minor, uint32_t patch) +{ + uint32_t version = device_properties->driverVersion; + + if (version == 1) + { + uint32_t driver_major, driver_minor, driver_patch; + + /* llvmpipe doesn't provide a valid driverVersion value, so we resort to + * parsing the driverInfo string. */ + if (sscanf(driver_properties->driverInfo, "Mesa %u.%u.%u", + &driver_major, &driver_minor, &driver_patch) == 3) + version = VK_MAKE_API_VERSION(0, driver_major, driver_minor, driver_patch); + } + + return version >= VK_MAKE_API_VERSION(0, major, minor, patch); +} + +static inline bool is_mesa_vulkan_driver(const VkPhysicalDeviceDriverPropertiesKHR *properties) +{ + switch (properties->driverID) + { + case VK_DRIVER_ID_MESA_RADV_KHR: + case VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA: + case VK_DRIVER_ID_MESA_LLVMPIPE: + case VK_DRIVER_ID_MESA_TURNIP: + case VK_DRIVER_ID_MESA_V3DV: + case VK_DRIVER_ID_MESA_PANVK: + case VK_DRIVER_ID_MESA_VENUS: + case VK_DRIVER_ID_MESA_DOZEN: + return true; + + default: + return false; + } +} + #endif /* __VKD3D_VULKAN_UTILS_H */