From 16bef14dd4fb1e5ed3d3aba86fc55de6299d6311 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 7 Aug 2023 15:10:26 +0200 Subject: [PATCH] r600/sfn: Make use of four clause local registers The hardware is actually configures like this, but for fma64 we have to sacrifice a "normal" register to allocate z and w channels, even though the result written there is not used. Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/r600_asm.c | 4 ++-- src/gallium/drivers/r600/sfn/sfn_alu_defines.h | 5 +++-- src/gallium/drivers/r600/sfn/sfn_assembler.cpp | 4 ++-- src/gallium/drivers/r600/sfn/sfn_ra.cpp | 8 ++++---- src/gallium/drivers/r600/sfn/sfn_valuefactory.h | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c index f51fae6..39b16f1 100644 --- a/src/gallium/drivers/r600/r600_asm.c +++ b/src/gallium/drivers/r600/r600_asm.c @@ -1334,14 +1334,14 @@ int r600_bytecode_add_alu_type(struct r600_bytecode *bc, } /* number of gpr == the last gpr used in any alu */ for (i = 0; i < 3; i++) { - if (nalu->src[i].sel >= bc->ngpr && nalu->src[i].sel < 124) { + if (nalu->src[i].sel >= bc->ngpr && nalu->src[i].sel < 123) { bc->ngpr = nalu->src[i].sel + 1; } if (nalu->src[i].sel == V_SQ_ALU_SRC_LITERAL) r600_bytecode_special_constants(nalu->src[i].value, &nalu->src[i].sel); } - if (nalu->dst.write && nalu->dst.sel >= bc->ngpr && nalu->dst.sel < 124) { + if (nalu->dst.write && nalu->dst.sel >= bc->ngpr && nalu->dst.sel < 123) { bc->ngpr = nalu->dst.sel + 1; } list_addtail(&nalu->list, &bc->cf_last->alu); diff --git a/src/gallium/drivers/r600/sfn/sfn_alu_defines.h b/src/gallium/drivers/r600/sfn/sfn_alu_defines.h index dd02459..93ee6c6 100644 --- a/src/gallium/drivers/r600/sfn/sfn_alu_defines.h +++ b/src/gallium/drivers/r600/sfn/sfn_alu_defines.h @@ -34,9 +34,10 @@ namespace r600 { - +// We sacrifice 123 for dummy dests +static const int g_registers_end = 123; static const int g_clause_local_start = 124; -static const int g_clause_local_end = 126; +static const int g_clause_local_end = 128; /* ALU op2 instructions 17:7 top three bits always zero. */ enum EAluOp { diff --git a/src/gallium/drivers/r600/sfn/sfn_assembler.cpp b/src/gallium/drivers/r600/sfn/sfn_assembler.cpp index 47cabf9..208ec68 100644 --- a/src/gallium/drivers/r600/sfn/sfn_assembler.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_assembler.cpp @@ -1217,7 +1217,7 @@ bool AssamblerVisitor::copy_dst(r600_bytecode_alu_dst& dst, const Register& d, bool write) { if (write && d.sel() > g_clause_local_end) { - R600_ERR("shader_from_nir: Don't support more then 124 GPRs + 2 claus " + R600_ERR("shader_from_nir: Don't support more then 123 GPRs + 4 clause " "local, but try using %d\n", d.sel()); m_result = false; @@ -1306,7 +1306,7 @@ EncodeSourceVisitor::EncodeSourceVisitor(r600_bytecode_alu_src& s, r600_bytecode void EncodeSourceVisitor::visit(const Register& value) { - assert(value.sel() < g_clause_local_end && "Only have 124 reisters + 4 clause local"); + assert(value.sel() < g_clause_local_end && "Only have 123 reisters + 4 clause local"); } void diff --git a/src/gallium/drivers/r600/sfn/sfn_ra.cpp b/src/gallium/drivers/r600/sfn/sfn_ra.cpp index 2a36b31..6905827 100644 --- a/src/gallium/drivers/r600/sfn/sfn_ra.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_ra.cpp @@ -114,7 +114,7 @@ group_allocation(LiveRangeMap& lrm, if (group.priority > 0) color = 0; - while (color < 124) { + while (color < g_registers_end) { /* Find the coloring for the first channel */ bool color_in_use = false; int comp = start_comp; @@ -181,7 +181,7 @@ group_allocation(LiveRangeMap& lrm, break; } - if (color == 124) + if (color == g_registers_end) return false; } @@ -206,7 +206,7 @@ scalar_allocation(LiveRangeMap& lrm, const Interference& interference) int color = 0; - while (color < 124) { + while (color < g_registers_end) { bool color_in_use = false; for (auto adj : adjecency) { if (live_ranges[adj].m_color == color) { @@ -223,7 +223,7 @@ scalar_allocation(LiveRangeMap& lrm, const Interference& interference) r.m_color = color; break; } - if (color == 124) + if (color == g_registers_end) return false; } } diff --git a/src/gallium/drivers/r600/sfn/sfn_valuefactory.h b/src/gallium/drivers/r600/sfn/sfn_valuefactory.h index b5293ab..f29e090 100644 --- a/src/gallium/drivers/r600/sfn/sfn_valuefactory.h +++ b/src/gallium/drivers/r600/sfn/sfn_valuefactory.h @@ -329,7 +329,7 @@ private: uint32_t m_nowrite_idx; RegisterVec4 m_dummy_dest_pinned{ - 126, pin_chan, {0, 1, 2, 3} + g_registers_end, pin_chan, {0, 1, 2, 3} }; ChannelCounts m_channel_counts; uint32_t m_required_array_registers{0}; -- 2.7.4