summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/prog_optimize.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-07-27 11:45:27 -0700
committerEric Anholt <[email protected]>2010-07-27 11:45:27 -0700
commit8bbdf6e7cdfc3265439761a06eea79627f4ee2fa (patch)
tree48c6ebf2c7fdbebb4af6697e2fad059eeb9cb543 /src/mesa/program/prog_optimize.c
parent85cd64ee170e578317a6aa41d824314550a318ac (diff)
mesa: Allow large temporary indices coming into the temporary reg allocator.
This gets glsl-vs-raytrace, glsl-fs-raytrace running on the new compiler.
Diffstat (limited to 'src/mesa/program/prog_optimize.c')
-rw-r--r--src/mesa/program/prog_optimize.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c
index bd120b8643c..457ace14c6b 100644
--- a/src/mesa/program/prog_optimize.c
+++ b/src/mesa/program/prog_optimize.c
@@ -34,7 +34,12 @@
#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;
@@ -154,8 +159,8 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[])
static void
_mesa_consolidate_registers(struct gl_program *prog)
{
- GLboolean tempUsed[MAX_PROGRAM_TEMPS];
- GLint tempMap[MAX_PROGRAM_TEMPS];
+ GLboolean tempUsed[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLint tempMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
GLuint tempMax = 0, i;
if (dbg) {
@@ -164,7 +169,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
memset(tempUsed, 0, sizeof(tempUsed));
- for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
tempMap[i] = -1;
}
@@ -176,7 +181,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
for (j = 0; j < numSrc; j++) {
if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
const GLuint index = inst->SrcReg[j].Index;
- ASSERT(index < MAX_PROGRAM_TEMPS);
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
tempUsed[index] = GL_TRUE;
tempMax = MAX2(tempMax, index);
break;
@@ -184,7 +189,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
}
if (inst->DstReg.File == PROGRAM_TEMPORARY) {
const GLuint index = inst->DstReg.Index;
- ASSERT(index < MAX_PROGRAM_TEMPS);
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
tempUsed[index] = GL_TRUE;
tempMax = MAX2(tempMax, index);
}
@@ -225,7 +230,7 @@ _mesa_consolidate_registers(struct gl_program *prog)
static void
_mesa_remove_dead_code(struct gl_program *prog)
{
- GLboolean tempRead[MAX_PROGRAM_TEMPS][4];
+ GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4];
GLboolean *removeInst; /* per-instruction removal flag */
GLuint i, rem = 0, comp;
@@ -250,7 +255,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
const GLuint index = inst->SrcReg[j].Index;
GLuint read_mask;
- ASSERT(index < MAX_PROGRAM_TEMPS);
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
read_mask = get_src_arg_mask(inst, j);
if (inst->SrcReg[j].RelAddr) {
@@ -286,7 +291,7 @@ _mesa_remove_dead_code(struct gl_program *prog)
/* check dst reg */
if (inst->DstReg.File == PROGRAM_TEMPORARY) {
const GLuint index = inst->DstReg.Index;
- ASSERT(index < MAX_PROGRAM_TEMPS);
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
if (inst->DstReg.RelAddr) {
if (dbg)
@@ -642,7 +647,7 @@ struct interval
struct interval_list
{
GLuint Num;
- struct interval Intervals[MAX_PROGRAM_TEMPS];
+ struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
};
@@ -754,7 +759,7 @@ update_interval(GLint intBegin[], GLint intEnd[],
}
}
- ASSERT(index < MAX_PROGRAM_TEMPS);
+ ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
if (intBegin[index] == -1) {
ASSERT(intEnd[index] == -1);
intBegin[index] = intEnd[index] = ic;
@@ -771,14 +776,14 @@ update_interval(GLint intBegin[], GLint intEnd[],
GLboolean
_mesa_find_temp_intervals(const struct prog_instruction *instructions,
GLuint numInstructions,
- GLint intBegin[MAX_PROGRAM_TEMPS],
- GLint intEnd[MAX_PROGRAM_TEMPS])
+ GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS],
+ GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
{
struct loop_info loopStack[MAX_LOOP_NESTING];
GLuint loopStackDepth = 0;
GLuint i;
- for (i = 0; i < MAX_PROGRAM_TEMPS; i++){
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
intBegin[i] = intEnd[i] = -1;
}
@@ -833,7 +838,8 @@ static GLboolean
find_live_intervals(struct gl_program *prog,
struct interval_list *liveIntervals)
{
- GLint intBegin[MAX_PROGRAM_TEMPS], intEnd[MAX_PROGRAM_TEMPS];
+ GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
GLuint i;
/*
@@ -853,7 +859,7 @@ find_live_intervals(struct gl_program *prog,
/* Build live intervals list from intermediate arrays */
liveIntervals->Num = 0;
- for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
if (intBegin[i] >= 0) {
struct interval inv;
inv.Reg = i;
@@ -889,10 +895,10 @@ find_live_intervals(struct gl_program *prog,
/** Scan the array of used register flags to find free entry */
static GLint
-alloc_register(GLboolean usedRegs[MAX_PROGRAM_TEMPS])
+alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
{
GLuint k;
- for (k = 0; k < MAX_PROGRAM_TEMPS; k++) {
+ for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) {
if (!usedRegs[k]) {
usedRegs[k] = GL_TRUE;
return k;
@@ -914,8 +920,8 @@ static void
_mesa_reallocate_registers(struct gl_program *prog)
{
struct interval_list liveIntervals;
- GLint registerMap[MAX_PROGRAM_TEMPS];
- GLboolean usedRegs[MAX_PROGRAM_TEMPS];
+ GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
+ GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
GLuint i;
GLint maxTemp = -1;
@@ -924,7 +930,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
_mesa_print_program(prog);
}
- for (i = 0; i < MAX_PROGRAM_TEMPS; i++){
+ for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
registerMap[i] = -1;
usedRegs[i] = GL_FALSE;
}