From dff7c0e7b8f425887052384038f44cd9378f5c4b Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sat, 19 Oct 2024 11:13:07 +0200 Subject: [PATCH] tests: Mark interface packing pipeline creation as todo on MoltenVK. Most Vulkan drivers are happy to compile a pipeline with interstage interface mismatches, even if the pipeline will be broken. Metal, and therefore MoltenVK, instead doesn't and errors out immediately. --- tests/hlsl/interface-packing.shader_test | 23 ++++++------ tests/shader_runner.c | 2 + tests/shader_runner_d3d12.c | 19 +++++++++- tests/shader_runner_vulkan.c | 47 +++++++++++++++++++++++- tests/vulkan_procs.h | 2 + 5 files changed, 78 insertions(+), 15 deletions(-) diff --git a/tests/hlsl/interface-packing.shader_test b/tests/hlsl/interface-packing.shader_test index a9df0893..3873a61f 100644 --- a/tests/hlsl/interface-packing.shader_test +++ b/tests/hlsl/interface-packing.shader_test @@ -114,16 +114,17 @@ float4 main(data input) : SV_Target } [test] -draw triangle list 3 -probe (0, 0) rgba ( 0.0, 0.0, 0.0, 0.0) -probe (1, 0) rgba ( 1.0, 12.0, 13.0, 14.0) -probe (2, 0) rgba ( 2.0, 15.0, 16.0, 22.0) -probe (3, 0) rgba ( 3.0, 4.0, 5.0, 26.0) -probe (4, 0) rgba ( 6.0, 17.0, 20.0, 21.0) -probe (5, 0) rgba ( 7.0, 18.0, 19.0, 0.0) -probe (6, 0) rgba (27.0, 28.0, 0.0, 0.0) -probe (7, 0) rgba ( 8.0, 9.0, 10.0, 11.0) -probe (8, 0) rgba (23.0, 24.0, 25.0, 0.0) +clear rtv 0 -1.0 -1.0 -1.0 -1.0 +todo(mvk & vulkan) draw triangle list 3 +todo(mvk) probe (0, 0) rgba ( 0.0, 0.0, 0.0, 0.0) +todo(mvk) probe (1, 0) rgba ( 1.0, 12.0, 13.0, 14.0) +todo(mvk) probe (2, 0) rgba ( 2.0, 15.0, 16.0, 22.0) +todo(mvk) probe (3, 0) rgba ( 3.0, 4.0, 5.0, 26.0) +todo(mvk) probe (4, 0) rgba ( 6.0, 17.0, 20.0, 21.0) +todo(mvk) probe (5, 0) rgba ( 7.0, 18.0, 19.0, 0.0) +todo(mvk) probe (6, 0) rgba (27.0, 28.0, 0.0, 0.0) +todo(mvk) probe (7, 0) rgba ( 8.0, 9.0, 10.0, 11.0) +todo(mvk) probe (8, 0) rgba (23.0, 24.0, 25.0, 0.0) [require] shader model >= 3.0 @@ -157,5 +158,5 @@ float4 main(float4 pos : SV_Position, float4 color : COLOR) : SV_Target } [test] -draw triangle list 3 +todo(mvk & sm<4) draw triangle list 3 todo(sm<4) probe (0, 0) rgba (1.0, 10.0, 11.0, 4.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index ba4838c8..daead930 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -147,6 +147,8 @@ static bool check_qualifier_args_conjunction(struct shader_runner *runner, const {"sm<6", SHADER_MODEL_2_0, SHADER_MODEL_6_0 - 1}, {"glsl", 0, 0, true}, {"d3d12", 0, 0, true}, + {"mvk", 0, 0, true}, + {"vulkan", 0, 0, true}, }; while (*line != ')' && *line != '|') diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 0d26f593..9d50d36f 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -986,6 +986,12 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner, "d3d12", }; + static const char *const mvk_tags[] = + { + "d3d12", + "mvk", + }; + static const enum DXGI_FORMAT formats[] = { DXGI_FORMAT_R32_FLOAT, @@ -1028,8 +1034,17 @@ static void d3d12_runner_init_caps(struct d3d12_shader_runner *runner, runner->caps.rov = options.ROVsSupported; runner->caps.wave_ops = options1.WaveOps; runner->caps.depth_bounds = options2.DepthBoundsTestSupported; - runner->caps.tags = tags; - runner->caps.tag_count = ARRAY_SIZE(tags); + + if (is_mvk_device(device)) + { + runner->caps.tags = mvk_tags; + runner->caps.tag_count = ARRAY_SIZE(mvk_tags); + } + else + { + runner->caps.tags = tags; + runner->caps.tag_count = ARRAY_SIZE(tags); + } 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 0d2fd1b6..257cc383 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -52,6 +52,7 @@ struct vulkan_shader_runner struct shader_runner r; struct shader_runner_caps caps; bool demote_to_helper_invocation; + bool driver_properties; struct vulkan_test_context context; @@ -69,6 +70,8 @@ struct physical_device_info VkPhysicalDeviceFeatures2 features2; VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT interlock_features; VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT demote_to_helper_invocation_features; + VkPhysicalDeviceProperties2 properties2; + VkPhysicalDeviceDriverPropertiesKHR driver_properties; }; static struct vulkan_shader_runner *vulkan_shader_runner(struct shader_runner *r) @@ -641,9 +644,11 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner, ret &= create_shader_stage(runner, &stage_desc[stage_count++], "gs", VK_SHADER_STAGE_GEOMETRY_BIT, runner->r.gs_source, NULL); - todo_if (runner->r.is_todo) ok(ret, "Failed to compile shaders.\n"); if (!ret) { + /* We ok() only when failing here, so that we don't result in a "todo + * succeeded" when the todo applies to pipeline linking. */ + todo_if (runner->r.is_todo) ok(false, "Failed to compile shaders.\n"); for (i = 0; i < ARRAY_SIZE(stage_desc); ++i) VK_CALL(vkDestroyShaderModule(device, stage_desc[i].module, NULL)); return VK_NULL_HANDLE; @@ -768,7 +773,7 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner, } vr = VK_CALL(vkCreateGraphicsPipelines(context->device, VK_NULL_HANDLE, 1, &pipeline_desc, NULL, &pipeline)); - ok(vr == VK_SUCCESS, "Failed to create graphics pipeline, vr %d.\n", vr); + todo_if (runner->r.is_todo) ok(vr == VK_SUCCESS, "Failed to create graphics pipeline, vr %d.\n", vr); for (i = 0; i < ARRAY_SIZE(stage_desc); ++i) VK_CALL(vkDestroyShaderModule(device, stage_desc[i].module, NULL)); @@ -1410,6 +1415,7 @@ static bool check_device_extensions(struct vulkan_shader_runner *runner, {VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME}, {VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, true}, {VK_KHR_MAINTENANCE1_EXTENSION_NAME, true}, + {VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME}, }; enabled_extensions->names = calloc(ARRAY_SIZE(device_extensions), sizeof(*enabled_extensions->names)); @@ -1430,6 +1436,8 @@ static bool check_device_extensions(struct vulkan_shader_runner *runner, runner->caps.rov = true; if (!strcmp(name, VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME)) runner->demote_to_helper_invocation = true; + if (!strcmp(name, VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME)) + runner->driver_properties = true; continue; } @@ -1471,6 +1479,20 @@ static void get_physical_device_info(struct vulkan_shader_runner *runner, struct VK_CALL(vkGetPhysicalDeviceFeatures2KHR(context->phys_device, &info->features2)); else VK_CALL(vkGetPhysicalDeviceFeatures(context->phys_device, &info->features2.features)); + + if (runner->driver_properties) + { + void *list = info->properties2.pNext; + + info->properties2.pNext = &info->driver_properties; + info->driver_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR; + info->driver_properties.pNext = list; + } + + if (context->vkGetPhysicalDeviceFeatures2KHR) + VK_CALL(vkGetPhysicalDeviceProperties2KHR(context->phys_device, &info->properties2)); + else + VK_CALL(vkGetPhysicalDeviceProperties(context->phys_device, &info->properties2.properties)); } static uint32_t get_format_support(const struct vulkan_test_context *context, enum DXGI_FORMAT format) @@ -1526,6 +1548,16 @@ static bool init_vulkan_runner(struct vulkan_shader_runner *runner) DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_SINT, }; + static const char *const tags[] = + { + "vulkan", + }; + + static const char *const mvk_tags[] = + { + "vulkan", + "mvk", + }; if (!vulkan_test_context_init_instance(context, instance_extensions, ARRAY_SIZE(instance_extensions))) return false; @@ -1559,6 +1591,17 @@ static bool init_vulkan_runner(struct vulkan_shader_runner *runner) get_physical_device_info(runner, &device_info); ret_features = &device_info.features2.features; + if (device_info.driver_properties.driverID == VK_DRIVER_ID_MOLTENVK) + { + runner->caps.tags = mvk_tags; + runner->caps.tag_count = ARRAY_SIZE(mvk_tags); + } + else + { + runner->caps.tags = tags; + runner->caps.tag_count = ARRAY_SIZE(tags); + } + runner->caps.clip_planes = true; runner->caps.point_size = true; diff --git a/tests/vulkan_procs.h b/tests/vulkan_procs.h index 2f4d7ad0..4dd69341 100644 --- a/tests/vulkan_procs.h +++ b/tests/vulkan_procs.h @@ -42,6 +42,8 @@ VK_INSTANCE_PFN(vkGetPhysicalDeviceFeatures) VK_INSTANCE_PFN(vkGetPhysicalDeviceFeatures2KHR) VK_INSTANCE_PFN(vkGetPhysicalDeviceFormatProperties) VK_INSTANCE_PFN(vkGetPhysicalDeviceMemoryProperties) +VK_INSTANCE_PFN(vkGetPhysicalDeviceProperties) +VK_INSTANCE_PFN(vkGetPhysicalDeviceProperties2KHR) VK_INSTANCE_PFN(vkGetPhysicalDeviceQueueFamilyProperties) /* Device functions (obtained by vkGetDeviceProcAddr). */