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: c8765c5244 ("radv: ignore shader stages that don't need to be imported with GPL")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20899>
(cherry picked from commit b97fee432c)
This commit is contained in:
Samuel Pitoiset 2023-01-25 09:30:48 +01:00 committed by Dylan Baker
parent f89be5c1d6
commit c172f1de89
4 changed files with 16 additions and 6 deletions

View file

@ -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"
},

View file

@ -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;

View file

@ -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;

View file

@ -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;