From 16ab31f358a185ec3e1f762ffad1f751dfee2409 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 24 Oct 2025 14:50:06 -0700 Subject: [PATCH] brw: Use NUM_TOTAL_VARYING_SLOTS instead of VARYING_SLOT_TESS_MAX This is a bit larger, but also clearer. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/intel/compiler/brw/brw_vue_map.c | 22 ++++------------------ src/intel/compiler/intel_shader_enums.h | 4 ++-- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/intel/compiler/brw/brw_vue_map.c b/src/intel/compiler/brw/brw_vue_map.c index 70dffa72629..0e701c978ab 100644 --- a/src/intel/compiler/brw/brw_vue_map.c +++ b/src/intel/compiler/brw/brw_vue_map.c @@ -121,6 +121,8 @@ brw_compute_per_primitive_map(int *out_per_primitive_map, static inline void assign_vue_slot(struct intel_vue_map *vue_map, int varying, int slot) { + STATIC_ASSERT(NUM_TOTAL_VARYING_SLOTS <= INT8_MAX); + /* Make sure this varying hasn't been assigned a slot already */ assert (vue_map->varying_to_slot[varying] == -1); @@ -162,15 +164,7 @@ brw_compute_vue_map(const struct intel_device_info *devinfo, */ slots_valid &= ~VARYING_BIT_FACE; - /* Make sure that the values we store in vue_map->varying_to_slot and - * vue_map->slot_to_varying won't overflow the signed chars that are used - * to store them. Note that since vue_map->slot_to_varying sometimes holds - * values equal to BRW_VARYING_SLOT_COUNT, we need to ensure that - * BRW_VARYING_SLOT_COUNT is <= 127, not 128. - */ - STATIC_ASSERT(BRW_VARYING_SLOT_COUNT <= 127); - - for (int i = 0; i < BRW_VARYING_SLOT_COUNT; ++i) { + for (int i = 0; i < NUM_TOTAL_VARYING_SLOTS; ++i) { vue_map->varying_to_slot[i] = -1; vue_map->slot_to_varying[i] = BRW_VARYING_SLOT_PAD; } @@ -291,15 +285,7 @@ brw_compute_tess_vue_map(struct intel_vue_map *vue_map, vertex_slots |= VARYING_BIT_CLIP_DIST1; } - /* Make sure that the values we store in vue_map->varying_to_slot and - * vue_map->slot_to_varying won't overflow the signed chars that are used - * to store them. Note that since vue_map->slot_to_varying sometimes holds - * values equal to VARYING_SLOT_TESS_MAX , we need to ensure that - * VARYING_SLOT_TESS_MAX is <= 127, not 128. - */ - STATIC_ASSERT(VARYING_SLOT_TESS_MAX <= 127); - - for (int i = 0; i < VARYING_SLOT_TESS_MAX ; ++i) { + for (int i = 0; i < NUM_TOTAL_VARYING_SLOTS; ++i) { vue_map->varying_to_slot[i] = -1; vue_map->slot_to_varying[i] = BRW_VARYING_SLOT_PAD; } diff --git a/src/intel/compiler/intel_shader_enums.h b/src/intel/compiler/intel_shader_enums.h index 250bb7c4b7f..c79ca70b919 100644 --- a/src/intel/compiler/intel_shader_enums.h +++ b/src/intel/compiler/intel_shader_enums.h @@ -312,7 +312,7 @@ struct intel_vue_map { * additional processing is applied before storing them in the VUE), the * value is -1. */ - int8_t varying_to_slot[VARYING_SLOT_TESS_MAX]; + int8_t varying_to_slot[NUM_TOTAL_VARYING_SLOTS]; /** * Map from VUE slot to gl_varying_slot value. For slots that do not @@ -321,7 +321,7 @@ struct intel_vue_map { * * For slots that are not in use, the value is BRW_VARYING_SLOT_PAD. */ - int8_t slot_to_varying[VARYING_SLOT_TESS_MAX]; + int8_t slot_to_varying[NUM_TOTAL_VARYING_SLOTS]; /** * Total number of VUE slots in use