From 8623e599fc050e33a1e19bc7f5aac59bc7fa3ae3 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 10 May 2016 11:46:11 -0400 Subject: [PATCH] freedreno/ir3: size input/output arrays properly We index into these based on var->data.driver_location, which might have gaps (ie. two inputs, one w/ drvloc 0 and other 2). This shows up in (for example) 'bin/copyteximage 1D', but was only noticed recently due to additional asserts. Signed-off-by: Rob Clark --- .../drivers/freedreno/ir3/ir3_compiler_nir.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 34f1d9009c4..5f23272426e 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2148,11 +2148,21 @@ setup_output(struct ir3_compile *ctx, nir_variable *out) for (int i = 0; i < ncomp; i++) { unsigned idx = (n * 4) + i; - + compile_assert(ctx, idx < ctx->ir->noutputs); ctx->ir->outputs[idx] = create_immed(ctx->block, fui(0.0)); } } +static int +max_drvloc(struct exec_list *vars) +{ + int drvloc = -1; + nir_foreach_variable(var, vars) { + drvloc = MAX2(drvloc, (int)var->data.driver_location); + } + return drvloc; +} + static void emit_instructions(struct ir3_compile *ctx) { @@ -2167,8 +2177,9 @@ emit_instructions(struct ir3_compile *ctx) break; } - ninputs = exec_list_length(&ctx->s->inputs) * 4; - noutputs = exec_list_length(&ctx->s->outputs) * 4; + + ninputs = (max_drvloc(&ctx->s->inputs) + 1) * 4; + noutputs = (max_drvloc(&ctx->s->outputs) + 1) * 4; /* or vtx shaders, we need to leave room for sysvals: */ -- 2.30.2