From f79525dda6fa288514f0a2ac63fbd4b8b87c7067 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: (cherry picked from commit dcab399a173f2ab99f408e2db1bafc114c29cfd9) --- .pick_status.json | 2 +- src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 566cca3ef93..5fa718428fe 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -49,7 +49,7 @@ "description": "ir3/analyze_ubo_ranges: Account for reserved consts better", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "8cb1deded60e4b8d101e4a3055078f9434aa7d8f" }, diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c index 894d069388d..637995778f7 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