From b1acc1aa894233beba2c7299b5dd0c5654c62a1e Mon Sep 17 00:00:00 2001 From: Lorenzo Rossi Date: Wed, 25 Mar 2026 14:40:26 +0100 Subject: [PATCH] pan/compiler: Refactor va_shader_output_from_ in common code Signed-off-by: Lorenzo Rossi Reviewed-by: Faith Ekstrand Part-of: --- .../compiler/bifrost/bifrost_compile.c | 19 ++----------------- .../compiler/bifrost/valhall/valhall.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/panfrost/compiler/bifrost/bifrost_compile.c b/src/panfrost/compiler/bifrost/bifrost_compile.c index 2fea9bea383..926c7518c13 100644 --- a/src/panfrost/compiler/bifrost/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost/bifrost_compile.c @@ -1015,21 +1015,6 @@ bi_is_zs(unsigned location) return location == FRAG_RESULT_DEPTH || location == FRAG_RESULT_STENCIL; } -static enum va_shader_output -va_shader_output_from_semantics(const nir_io_semantics *sem) -{ - switch (sem->location) { - case VARYING_SLOT_POS: - return VA_SHADER_OUTPUT_POSITION; - case VARYING_SLOT_PSIZ: - case VARYING_SLOT_LAYER: - case VARYING_SLOT_PRIMITIVE_ID: - return VA_SHADER_OUTPUT_ATTRIB; - default: - return VA_SHADER_OUTPUT_VARY; - } -} - static bool bifrost_nir_lower_shader_output_impl(struct nir_builder *b, nir_intrinsic_instr *intr, void *data) @@ -1039,7 +1024,7 @@ bifrost_nir_lower_shader_output_impl(struct nir_builder *b, return false; nir_io_semantics sem = nir_intrinsic_io_semantics(intr); - unsigned mask = va_shader_output_from_semantics(&sem); + unsigned mask = va_shader_output_from_loc(sem.location); b->cursor = nir_instr_remove(&intr->instr); nir_def *shader_output = nir_load_shader_output_pan(b); @@ -1089,7 +1074,7 @@ bifrost_nir_lower_vs_atomics_impl(nir_builder *b, nir_intrinsic_instr *intr, continue; nir_io_semantics sem = nir_intrinsic_io_semantics(parent_intr); - output_mask |= BITFIELD_BIT(va_shader_output_from_semantics(&sem)); + output_mask |= BITFIELD_BIT(va_shader_output_from_loc(sem.location)); } /* In case they are not written to any outputs, we default to only output in diff --git a/src/panfrost/compiler/bifrost/valhall/valhall.h b/src/panfrost/compiler/bifrost/valhall/valhall.h index b3896a9f38c..ae716c36ffd 100644 --- a/src/panfrost/compiler/bifrost/valhall/valhall.h +++ b/src/panfrost/compiler/bifrost/valhall/valhall.h @@ -10,6 +10,7 @@ #include "util/macros.h" #include "bi_opcodes.h" #include "valhall_enums.h" +#include "shader_enums.h" #ifdef __cplusplus extern "C" { @@ -193,6 +194,21 @@ enum va_shader_output { #define VA_SHADER_OUTPUT_ATTRIB_BIT BITFIELD_BIT(VA_SHADER_OUTPUT_ATTRIB) #define VA_SHADER_OUTPUT_VARY_BIT BITFIELD_BIT(VA_SHADER_OUTPUT_VARY) +static inline enum va_shader_output +va_shader_output_from_loc(gl_varying_slot location) +{ + switch (location) { + case VARYING_SLOT_POS: + return VA_SHADER_OUTPUT_POSITION; + case VARYING_SLOT_PSIZ: + case VARYING_SLOT_LAYER: + case VARYING_SLOT_PRIMITIVE_ID: + return VA_SHADER_OUTPUT_ATTRIB; + default: + return VA_SHADER_OUTPUT_VARY; + } +} + #ifdef __cplusplus } /* extern C */ #endif