From 4dc6cd5933c191ce50b9acdffaec202faedf7a4c Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 30 Dec 2021 16:09:50 -0800 Subject: [PATCH] tgsi/exec: Simplify indirects now that they always use the ADDR file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was a lot of extra code in the hot path of getting though fetch_src_file_channel(). No significant perf difference in softpipe, though. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 56 +++++--------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index b9262d25bab..f50b2c3f2f6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1501,8 +1501,6 @@ get_index_registers(const struct tgsi_exec_machine *mach, union tgsi_exec_channel *index, union tgsi_exec_channel *index2D) { - uint swizzle; - /* We start with a direct index into a register file. * * file[1], @@ -1526,35 +1524,17 @@ get_index_registers(const struct tgsi_exec_machine *mach, * .x = Indirect.SwizzleX */ if (reg->Register.Indirect) { - union tgsi_exec_channel index2; - union tgsi_exec_channel indir_index; const uint execmask = mach->ExecMask; - uint i; - /* which address register (always zero now) */ - index2.i[0] = - index2.i[1] = - index2.i[2] = - index2.i[3] = reg->Indirect.Index; - /* get current value of address register[swizzle] */ - swizzle = reg->Indirect.Swizzle; - fetch_src_file_channel(mach, - reg->Indirect.File, - swizzle, - &index2, - &ZeroVec, - &indir_index); - - /* add value of address register to the offset */ - index->i[0] += indir_index.i[0]; - index->i[1] += indir_index.i[1]; - index->i[2] += indir_index.i[2]; - index->i[3] += indir_index.i[3]; + assert(reg->Indirect.File == TGSI_FILE_ADDRESS); + const union tgsi_exec_channel *addr = &mach->Addrs[reg->Indirect.Index].xyzw[reg->Indirect.Swizzle]; + for (int i = 0; i < TGSI_QUAD_SIZE; i++) + index->i[i] += addr->u[i]; /* for disabled execution channels, zero-out the index to * avoid using a potential garbage value. */ - for (i = 0; i < TGSI_QUAD_SIZE; i++) { + for (int i = 0; i < TGSI_QUAD_SIZE; i++) { if ((execmask & (1 << i)) == 0) index->i[i] = 0; } @@ -1586,33 +1566,17 @@ get_index_registers(const struct tgsi_exec_machine *mach, * .y = DimIndirect.SwizzleX */ if (reg->Dimension.Indirect) { - union tgsi_exec_channel index2; - union tgsi_exec_channel indir_index; const uint execmask = mach->ExecMask; - uint i; - index2.i[0] = - index2.i[1] = - index2.i[2] = - index2.i[3] = reg->DimIndirect.Index; - - swizzle = reg->DimIndirect.Swizzle; - fetch_src_file_channel(mach, - reg->DimIndirect.File, - swizzle, - &index2, - &ZeroVec, - &indir_index); - - index2D->i[0] += indir_index.i[0]; - index2D->i[1] += indir_index.i[1]; - index2D->i[2] += indir_index.i[2]; - index2D->i[3] += indir_index.i[3]; + assert(reg->DimIndirect.File == TGSI_FILE_ADDRESS); + const union tgsi_exec_channel *addr = &mach->Addrs[reg->DimIndirect.Index].xyzw[reg->DimIndirect.Swizzle]; + for (int i = 0; i < TGSI_QUAD_SIZE; i++) + index2D->i[i] += addr->u[i]; /* for disabled execution channels, zero-out the index to * avoid using a potential garbage value. */ - for (i = 0; i < TGSI_QUAD_SIZE; i++) { + for (int i = 0; i < TGSI_QUAD_SIZE; i++) { if ((execmask & (1 << i)) == 0) { index2D->i[i] = 0; }