aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-05-10 11:46:11 -0400
committerRob Clark <[email protected]>2016-05-10 13:17:27 -0400
commit8623e599fc050e33a1e19bc7f5aac59bc7fa3ae3 (patch)
treed43a27dab8bc063aea4a4d1ff2d86cd29df7bb5f /src/gallium/drivers/freedreno
parent2483a9a08cae6935e84fab3580ed285c6c68fb75 (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c17
1 files 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:
*/