nir: Move is is_compact() out of unlower_io_to_vars

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39328>
This commit is contained in:
Connor Abbott 2026-01-08 18:19:50 -05:00 committed by Marge Bot
parent b8e1ca9913
commit 3208cc80b1
2 changed files with 15 additions and 15 deletions

View file

@ -6969,6 +6969,20 @@ bool nir_opt_barycentric(nir_shader *shader, bool lower_sample_to_pos);
#include "nir_inline_helpers.h"
static inline bool
nir_is_io_compact(nir_shader *nir, bool is_output, unsigned location)
{
return nir->options->compact_arrays &&
(nir->info.stage != MESA_SHADER_VERTEX || is_output) &&
(nir->info.stage != MESA_SHADER_FRAGMENT || !is_output) &&
(location == VARYING_SLOT_CLIP_DIST0 ||
location == VARYING_SLOT_CLIP_DIST1 ||
location == VARYING_SLOT_CULL_DIST0 ||
location == VARYING_SLOT_CULL_DIST1 ||
location == VARYING_SLOT_TESS_LEVEL_OUTER ||
location == VARYING_SLOT_TESS_LEVEL_INNER);
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -67,20 +67,6 @@ get_var_num_slots(mesa_shader_stage stage, nir_variable *var,
}
}
static bool
is_compact(nir_shader *nir, bool is_output, unsigned location)
{
return nir->options->compact_arrays &&
(nir->info.stage != MESA_SHADER_VERTEX || is_output) &&
(nir->info.stage != MESA_SHADER_FRAGMENT || !is_output) &&
(location == VARYING_SLOT_CLIP_DIST0 ||
location == VARYING_SLOT_CLIP_DIST1 ||
location == VARYING_SLOT_CULL_DIST0 ||
location == VARYING_SLOT_CULL_DIST1 ||
location == VARYING_SLOT_TESS_LEVEL_OUTER ||
location == VARYING_SLOT_TESS_LEVEL_INNER);
}
/* Get information about the intrinsic. */
static bool
parse_intrinsic(nir_shader *nir, nir_intrinsic_instr *intr,
@ -120,7 +106,7 @@ parse_intrinsic(nir_shader *nir, nir_intrinsic_instr *intr,
desc->mode = desc->is_output ? nir_var_shader_out : nir_var_shader_in;
desc->location_src = *nir_get_io_offset_src(intr);
desc->is_indirect = !nir_src_is_const(desc->location_src);
desc->is_compact = is_compact(nir, desc->is_output, desc->sem.location);
desc->is_compact = nir_is_io_compact(nir, desc->is_output, desc->sem.location);
desc->is_xfb = nir_instr_xfb_write_mask(intr) != 0;
desc->num_slots = desc->is_compact ? DIV_ROUND_UP(desc->sem.num_slots, 4)
: desc->sem.num_slots;