Module: Mesa Branch: main Commit: e9f08d8193c1ff4c37fae1797e53b2e895615fc3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9f08d8193c1ff4c37fae1797e53b2e895615fc3
Author: Qiang Yu <[email protected]> Date: Wed Aug 10 19:18:15 2022 +0800 ac/nir: add ac_nir_unpack_arg Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Qiang Yu <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18010> --- src/amd/common/ac_nir.c | 8 ++++++++ src/amd/common/ac_nir.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/amd/common/ac_nir.c b/src/amd/common/ac_nir.c index 6e86babf3d1..569bb9efe06 100644 --- a/src/amd/common/ac_nir.c +++ b/src/amd/common/ac_nir.c @@ -36,6 +36,14 @@ ac_nir_load_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct ac_ return nir_load_vector_arg_amd(b, num_components, .base = arg.arg_index); } +nir_ssa_def * +ac_nir_unpack_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct ac_arg arg, + unsigned rshift, unsigned bitwidth) +{ + nir_ssa_def *value = ac_nir_load_arg(b, ac_args, arg); + return nir_ubfe_imm(b, value, rshift, bitwidth); +} + /** * This function takes an I/O intrinsic like load/store_input, * and emits a sequence that calculates the full offset of that instruction, diff --git a/src/amd/common/ac_nir.h b/src/amd/common/ac_nir.h index 798bb552aeb..39794a40c95 100644 --- a/src/amd/common/ac_nir.h +++ b/src/amd/common/ac_nir.h @@ -63,6 +63,10 @@ typedef void (*ac_nir_cull_accepted)(nir_builder *b, void *state); nir_ssa_def * ac_nir_load_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct ac_arg arg); +nir_ssa_def * +ac_nir_unpack_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct ac_arg arg, + unsigned rshift, unsigned bitwidth); + nir_ssa_def * ac_nir_calc_io_offset(nir_builder *b, nir_intrinsic_instr *intrin,
