pan/bi: Use variable src/dest for collect/split

This avoids the nr_srcs/nr_dests setting dance, and will allow the builder to
handle the required memory allocation when we switch to dynamic src/dest
allocation.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>
This commit is contained in:
Alyssa Rosenzweig
2022-07-22 11:40:17 -04:00
committed by Marge Bot
parent 9bb2ac4d8c
commit 9c45ce309d
7 changed files with 19 additions and 27 deletions
+2 -2
View File
@@ -8854,9 +8854,9 @@
</mod>
</ins>
<ins name="+COLLECT.i32" pseudo="true"/>
<ins name="+COLLECT.i32" pseudo="true" variable_srcs="true"/>
<ins name="+SPLIT.i32" pseudo="true">
<ins name="+SPLIT.i32" pseudo="true" variable_dests="true">
<src start="0"/>
</ins>
@@ -129,8 +129,8 @@ bi_opt_message_preload(bi_context *ctx)
*/
b.cursor = bi_before_instr(I);
bi_instr *collect = bi_collect_i32_to(&b, I->dest[0]);
collect->nr_srcs = bi_count_write_registers(I, 0);
unsigned nr = bi_count_write_registers(I, 0);
bi_instr *collect = bi_collect_i32_to(&b, I->dest[0], nr);
/* The registers themselves must be preloaded at the start of
* the program. Preloaded registers are coalesced, so these
+2 -2
View File
@@ -160,8 +160,8 @@ bi_opt_push_ubo(bi_context *ctx)
/* Replace the UBO load with moves from FAU */
bi_builder b = bi_init_builder(ctx, bi_after_instr(ins));
bi_instr *vec = bi_collect_i32_to(&b, ins->dest[0]);
vec->nr_srcs = bi_opcode_props[ins->op].sr_count;
unsigned nr = bi_opcode_props[ins->op].sr_count;
bi_instr *vec = bi_collect_i32_to(&b, ins->dest[0], nr);
bi_foreach_src(vec, w) {
/* FAU is grouped in pairs (2 x 4-byte) */
+7 -11
View File
@@ -158,8 +158,7 @@ bi_extract(bi_builder *b, bi_index vec, unsigned channel)
* Bypass the cache and emit an explicit split for registers.
*/
if (vec.reg) {
bi_instr *I = bi_split_i32_to(b, bi_null(), vec);
I->nr_dests = channel + 1;
bi_instr *I = bi_split_i32_to(b, channel + 1, vec);
I->dest[channel] = bi_temp(b->shader);
return I->dest[channel];
}
@@ -210,10 +209,9 @@ bi_emit_split_i32(bi_builder *b, bi_index dests[4], bi_index vec, unsigned n)
if (n == 1) {
bi_mov_i32_to(b, dests[0], vec);
} else {
bi_instr *I = bi_split_i32_to(b, dests[0], vec);
I->nr_dests = n;
bi_instr *I = bi_split_i32_to(b, n, vec);
for (unsigned j = 1; j < n; ++j)
bi_foreach_dest(I, j)
I->dest[j] = dests[j];
}
}
@@ -251,10 +249,9 @@ bi_emit_collect_to(bi_builder *b, bi_index dst, bi_index *chan, unsigned n)
if (n == 1)
return bi_mov_i32_to(b, dst, chan[0]);
bi_instr *I = bi_collect_i32_to(b, dst);
I->nr_srcs = n;
bi_instr *I = bi_collect_i32_to(b, dst, n);
for (unsigned i = 0; i < n; ++i)
bi_foreach_src(I, i)
I->src[i] = chan[i];
bi_cache_collect(b, dst, chan, n);
@@ -1050,10 +1047,9 @@ bi_emit_store_vary(bi_builder *b, nir_intrinsic_instr *instr)
bi_emit_split_i32(b, chans, data, src_comps);
bi_index tmp = bi_temp(b->shader);
bi_instr *collect = bi_collect_i32_to(b, tmp);
collect->nr_srcs = nr;
bi_instr *collect = bi_collect_i32_to(b, tmp, nr);
for (unsigned w = 0; w < nr; ++w)
bi_foreach_src(collect, w)
collect->src[w] = chans[w];
data = tmp;
@@ -80,11 +80,10 @@ protected:
static void preload_moves(bi_builder *b, bi_index dest, int count, int idx)
{
bi_instr *I = bi_collect_i32_to(b, dest);
I->nr_srcs = count;
bi_instr *I = bi_collect_i32_to(b, dest, count);
b->cursor = bi_before_block(bi_start_block(&b->shader->blocks));
for (int i = 0; i < count; ++i)
bi_foreach_src(I, i)
I->src[i] = bi_mov_i32(b, bi_register(idx*4 + i));
b->cursor = bi_after_instr(I);
+2 -2
View File
@@ -429,8 +429,8 @@ TEST_F(Optimizer, VarTexCoord32)
bi_index x = bi_temp(b->shader);
bi_index y = bi_temp(b->shader);
bi_instr *split = bi_split_i32_to(b, x, ld);
split->nr_dests = 2;
bi_instr *split = bi_split_i32_to(b, 2, ld);
split->dest[0] = x;
split->dest[1] = y;
bi_texs_2d_f32_to(b, reg, x, y, false, 0, 0);
@@ -47,11 +47,8 @@ lower_split_src(bi_context *ctx, bi_instr *I, unsigned s)
/* Allocate temporary before the instruction */
bi_builder b = bi_init_builder(ctx, bi_before_instr(I));
bi_index vec = bi_temp(ctx);
bi_instr *collect = bi_collect_i32_to(&b, vec);
collect->nr_srcs = 2;
bi_instr *split = bi_split_i32_to(&b, bi_null(), vec);
split->nr_dests = 2;
bi_instr *collect = bi_collect_i32_to(&b, vec, 2);
bi_instr *split = bi_split_i32_to(&b, 2, vec);
/* Emit collect */
for (unsigned w = 0; w < 2; ++w) {