From 4100f1d08ac9b04eee26449c3295572bf7362860 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Wed, 30 Apr 2025 12:40:14 +0000 Subject: [PATCH] pan/bi: Stop writing pan_shader_info::vs::idvs on non VS stages We were unconditionally writing to vs anonymous union on other stages than VS. this was not causing issues as pan_shader_compile unconditionally overrite the value for fragment shaders and compute shaders union is too small to be affecte. Fixes: 1d21de788d3f ("pan/bi: Specialize shaders for IDVS") Reported-by: Erik Faye-Lund Signed-off-by: Mary Guillemard Reviewed-by: Erik Faye-Lund Part-of: --- src/panfrost/compiler/bifrost_compile.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index ed046307755..59a1e3fa77c 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -6343,10 +6343,12 @@ bifrost_compile_shader_nir(nir_shader *nir, */ NIR_PASS(_, nir, pan_nir_lower_zs_store); - info->vs.idvs = bi_should_idvs(nir, inputs); + if (nir->info.stage == MESA_SHADER_VERTEX) { + info->vs.idvs = bi_should_idvs(nir, inputs); - if (info->vs.idvs) - NIR_PASS(_, nir, bifrost_nir_lower_shader_output); + if (info->vs.idvs) + NIR_PASS(_, nir, bifrost_nir_lower_shader_output); + } bi_optimize_nir(nir, inputs->gpu_id, inputs->is_blend); @@ -6354,12 +6356,14 @@ bifrost_compile_shader_nir(nir_shader *nir, pan_nir_collect_varyings(nir, info, PAN_MEDIUMP_VARY_32BIT); - /* On Avalon, IDVS is only in one binary */ - if (info->vs.idvs && pan_arch(inputs->gpu_id) >= 12) { - bi_compile_variant(nir, inputs, binary, info, BI_IDVS_ALL); - } else if (info->vs.idvs) { - bi_compile_variant(nir, inputs, binary, info, BI_IDVS_POSITION); - bi_compile_variant(nir, inputs, binary, info, BI_IDVS_VARYING); + if (nir->info.stage == MESA_SHADER_VERTEX && info->vs.idvs) { + /* On Avalon, IDVS is only in one binary */ + if (pan_arch(inputs->gpu_id) >= 12) + bi_compile_variant(nir, inputs, binary, info, BI_IDVS_ALL); + else { + bi_compile_variant(nir, inputs, binary, info, BI_IDVS_POSITION); + bi_compile_variant(nir, inputs, binary, info, BI_IDVS_VARYING); + } } else { bi_compile_variant(nir, inputs, binary, info, BI_IDVS_NONE); }