ac,radeonsi: move load_vector_arg flags to common code

This will be needed by lowering of barycentrics.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32782>
This commit is contained in:
Marek Olšák 2024-12-25 14:43:13 -05:00 committed by Marge Bot
parent 7e83f6ca8b
commit a15e733a81
4 changed files with 12 additions and 8 deletions

View file

@ -39,6 +39,14 @@ enum {
AC_EXP_FLAG_VALID_MASK = (1 << 2),
};
/* TODO: Remove these once radeonsi gathers shader_info before lowering. */
#define AC_VECTOR_ARG_FLAG(name, value) (((name) & 0xf) | ((value) << 4))
#define AC_VECTOR_ARG_UNSET 0
#define AC_VECTOR_ARG_INTERP_MODE 1
#define AC_VECTOR_ARG_IS_COLOR 2
#define AC_VECTOR_ARG_FLAG_GET_NAME(intr) (nir_intrinsic_flags(intr) & 0xf)
#define AC_VECTOR_ARG_FLAG_GET_VALUE(intr) (nir_intrinsic_flags(intr) >> 4)
/* Maps I/O semantics to the actual location used by the lowering pass. */
typedef unsigned (*ac_nir_map_io_driver_location)(unsigned semantic);

View file

@ -637,8 +637,7 @@ static bool lower_intrinsic(nir_builder *b, nir_instr *instr, struct lower_abi_s
color[i] = ac_nir_load_arg_at_offset(b, &args->ac, args->color_start, offset++);
nir_intrinsic_set_flags(nir_instr_as_intrinsic(color[i]->parent_instr),
SI_VECTOR_ARG_IS_COLOR |
SI_VECTOR_ARG_COLOR_COMPONENT(start + i));
AC_VECTOR_ARG_FLAG(AC_VECTOR_ARG_IS_COLOR, start + i));
} else {
color[i] = nir_undef(b, 1, 32);
}

View file

@ -139,10 +139,6 @@ struct nir_instr;
/* D3D9 behaviour for COLOR0 requires 0001. GL is undefined. */
#define SI_PS_INPUT_CNTL_UNUSED_COLOR0 SI_PS_INPUT_CNTL_0001
#define SI_VECTOR_ARG_IS_COLOR BITFIELD_BIT(0)
#define SI_VECTOR_ARG_COLOR_COMPONENT(x) (((x) & 0x7) << 1)
#define SI_GET_VECTOR_ARG_COLOR_COMPONENT(x) (((x) >> 1) & 0x7)
/* SGPR user data indices */
enum
{

View file

@ -10,6 +10,7 @@
#include "sid.h"
#include "nir.h"
#include "aco_interface.h"
#include "ac_nir.h"
struct si_shader_profile si_shader_profiles[] =
{
@ -468,9 +469,9 @@ static void scan_instruction(const struct nir_shader *nir, struct si_shader_info
}
case nir_intrinsic_load_vector_arg_amd:
/* Non-monolithic lowered PS can have this. We need to record color usage. */
if (nir_intrinsic_flags(intr) & SI_VECTOR_ARG_IS_COLOR) {
if (AC_VECTOR_ARG_FLAG_GET_NAME(intr) == AC_VECTOR_ARG_IS_COLOR) {
/* The channel can be between 0 and 7. */
unsigned chan = SI_GET_VECTOR_ARG_COLOR_COMPONENT(nir_intrinsic_flags(intr));
unsigned chan = AC_VECTOR_ARG_FLAG_GET_VALUE(intr);
info->colors_read |= BITFIELD_BIT(chan);
}
break;