ir3: Don't reset immediate count to 0 after lowering

We need to know the immediate count even after lowering, to compute the
overall const size. Previously we were using the capacity field, but
that's unreliable and won't be available once we switch to a real
dynamic array container instead of (poorly) reinventing one.

Fixes: 86f3c0c4c2 ("ir3: simplify constlen calculation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40961>
This commit is contained in:
Connor Abbott 2026-04-15 14:21:42 -04:00 committed by Marge Bot
parent 19d64d6f7d
commit 280c64d720
3 changed files with 4 additions and 3 deletions

View file

@ -47,6 +47,5 @@ ir3_imm_const_to_preamble(struct ir3 *ir, struct ir3_shader_variant *so)
ir3_store_const(so, &build, src, dst);
}
imms->count = 0;
return true;
}

View file

@ -1576,7 +1576,8 @@ tu_xs_get_immediates_packet_size_dwords(const struct ir3_shader_variant *xs)
const struct ir3_const_state *const_state = ir3_const_state(xs);
uint32_t base = const_state->allocs.max_const_offset_vec4;
const struct ir3_imm_const_state *imm_state = &xs->imm_state;
int32_t size = DIV_ROUND_UP(imm_state->count, 4);
int32_t size = xs->compiler->info->props.load_shader_consts_via_preamble ?
0 : DIV_ROUND_UP(imm_state->count, 4);
/* truncate size to avoid writing constants that shader
* does not use:

View file

@ -302,7 +302,8 @@ ir3_emit_immediates(const struct ir3_shader_variant *v,
{
const struct ir3_const_state *const_state = ir3_const_state(v);
uint32_t base = const_state->allocs.max_const_offset_vec4;
int size = DIV_ROUND_UP(v->imm_state.count, 4);
int size = v->compiler->info->props.load_shader_consts_via_preamble ? 0 :
DIV_ROUND_UP(v->imm_state.count, 4);
/* truncate size to avoid writing constants that shader
* does not use: