From c172f1de89d65f88d3b064a66252458431d3e2cf Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 25 Jan 2023 09:30:48 +0100 Subject: [PATCH] radv: fix ignoring graphics shader stages that don't need to be imported If a shader stage is already imported from a library it should be properly ignored. Fixes recent CTS dEQP-VK.pipeline.fast_linked_library.misc.unused_shader_stages*. Fixes: c8765c5244a ("radv: ignore shader stages that don't need to be imported with GPL") Signed-off-by: Samuel Pitoiset Part-of: (cherry picked from commit b97fee432c23435bc6c6ef3f27af54c2538cc36b) --- .pick_status.json | 2 +- src/amd/vulkan/radv_pipeline.c | 15 ++++++++++++--- src/amd/vulkan/radv_pipeline_rt.c | 4 ++-- src/amd/vulkan/radv_shader.h | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index af2eccc5a4c..9e79d54b5b0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -139,7 +139,7 @@ "description": "radv: fix ignoring graphics shader stages that don't need to be imported", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c8765c5244ac194e1c85d2a88dde76c5d92a8111" }, diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 9f363c20cd5..2f4f3058916 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -3583,6 +3583,7 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout const VkPipelineCreationFeedbackCreateInfo *creation_feedback, struct radv_pipeline_shader_stack_size **stack_sizes, uint32_t *num_stack_sizes, + VkGraphicsPipelineLibraryFlagBitsEXT lib_flags, gl_shader_stage *last_vgt_api_stage) { const char *noop_fs_entrypoint = "noop_fs"; @@ -3610,6 +3611,12 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout const VkPipelineShaderStageCreateInfo *sinfo = &pStages[i]; gl_shader_stage stage = vk_to_mesa_shader_stage(sinfo->stage); + /* Ignore graphics shader stages that don't need to be imported. */ + if ((pipeline->type == RADV_PIPELINE_GRAPHICS || + pipeline->type == RADV_PIPELINE_GRAPHICS_LIB) && + !(shader_stage_to_pipeline_library_flags(sinfo->stage) & lib_flags)) + continue; + radv_pipeline_stage_init(sinfo, &stages[stage], stage); } @@ -5164,7 +5171,9 @@ radv_graphics_pipeline_init(struct radv_graphics_pipeline *pipeline, struct radv result = radv_create_shaders(&pipeline->base, &pipeline_layout, device, cache, &key, pCreateInfo->pStages, pCreateInfo->stageCount, pCreateInfo->flags, NULL, - creation_feedback, NULL, NULL, &pipeline->last_vgt_api_stage); + creation_feedback, NULL, NULL, + (~imported_flags) & ALL_GRAPHICS_LIB_FLAGS, + &pipeline->last_vgt_api_stage); if (result != VK_SUCCESS) { radv_pipeline_layout_finish(device, &pipeline_layout); return result; @@ -5379,7 +5388,7 @@ radv_graphics_lib_pipeline_init(struct radv_graphics_lib_pipeline *pipeline, result = radv_create_shaders(&pipeline->base.base, pipeline_layout, device, cache, &key, pCreateInfo->pStages, pCreateInfo->stageCount, pCreateInfo->flags, - NULL, creation_feedback, NULL, NULL, + NULL, creation_feedback, NULL, NULL, imported_flags, &pipeline->base.last_vgt_api_stage); if (result != VK_SUCCESS) @@ -5583,7 +5592,7 @@ radv_compute_pipeline_create(VkDevice _device, VkPipelineCache _cache, UNUSED gl_shader_stage last_vgt_api_stage = MESA_SHADER_NONE; result = radv_create_shaders(&pipeline->base, pipeline_layout, device, cache, &key, &pCreateInfo->stage, 1, pCreateInfo->flags, NULL, creation_feedback, - NULL, NULL, &last_vgt_api_stage); + NULL, NULL, 0, &last_vgt_api_stage); if (result != VK_SUCCESS) { radv_pipeline_destroy(device, &pipeline->base, pAllocator); return result; diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 35c93236309..e48358a2e34 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -307,7 +307,7 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, * generating the nir. */ result = radv_create_shaders( &rt_pipeline->base.base, pipeline_layout, device, cache, &key, &stage, 1, flags, hash, - creation_feedback, &rt_pipeline->stack_sizes, &rt_pipeline->group_count, &last_vgt_api_stage); + creation_feedback, &rt_pipeline->stack_sizes, &rt_pipeline->group_count, 0, &last_vgt_api_stage); if (result != VK_SUCCESS && result != VK_PIPELINE_COMPILE_REQUIRED) goto pipeline_fail; @@ -327,7 +327,7 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, module.nir = shader; result = radv_create_shaders(&rt_pipeline->base.base, pipeline_layout, device, cache, &key, &stage, 1, pCreateInfo->flags, hash, creation_feedback, - &rt_pipeline->stack_sizes, &rt_pipeline->group_count, + &rt_pipeline->stack_sizes, &rt_pipeline->group_count, 0, &last_vgt_api_stage); if (result != VK_SUCCESS) goto shader_fail; diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 50bc984bf00..2629263c90f 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -566,6 +566,7 @@ VkResult radv_create_shaders(struct radv_pipeline *pipeline, const VkPipelineCreationFeedbackCreateInfo *creation_feedback, struct radv_pipeline_shader_stack_size **stack_sizes, uint32_t *num_stack_sizes, + VkGraphicsPipelineLibraryFlagBitsEXT lib_flags, gl_shader_stage *last_vgt_api_stage); struct radv_shader_args;