summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_vp_build.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl/t_vp_build.c')
-rw-r--r--src/mesa/tnl/t_vp_build.c71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 81266f3c8b..283782588a 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -33,11 +33,14 @@
#include "glheader.h"
#include "macros.h"
#include "enums.h"
+#include "program.h"
+#include "prog_instruction.h"
+#include "prog_parameter.h"
+#include "prog_print.h"
+#include "prog_statevars.h"
#include "t_context.h" /* NOTE: very light dependency on this */
#include "t_vp_build.h"
-#include "shader/program.h"
-#include "shader/program_instruction.h"
struct state_key {
unsigned light_global_enabled:1;
@@ -382,11 +385,14 @@ static struct ureg register_const4f( struct tnl_program *p,
{
GLfloat values[4];
GLint idx;
+ GLuint swizzle;
values[0] = s0;
values[1] = s1;
values[2] = s2;
values[3] = s3;
- idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
+ idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
+ &swizzle );
+ ASSERT(swizzle == SWIZZLE_NOOP);
return make_ureg(PROGRAM_STATE_VAR, idx);
}
@@ -630,14 +636,14 @@ static struct ureg get_eye_position( struct tnl_program *p )
p->eye_position = reserve_temp(p);
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX, modelview );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
+ 0, 0, modelview );
emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, modelview );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, modelview );
emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
}
@@ -665,8 +671,8 @@ static struct ureg get_eye_normal( struct tnl_program *p )
struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
struct ureg mvinv[3];
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
- STATE_MATRIX_INVTRANS, mvinv );
+ register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 2,
+ STATE_MATRIX_INVTRANS, 0, mvinv );
p->eye_normal = reserve_temp(p);
@@ -700,13 +706,13 @@ static void build_hpos( struct tnl_program *p )
struct ureg mvp[4];
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX, mvp );
+ register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3,
+ 0, 0, mvp );
emit_matrix_transform_vec4( p, hpos, mvp, pos );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, mvp );
+ register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, mvp );
emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
}
}
@@ -939,7 +945,7 @@ static void build_lighting( struct tnl_program *p )
*/
VPpli = register_param3(p, STATE_LIGHT, i,
STATE_POSITION_NORMALIZED);
- half = register_param3(p, STATE_LIGHT, i, STATE_HALF);
+ half = register_param3(p, STATE_LIGHT, i, STATE_HALF_VECTOR);
}
else {
struct ureg Ppli = register_param3(p, STATE_LIGHT, i,
@@ -1204,7 +1210,7 @@ static void build_texture_transform( struct tnl_program *p )
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- if (!(p->state->fragprog_inputs_read & (FRAG_BIT_TEX0<<i)))
+ if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i)))
continue;
if (p->state->unit[i].texgen_enabled ||
@@ -1294,13 +1300,13 @@ static void build_texture_transform( struct tnl_program *p )
out_texgen :
register_input(p, VERT_ATTRIB_TEX0+i));
if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX, texmat );
+ register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ 0, 0, texmat );
emit_matrix_transform_vec4( p, out, texmat, in );
}
else {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX_TRANSPOSE, texmat );
+ register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3,
+ STATE_MATRIX_TRANSPOSE, 0, texmat );
emit_transpose_matrix_transform_vec4( p, out, texmat, in );
}
}
@@ -1317,8 +1323,8 @@ static void build_texture_transform( struct tnl_program *p )
static void build_pointsize( struct tnl_program *p )
{
struct ureg eye = get_eye_position(p);
- struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
- struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
+ struct ureg state_size = register_param2(p, STATE_POINT, STATE_POINT_SIZE);
+ struct ureg state_attenuation = register_param2(p, STATE_POINT, STATE_POINT_ATTENUATION);
struct ureg out = register_output(p, VERT_RESULT_PSIZ);
struct ureg ut = get_temp(p);
@@ -1495,7 +1501,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
GLuint hash;
const struct gl_vertex_program *prev = ctx->VertexProgram._Current;
- if (ctx->VertexProgram._Enabled == GL_FALSE) {
+ if (!ctx->VertexProgram._Current) {
/* Grab all the relevent state and put it in a single structure:
*/
key = make_state_key(ctx);
@@ -1503,45 +1509,42 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
/* Look for an already-prepared program for this state:
*/
- ctx->_TnlProgram = (struct gl_vertex_program *)
+ ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
/* OK, we'll have to build a new one:
*/
- if (!ctx->_TnlProgram) {
+ if (!ctx->VertexProgram._TnlProgram) {
if (0)
_mesa_printf("Build new TNL program\n");
- ctx->_TnlProgram = (struct gl_vertex_program *)
+ ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
- create_new_program( key, ctx->_TnlProgram,
+ create_new_program( key, ctx->VertexProgram._TnlProgram,
ctx->Const.VertexProgram.MaxTemps );
if (ctx->Driver.ProgramStringNotify)
ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
- &ctx->_TnlProgram->Base );
+ &ctx->VertexProgram._TnlProgram->Base );
- cache_item(tnl->vp_cache, hash, key, ctx->_TnlProgram );
+ cache_item(tnl->vp_cache, hash, key, ctx->VertexProgram._TnlProgram );
}
else {
FREE(key);
if (0)
_mesa_printf("Found existing TNL program for key %x\n", hash);
}
- ctx->VertexProgram._Current = ctx->_TnlProgram;
- }
- else {
- ctx->VertexProgram._Current = ctx->VertexProgram.Current;
+ ctx->VertexProgram._Current = ctx->VertexProgram._TnlProgram;
}
/* Tell the driver about the change. Could define a new target for
* this?
*/
- if (ctx->VertexProgram._Current != prev &&
- ctx->Driver.BindProgram)
+ if (ctx->VertexProgram._Current != prev && ctx->Driver.BindProgram) {
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
(struct gl_program *) ctx->VertexProgram._Current);
+ }
}
void _tnl_ProgramCacheInit( GLcontext *ctx )