From d12a9738a04f8d8158872b52221daf376ee82467 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Fri, 27 Oct 2023 11:31:47 -0500 Subject: [PATCH] tests/shader_runner: Compile HLSL for all stages before compiling SPIRV. --- tests/shader_runner_vulkan.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 8ccda6d2..003f8295 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -465,9 +465,6 @@ static bool create_shader_stage(struct vulkan_shader_runner *runner, const struct vulkan_test_context *context = &runner->context; struct vkd3d_shader_code spirv; - if (!compile_hlsl_and_scan(runner, type)) - return false; - if (!compile_d3d_code(runner, type, &spirv)) return false; @@ -578,6 +575,24 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner, VkResult vr; int ret; + ret = compile_hlsl_and_scan(runner, SHADER_TYPE_VS); + ret &= compile_hlsl_and_scan(runner, SHADER_TYPE_PS); + if (runner->r.shader_source[SHADER_TYPE_HS]) + { + ret &= compile_hlsl_and_scan(runner, SHADER_TYPE_HS); + ret &= compile_hlsl_and_scan(runner, SHADER_TYPE_DS); + } + if (runner->r.shader_source[SHADER_TYPE_GS]) + ret &= compile_hlsl_and_scan(runner, SHADER_TYPE_GS); + + 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"); + return VK_NULL_HANDLE; + } + memset(stage_desc, 0, sizeof(stage_desc)); ret = create_shader_stage(runner, &stage_desc[stage_count++], SHADER_TYPE_VS, VK_SHADER_STAGE_VERTEX_BIT); ret &= create_shader_stage(runner, &stage_desc[stage_count++], SHADER_TYPE_PS, VK_SHADER_STAGE_FRAGMENT_BIT); @@ -593,11 +608,9 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner, if (runner->r.shader_source[SHADER_TYPE_GS]) ret &= create_shader_stage(runner, &stage_desc[stage_count++], SHADER_TYPE_GS, VK_SHADER_STAGE_GEOMETRY_BIT); + 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; @@ -747,11 +760,14 @@ static VkPipeline create_compute_pipeline(struct vulkan_shader_runner *runner, V VkPipeline pipeline; bool ret; - ret = create_shader_stage(runner, &pipeline_desc.stage, SHADER_TYPE_CS, VK_SHADER_STAGE_COMPUTE_BIT); + ret = compile_hlsl_and_scan(runner, SHADER_TYPE_CS); todo_if (runner->r.is_todo) ok(ret, "Failed to compile shader.\n"); if (!ret) return VK_NULL_HANDLE; + ret = create_shader_stage(runner, &pipeline_desc.stage, SHADER_TYPE_CS, VK_SHADER_STAGE_COMPUTE_BIT); + ok(ret, "Failed to compile shader.\n"); + pipeline_desc.layout = pipeline_layout; VK_CALL(vkCreateComputePipelines(context->device, VK_NULL_HANDLE, 1, &pipeline_desc, NULL, &pipeline));