From 5593d80a2c0db362e80c7733bc4a3f2899c288bf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 21 Apr 2020 15:43:03 -0700 Subject: [PATCH] freedreno/ir3: Fix sizing of the inputs/outputs array. If you have a struct, the var's base driver location is not the last driver location that will be accessed in that var. We have a shader struct member with this number for us, already. Fixes overflows in: dEQP-GLES31.functional.program_interface_query.program_output.type.interface_blocks.out.named_block_explicit_location.struct.mat3x2 Reviewed-by: Connor Abbott Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/freedreno/ir3/ir3_compiler_nir.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index fad611c9b5f..553b772b8ec 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -3236,24 +3236,13 @@ setup_output(struct ir3_context *ctx, nir_variable *out) } } -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_context *ctx) { nir_function_impl *fxn = nir_shader_get_entrypoint(ctx->s); - ctx->ninputs = (max_drvloc(&ctx->s->inputs) + 1) * 4; - ctx->noutputs = (max_drvloc(&ctx->s->outputs) + 1) * 4; - + ctx->ninputs = ctx->s->num_inputs * 4; + ctx->noutputs = ctx->s->num_outputs * 4; ctx->inputs = rzalloc_array(ctx, struct ir3_instruction *, ctx->ninputs); ctx->outputs = rzalloc_array(ctx, struct ir3_instruction *, ctx->noutputs); -- 2.30.2