brw: Drop BRW_VARYING_SLOT_PAD and brw_varying_slot enum

In elk, we tried to store our own "driver" enum values after Mesa's
VARYING_SLOT_MAX.  In brw, we eliminated all of these except for an
unnecessary "BRW_VARYING_SLOT_PAD" value.  This was used for empty
slots, so vue_map::slot_to_varying[] could store something.  This
patch replaces BRW_VARYING_SLOT_PAD with -1.

Our "driver" enum values overlapped with VARYING_SLOT_PATCH0, leading
to unnecessary headaches.  Now gl_varying_slot_name_for_stage will do
the right thing for both regular and patch varyings.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38121>
This commit is contained in:
Kenneth Graunke 2025-10-24 14:14:15 -07:00
parent 16ab31f358
commit 5e48094d72
4 changed files with 18 additions and 53 deletions

View file

@ -719,8 +719,7 @@ calculate_urb_setup(const struct intel_device_info *devinfo,
int first_slot = 0;
for (int i = 0; i < vue_map.num_slots; i++) {
int varying = vue_map.slot_to_varying[i];
if (varying != BRW_VARYING_SLOT_PAD && varying > 0 &&
(inputs_read & BITFIELD64_BIT(varying)) != 0) {
if (varying > 0 && (inputs_read & BITFIELD64_BIT(varying)) != 0) {
first_slot = ROUND_DOWN_TO(i, 2);
break;
}
@ -728,7 +727,7 @@ calculate_urb_setup(const struct intel_device_info *devinfo,
for (int slot = first_slot; slot < vue_map.num_slots; slot++) {
int varying = vue_map.slot_to_varying[slot];
if (varying != BRW_VARYING_SLOT_PAD &&
if (varying > 0 &&
(inputs_read & BRW_FS_VARYING_INPUT_MASK &
BITFIELD64_BIT(varying))) {
prog_data->urb_setup[varying] = slot - first_slot;
@ -1953,11 +1952,7 @@ brw_compute_sbe_per_vertex_urb_read(const struct intel_vue_map *prev_stage_vue_m
for (int _i = 0; _i < prev_stage_vue_map->num_slots; _i++) {
uint32_t i = prev_stage_vue_map->num_slots - 1 - _i;
int varying = prev_stage_vue_map->slot_to_varying[i];
if (varying < 0)
continue;
if (varying == BRW_VARYING_SLOT_PAD ||
(inputs_read & BITFIELD64_BIT(varying)) == 0)
if (varying < 0 || (inputs_read & BITFIELD64_BIT(varying)) == 0)
continue;
last_slot = i;
@ -1966,8 +1961,7 @@ brw_compute_sbe_per_vertex_urb_read(const struct intel_vue_map *prev_stage_vue_m
for (int i = 0; i < prev_stage_vue_map->num_slots; i++) {
int varying = prev_stage_vue_map->slot_to_varying[i];
if (varying != BRW_VARYING_SLOT_PAD && varying > 0 &&
(inputs_read & BITFIELD64_BIT(varying)) != 0) {
if (varying > 0 && (inputs_read & BITFIELD64_BIT(varying)) != 0) {
first_slot = i;
break;
}

View file

@ -971,18 +971,6 @@ struct brw_bs_prog_data {
uint32_t num_resume_shaders;
};
/**
* Enum representing the i965-specific vertex results that don't correspond
* exactly to any element of gl_varying_slot. The values of this enum are
* assigned such that they don't conflict with gl_varying_slot.
*/
typedef enum
{
BRW_VARYING_SLOT_PAD = VARYING_SLOT_MAX,
BRW_VARYING_SLOT_COUNT
} brw_varying_slot;
#define BRW_VUE_HEADER_VARYING_MASK \
(VARYING_BIT_VIEWPORT | \
VARYING_BIT_LAYER | \
@ -1009,7 +997,7 @@ static inline unsigned brw_vue_slot_to_offset(unsigned slot)
}
/**
* Convert a vertex output (brw_varying_slot) into a byte offset within the
* Convert a vertex output (gl_varying_slot) into a byte offset within the
* VUE.
*/
static inline unsigned

View file

@ -166,7 +166,7 @@ brw_compute_vue_map(const struct intel_device_info *devinfo,
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;
vue_map->slot_to_varying[i] = -1;
}
int slot = 0;
@ -287,7 +287,7 @@ brw_compute_tess_vue_map(struct intel_vue_map *vue_map,
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;
vue_map->slot_to_varying[i] = -1;
}
int slot = 0;
@ -360,21 +360,6 @@ brw_compute_tess_vue_map(struct intel_vue_map *vue_map,
vue_map->num_slots = slot;
}
static const char *
varying_name(brw_varying_slot slot, mesa_shader_stage stage)
{
assume(slot < BRW_VARYING_SLOT_COUNT);
if (slot < VARYING_SLOT_MAX)
return gl_varying_slot_name_for_stage((gl_varying_slot)slot, stage);
static const char *brw_names[] = {
[BRW_VARYING_SLOT_PAD - VARYING_SLOT_MAX] = "BRW_VARYING_SLOT_PAD",
};
return brw_names[slot - VARYING_SLOT_MAX];
}
void
brw_print_vue_map(FILE *fp, const struct intel_vue_map *vue_map,
mesa_shader_stage stage)
@ -390,21 +375,18 @@ brw_print_vue_map(FILE *fp, const struct intel_vue_map *vue_map,
vue_map->num_per_patch_slots,
vue_map->num_per_vertex_slots,
layout_name);
for (int i = 0; i < vue_map->num_slots; i++) {
if (vue_map->slot_to_varying[i] >= VARYING_SLOT_PATCH0) {
fprintf(fp, " [%02d] VARYING_SLOT_PATCH%d\n", i,
vue_map->slot_to_varying[i] - VARYING_SLOT_PATCH0);
} else {
fprintf(fp, " [%02d] %s\n", i,
varying_name(vue_map->slot_to_varying[i], stage));
}
}
} else {
fprintf(fp, "%s VUE map (%d slots, %s)\n",
mesa_shader_stage_name(stage), vue_map->num_slots, layout_name);
for (int i = 0; i < vue_map->num_slots; i++) {
}
for (int i = 0; i < vue_map->num_slots; i++) {
const signed char v = vue_map->slot_to_varying[i];
if (v == -1) {
fprintf(fp, " ...\n");
} else {
fprintf(fp, " [%02d] %s\n", i,
varying_name(vue_map->slot_to_varying[i], stage));
gl_varying_slot_name_for_stage(v, stage));
}
}
fprintf(fp, "\n");

View file

@ -317,9 +317,10 @@ struct intel_vue_map {
/**
* Map from VUE slot to gl_varying_slot value. For slots that do not
* directly correspond to a gl_varying_slot, the value comes from
* brw_varying_slot.
* elk_varying_slot.
*
* For slots that are not in use, the value is BRW_VARYING_SLOT_PAD.
* For slots that are not in use, the value is -1 (brw) or
* ELK_VARYING_SLOT_PAD.
*/
int8_t slot_to_varying[NUM_TOTAL_VARYING_SLOTS];