summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r300/r300_vertexprog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_vertexprog.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertexprog.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c
index 2492a4a3a0a..2ff92e13289 100644
--- a/src/mesa/drivers/dri/r300/r300_vertexprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c
@@ -960,26 +960,23 @@ static void position_invariant(struct gl_program *prog)
static void insert_wpos(struct r300_vertex_program *vp,
struct gl_program *prog,
- GLint pos)
+ GLuint temp_index)
{
GLint tokens[6] = { STATE_INTERNAL, STATE_R300_WINDOW_DIMENSION, 0, 0, 0, 0 };
struct prog_instruction *vpi;
struct prog_instruction *vpi_insert;
- GLuint temp_index;
GLuint window_index;
int i = 0;
vpi = malloc((prog->NumInstructions + 5) * sizeof(struct prog_instruction));
- memcpy(vpi, prog->Instructions, (pos+1) * sizeof(struct prog_instruction));
+ /* all but END */
+ memcpy(vpi, prog->Instructions, (prog->NumInstructions - 1) * sizeof(struct prog_instruction));
+ /* END */
+ memcpy(&vpi[prog->NumInstructions + 4], &prog->Instructions[prog->NumInstructions - 1],
+ sizeof(struct prog_instruction));
- vpi_insert = &vpi[pos];
-
- /* make a copy before outputting VERT_RESULT_HPOS */
- vpi_insert->DstReg.File = vpi_insert->SrcReg[2].File;
- vpi_insert->DstReg.Index = temp_index = vpi_insert->SrcReg[2].Index;
-
- vpi_insert++;
+ vpi_insert = &vpi[prog->NumInstructions - 1];
memset(vpi_insert, 0, 5 * sizeof(struct prog_instruction));
vpi_insert[i].Opcode = OPCODE_MOV;
@@ -1062,8 +1059,6 @@ static void insert_wpos(struct r300_vertex_program *vp,
vpi_insert[i].SrcReg[1].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ONE, SWIZZLE_ONE);
i++;
- memcpy(&vpi_insert[i], &prog->Instructions[pos+1], (prog->NumInstructions-(pos+1)) * sizeof(struct prog_instruction));
-
free(prog->Instructions);
prog->Instructions = vpi;
@@ -1078,16 +1073,18 @@ static void pos_as_texcoord(struct r300_vertex_program *vp,
struct gl_program *prog)
{
struct prog_instruction *vpi;
- int pos = 0;
-
- for(vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++, pos++){
+ GLuint tempregi = prog->NumTemporaries;
+ /* should do something else if no temps left... */
+ prog->NumTemporaries++;
+
+ for(vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++){
if( vpi->DstReg.File == PROGRAM_OUTPUT &&
vpi->DstReg.Index == VERT_RESULT_HPOS ){
- insert_wpos(vp, prog, pos);
- break;
+ vpi->DstReg.File = PROGRAM_TEMPORARY;
+ vpi->DstReg.Index = tempregi;
}
}
-
+ insert_wpos(vp, prog, tempregi);
}
static struct r300_vertex_program *build_program(struct r300_vertex_program_key *wanted_key,
@@ -1101,8 +1098,9 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
vp->wpos_idx = wpos_idx;
- if(mesa_vp->IsPositionInvariant)
+ if(mesa_vp->IsPositionInvariant) {
position_invariant(&mesa_vp->Base);
+ }
if(wpos_idx > -1)
pos_as_texcoord(vp, &mesa_vp->Base);
@@ -1158,6 +1156,10 @@ void r300_select_vertex_shader(r300ContextPtr r300)
wanted_key.OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
+ if(vpc->mesa_program.IsPositionInvariant) {
+ /* we wan't position don't we ? */
+ wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
+ }
for (vp = vpc->progs; vp; vp = vp->next)
if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) == 0) {
@@ -1170,6 +1172,5 @@ void r300_select_vertex_shader(r300ContextPtr r300)
vp = build_program(&wanted_key, &vpc->mesa_program, wpos_idx);
vp->next = vpc->progs;
vpc->progs = vp;
-
r300->selected_vp = vp;
}