diff options
author | Nicolai Haehnle <[email protected]> | 2008-07-12 11:11:59 +0200 |
---|---|---|
committer | Nicolai Haehnle <[email protected]> | 2008-07-12 11:11:59 +0200 |
commit | 8774fcd89acc9e180e0cb135bd62646f58cb623e (patch) | |
tree | 1c02214514ca568e9cc577ecad01d843b99b276a | |
parent | 11d711df360265f25dc5a96cc3a4c5a2d34f5b64 (diff) |
r300: Fix input register allocation in radeon_program_pair
When an input is marked in gl_program.InputsRead but is not actually read
in the final program (due to dead-code elimination or whatever), the order
of input registers must still match gl_program.InputsRead. This is done
even more explicitly now.
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_program_pair.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/r300/radeon_program_pair.c b/src/mesa/drivers/dri/r300/radeon_program_pair.c index 86180edcb5e..4eaac50412e 100644 --- a/src/mesa/drivers/dri/r300/radeon_program_pair.c +++ b/src/mesa/drivers/dri/r300/radeon_program_pair.c @@ -167,6 +167,15 @@ static struct pair_register_translation *get_register(struct pair_state *s, GLui } } +static void alloc_hw_reg(struct pair_state *s, GLuint file, GLuint index, GLuint hwindex) +{ + struct pair_register_translation *t = get_register(s, file, index); + ASSERT(!s->HwTemps[hwindex].RefCount); + ASSERT(!t->Allocated); + s->HwTemps[hwindex].RefCount = t->RefCount; + t->Allocated = 1; + t->HwIndex = hwindex; +} static GLuint get_hw_reg(struct pair_state *s, GLuint file, GLuint index) { @@ -190,9 +199,7 @@ static GLuint get_hw_reg(struct pair_state *s, GLuint file, GLuint index) return 0; } - s->HwTemps[hwindex].RefCount = t->RefCount; - t->Allocated = 1; - t->HwIndex = hwindex; + alloc_hw_reg(s, file, index, hwindex); return hwindex; } @@ -430,27 +437,28 @@ static void allocate_input_registers(struct pair_state *s) { GLuint InputsRead = s->Program->InputsRead; int i; + GLuint hwindex = 0; /* Texcoords come first */ for (i = 0; i < s->Ctx->Const.MaxTextureUnits; i++) { if (InputsRead & (FRAG_BIT_TEX0 << i)) - get_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_TEX0+i); + alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_TEX0+i, hwindex++); } InputsRead &= ~FRAG_BITS_TEX_ANY; /* fragment position treated as a texcoord */ if (InputsRead & FRAG_BIT_WPOS) - get_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_WPOS); + alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_WPOS, hwindex++); InputsRead &= ~FRAG_BIT_WPOS; /* Then primary colour */ if (InputsRead & FRAG_BIT_COL0) - get_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL0); + alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL0, hwindex++); InputsRead &= ~FRAG_BIT_COL0; /* Secondary color */ if (InputsRead & FRAG_BIT_COL1) - get_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL1); + alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL1, hwindex++); InputsRead &= ~FRAG_BIT_COL1; /* Anything else */ |