Module: Mesa Branch: main Commit: 7ad57d9af185aeec827a1b9b8012dacd08ffb29d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ad57d9af185aeec827a1b9b8012dacd08ffb29d
Author: Connor Abbott <[email protected]> Date: Tue Jan 25 10:30:33 2022 +0100 ir3: Don't count reserved user consts in ubo_state::size Previously we included the reserved user consts (for Vulkan push constants) as part of the pushed UBO contents, but that led to a problem because when calculating the worst-case space for UBOs we didn't factor in the reserved user consts. We'll have the same problem when doing the same thing in the preamble optimization pass. Stop including the reserved size in ubo_state::size, and have ir3_setup_consts() add it in instead, so we won't forget to add it anywhere. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148> --- src/freedreno/ir3/ir3_compiler_nir.c | 4 +++- src/freedreno/ir3/ir3_nir.c | 3 ++- src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index f4dd5048182..8975c85cd86 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -2044,7 +2044,9 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr) * addr reg value can be: */ ctx->so->constlen = - MAX2(ctx->so->constlen, const_state->ubo_state.size / 16); + MAX2(ctx->so->constlen, + ctx->so->shader->num_reserved_user_consts + + const_state->ubo_state.size / 16); } break; diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index dcd5052eccd..207a327f94f 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -825,7 +825,8 @@ ir3_setup_const_state(nir_shader *nir, struct ir3_shader_variant *v, const_state->num_ubos = nir->info.num_ubos; debug_assert((const_state->ubo_state.size % 16) == 0); - unsigned constoff = const_state->ubo_state.size / 16; + unsigned constoff = v->shader->num_reserved_user_consts + + const_state->ubo_state.size / 16; unsigned ptrsz = ir3_pointer_size(compiler); if (const_state->num_ubos > 0) { diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c index 83b9a45ca4b..5ee39737016 100644 --- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c +++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c @@ -408,7 +408,7 @@ ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader_variant *v) assert(offset <= max_upload); offset += range_size; } - state->size = offset; + state->size = offset - v->shader->num_reserved_user_consts * 16; } bool
