diff options
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_vs_tnl.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_tnl.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c index b69be350a9..2caa020e61 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c +++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c @@ -404,7 +404,7 @@ static struct ureg register_const4f( struct tnl_program *p, values[3] = s3; idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle); - /* XXX what about swizzle? */ + assert(swizzle == SWIZZLE_NOOP); /* Need to handle swizzle in reg setup */ return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -524,10 +524,13 @@ static void emit_op3fn(struct tnl_program *p, GLuint nr = p->program->Base.NumInstructions++; if (nr >= p->nr_instructions) { + int new_nr_instructions = p->nr_instructions * 2; + p->program->Base.Instructions = _mesa_realloc(p->program->Base.Instructions, sizeof(struct prog_instruction) * p->nr_instructions, - sizeof(struct prog_instruction) * (p->nr_instructions *= 2)); + sizeof(struct prog_instruction) * new_nr_instructions); + p->nr_instructions = new_nr_instructions; } { @@ -1000,13 +1003,19 @@ static void build_lighting( struct tnl_program *p ) STATE_POSITION); struct ureg V = get_eye_position(p); struct ureg dist = get_temp(p); + struct ureg tmpPpli = get_temp(p); VPpli = get_temp(p); half = get_temp(p); + + /* In homogeneous object coordinates + */ + emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); + emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); /* Calulate VPpli vector */ - emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); + emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); /* Normalize VPpli. The dist value also used in * attenuation below. @@ -1038,6 +1047,7 @@ static void build_lighting( struct tnl_program *p ) emit_normalize_vec3(p, half, half); release_temp(p, dist); + release_temp(p, tmpPpli); } /* Calculate dot products: @@ -1162,6 +1172,11 @@ static void build_fog( struct tnl_program *p ) } else { input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); + if (p->state->fog_option && + p->state->tnl_do_vertex_fog) + input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); + else + input = register_input(p, VERT_ATTRIB_FOG); } if (p->state->fog_option && @@ -1566,7 +1581,7 @@ static GLuint hash_key( struct state_key *key ) return hash; } -static void update_tnl_program( struct brw_context *brw ) +static void prepare_tnl_program( struct brw_context *brw ) { GLcontext *ctx = &brw->intel.ctx; struct state_key key; @@ -1574,7 +1589,7 @@ static void update_tnl_program( struct brw_context *brw ) struct gl_vertex_program *old = brw->tnl_program; /* _NEW_PROGRAM */ - if (brw->attribs.VertexProgram->_Enabled) + if (brw->attribs.VertexProgram->_Current) return; /* Grab all the relevent state and put it in a single structure: @@ -1608,6 +1623,7 @@ static void update_tnl_program( struct brw_context *brw ) if (old != brw->tnl_program) brw->state.dirty.brw |= BRW_NEW_TNL_PROGRAM; + return; } /* Note: See brw_draw.c - the vertex program must not rely on @@ -1621,24 +1637,25 @@ const struct brw_tracked_state brw_tnl_vertprog = { _NEW_FOG | _NEW_HINT | _NEW_POINT | - _NEW_TEXTURE), + _NEW_TEXTURE | + _NEW_TEXTURE_MATRIX), .brw = (BRW_NEW_FRAGMENT_PROGRAM | BRW_NEW_INPUT_VARYING), .cache = 0 }, - .update = update_tnl_program + .prepare = prepare_tnl_program }; -static void update_active_vertprog( struct brw_context *brw ) +static void prepare_active_vertprog( struct brw_context *brw ) { const struct gl_vertex_program *prev = brw->vertex_program; /* NEW_PROGRAM */ - if (brw->attribs.VertexProgram->_Enabled) { - brw->vertex_program = brw->attribs.VertexProgram->Current; + if (brw->attribs.VertexProgram->_Current) { + brw->vertex_program = brw->attribs.VertexProgram->_Current; } else { /* BRW_NEW_TNL_PROGRAM */ @@ -1657,7 +1674,7 @@ const struct brw_tracked_state brw_active_vertprog = { .brw = BRW_NEW_TNL_PROGRAM, .cache = 0 }, - .update = update_active_vertprog + .prepare = prepare_active_vertprog }; |