[Mesa-dev] [PATCH 13/16] mesa: Remove the last REG_ALLOCATE_MAX_TEMPS user.
Eric Anholt
eric at anholt.net
Wed May 28 11:37:44 PDT 2014
---
src/mesa/program/prog_optimize.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c
index d76a15d..88dc177 100644
--- a/src/mesa/program/prog_optimize.c
+++ b/src/mesa/program/prog_optimize.c
@@ -33,12 +33,6 @@
#define MAX_LOOP_NESTING 50
-/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to
- * register allocate many temporary values into that small number of
- * temps. So allow large temporary indices coming into the register
- * allocator.
- */
-#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1)
static GLboolean dbg = GL_FALSE;
@@ -1286,7 +1280,7 @@ print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) {
static void
_mesa_simplify_cmp(struct gl_program * program)
{
- GLuint tempWrites[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLuint *tempWrites;
GLuint outputWrites[MAX_PROGRAM_OUTPUTS];
GLuint i;
@@ -1295,9 +1289,9 @@ _mesa_simplify_cmp(struct gl_program * program)
_mesa_print_program(program);
}
- for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
- tempWrites[i] = 0;
- }
+ tempWrites = calloc(program->NumTemporaries, sizeof(*tempWrites));
+ if (!tempWrites)
+ return;
for (i = 0; i < MAX_PROGRAM_OUTPUTS; i++) {
outputWrites[i] = 0;
@@ -1309,6 +1303,7 @@ _mesa_simplify_cmp(struct gl_program * program)
/* Give up if we encounter relative addressing or flow control. */
if (_mesa_is_flow_control_opcode(inst->Opcode) || inst->DstReg.RelAddr) {
+ free(tempWrites);
return;
}
@@ -1317,7 +1312,7 @@ _mesa_simplify_cmp(struct gl_program * program)
prevWriteMask = outputWrites[inst->DstReg.Index];
outputWrites[inst->DstReg.Index] |= inst->DstReg.WriteMask;
} else if (inst->DstReg.File == PROGRAM_TEMPORARY) {
- assert(inst->DstReg.Index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
+ assert(inst->DstReg.Index < program->NumTemporaries);
prevWriteMask = tempWrites[inst->DstReg.Index];
tempWrites[inst->DstReg.Index] |= inst->DstReg.WriteMask;
} else {
@@ -1350,6 +1345,7 @@ _mesa_simplify_cmp(struct gl_program * program)
fprintf(stderr, "Optimize: End reads without writes\n");
_mesa_print_program(program);
}
+ free(tempWrites);
}
/**
--
2.0.0.rc2
More information about the mesa-dev
mailing list