From dcab399a173f2ab99f408e2db1bafc114c29cfd9 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 26 Sep 2022 18:31:48 +0200 Subject: [PATCH] ir3/analyze_ubo_ranges: Account for reserved consts better It turns out that the ir3_setup_const_state() already includes reserved consts, so we were accidentally counting it twice. This makes us use less consts, and if there are enough reserved consts can make it go negative and wrap around. Fix this while also making sure the previous bug remains fixed. Fixes: 8cb1deded60 ("ir3/analyze_ubo_ranges: Account for reserved consts") Part-of: --- src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c index 894d069..6379957 100644 --- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c +++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c @@ -425,7 +425,7 @@ ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader_variant *v) memset(state, 0, sizeof(*state)); - uint32_t upload_remaining = max_upload - v->num_reserved_user_consts * 16; + uint32_t upload_remaining = max_upload; bool push_ubos = compiler->push_ubo_with_preamble; nir_foreach_function (function, nir) { if (function->impl && (!push_ubos || !function->is_preamble)) { @@ -449,16 +449,16 @@ ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader_variant *v) * first. */ - uint32_t offset = v->num_reserved_user_consts * 16; + uint32_t offset = 0; for (uint32_t i = 0; i < state->num_enabled; i++) { uint32_t range_size = state->range[i].end - state->range[i].start; assert(offset <= max_upload); - state->range[i].offset = offset; + state->range[i].offset = offset + v->num_reserved_user_consts * 16; assert(offset <= max_upload); offset += range_size; } - state->size = offset - v->num_reserved_user_consts * 16; + state->size = offset; } bool -- 2.7.4