Mesa (master): freedreno/ir3: Fix sizing of the inputs/outputs array.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 23 19:13:03 UTC 2020


Module: Mesa
Branch: master
Commit: 5593d80a2c0db362e80c7733bc4a3f2899c288bf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5593d80a2c0db362e80c7733bc4a3f2899c288bf

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Apr 21 15:43:03 2020 -0700

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 <cwabbott0 at gmail.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4670>

---

 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);
 



More information about the mesa-commit mailing list