From a328e469d328f8b6fd5afdfc21d576fa1a2c43fc Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 13 Dec 2006 14:58:13 -0700 Subject: Checkpoint work for new GLSL compiler back-end. Among changes: Remove ctx->FragmentProgram._Active Remove _UseTexEnvProgram Move _MaintainTnlProgram, _MaintainTexEnvProgram, _TexEnvProgram and _TnlProgram fields. Remove/disable old GLSL interpreter code. --- src/mesa/tnl/t_context.c | 11 +- src/mesa/tnl/t_pipeline.c | 5 +- src/mesa/tnl/t_vb_arbprogram.c | 54 ++--- src/mesa/tnl/t_vb_arbprogram.h | 31 ++- src/mesa/tnl/t_vb_arbshader.c | 455 ++++++++++++++++++++++------------------- src/mesa/tnl/t_vb_cull.c | 5 +- src/mesa/tnl/t_vb_fog.c | 5 +- src/mesa/tnl/t_vb_light.c | 10 +- src/mesa/tnl/t_vb_normals.c | 7 +- src/mesa/tnl/t_vb_points.c | 5 +- src/mesa/tnl/t_vb_program.c | 23 ++- src/mesa/tnl/t_vb_texgen.c | 10 +- src/mesa/tnl/t_vb_texmat.c | 5 +- src/mesa/tnl/t_vb_vertex.c | 5 +- src/mesa/tnl/t_vp_build.c | 28 +-- src/mesa/tnl/t_vtx_eval.c | 3 +- 16 files changed, 346 insertions(+), 316 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 154780cc97..b07f90af02 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -86,7 +86,7 @@ _tnl_CreateContext( GLcontext *ctx ) _tnl_array_init( ctx ); _tnl_vtx_init( ctx ); - if (ctx->_MaintainTnlProgram) { + if (ctx->VertexProgram._MaintainTnlProgram) { _tnl_ProgramCacheInit( ctx ); _tnl_install_pipeline( ctx, _tnl_vp_pipeline ); } else { @@ -136,7 +136,7 @@ _tnl_DestroyContext( GLcontext *ctx ) _tnl_destroy_pipeline( ctx ); _ae_destroy_context( ctx ); - if (ctx->_MaintainTnlProgram) + if (ctx->VertexProgram._MaintainTnlProgram) _tnl_ProgramCacheDestroy( ctx ); FREE(tnl); @@ -183,7 +183,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) } if (ctx->Fog.Enabled || - (ctx->FragmentProgram._Active && + (ctx->FragmentProgram._Current && (ctx->FragmentProgram._Current->FogOption != GL_NONE || ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC))) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); @@ -199,8 +199,13 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled)) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); +#if NEW_SLANG + RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, + _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); +#else if (ctx->ShaderObjects._VertexShaderPresent || ctx->ShaderObjects._FragmentShaderPresent) RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); +#endif } diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index 2efe701a80..a50a3f0f2f 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -132,7 +132,7 @@ void _tnl_run_pipeline( GLcontext *ctx ) * (ie const or non-const). */ if (check_input_changes( ctx ) || tnl->pipeline.new_state) { - if (ctx->_MaintainTnlProgram) + if (ctx->VertexProgram._MaintainTnlProgram) _tnl_UpdateFixedFunctionProgram( ctx ); for (i = 0; i < tnl->pipeline.nr_stages ; i++) { @@ -207,9 +207,6 @@ const struct tnl_pipeline_stage *_tnl_default_pipeline[] = { #if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program) &_tnl_arb_vertex_program_stage, &_tnl_vertex_program_stage, -#endif -#if FEATURE_ARB_vertex_shader - &_tnl_arb_vertex_shader_stage, #endif &_tnl_render_stage, NULL diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index bf4c1d5223..b7975f3a4e 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -37,6 +37,7 @@ #include "arbprogparse.h" #include "light.h" #include "program.h" +#include "programopt.h" #include "math/m_matrix.h" #include "t_context.h" #include "t_pipeline.h" @@ -292,7 +293,7 @@ static void do_EX2( struct arb_vp_machine *m, union instruction op ) GLfloat *result = m->File[0][op.alu.dst]; const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0]; - result[0] = (GLfloat)ApproxExp2(arg0[0]); + result[0] = ApproxExp2(arg0[0]); PUFF(result); } @@ -566,7 +567,7 @@ static void print_reg( GLuint file, GLuint reg ) _mesa_printf("TMP%d", reg - REG_TMP0); else if (reg >= REG_IN0 && reg <= REG_IN31) _mesa_printf("IN%d", reg - REG_IN0); - else if (reg >= REG_OUT0 && reg <= REG_OUT14) + else if (reg >= REG_OUT0 && reg <= REG_OUT23) _mesa_printf("OUT%d", reg - REG_OUT0); else if (reg == REG_ADDR) _mesa_printf("ADDR"); @@ -714,6 +715,7 @@ _tnl_disassem_vba_insn( union instruction op ) static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union instruction) = { + do_NOP, do_ABS, do_ADD, do_NOP,/*ARA*/ @@ -853,6 +855,7 @@ static struct reg cvp_load_reg( struct compilation *cp, return reg; case PROGRAM_STATE_VAR: + case PROGRAM_CONSTANT: reg = cvp_make_reg(FILE_STATE_PARAM, index); if (rel) return cvp_emit_rel(cp, reg, tmpreg); @@ -1058,6 +1061,16 @@ static void compile_vertex_program( struct gl_vertex_program *program, struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program); GLuint i; +#if 1 + if (!program->IsNVProgram && program->IsPositionInvariant) { + printf("Adding MVP code\n"); + if (!program->Base.Parameters) + program->Base.Parameters = _mesa_new_parameter_list(); + _mesa_insert_mvp_code(NULL, program); + program->IsPositionInvariant = 0; + } +#endif + if (program->TnlData) free_tnl_data( program ); @@ -1182,6 +1195,7 @@ do_ndc_cliptest(GLcontext *ctx, struct arb_vp_machine *m) /* Test userclip planes. This contributes to VB->ClipMask. */ + /** XXX NEW_SLANG _Enabled ??? */ if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled || ctx->VertexProgram.Current->IsPositionInvariant)) { userclip( ctx, @@ -1221,21 +1235,14 @@ static INLINE void call_func( struct tnl_compiled_program *p, static GLboolean run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) { - const struct gl_vertex_program *program; + const struct gl_vertex_program *program = ctx->VertexProgram._Current; struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct arb_vp_machine *m = ARB_VP_MACHINE(stage); struct tnl_compiled_program *p; GLuint i, j; GLbitfield outputs; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - program = ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : NULL; - if (!program && ctx->_MaintainTnlProgram) { - program = ctx->_TnlProgram; - } - if (!program || program->IsNVProgram) + if (!program) return GL_TRUE; if (program->Base.Parameters) { @@ -1299,12 +1306,13 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) /* If the program is position invariant, multiply the input position * by the MVP matrix and store in the vertex position result register. */ +#if 0 if (program->IsPositionInvariant) { TRANSFORM_POINT( m->File[0][REG_OUT0+0], ctx->_ModelProjectMatrix.m, m->File[0][REG_IN0+0]); } - +#endif for (j = 0; j < m->nr_outputs; j++) { GLuint idx = REG_OUT0 + m->output[j].idx; m->output[j].data[0] = m->File[0][idx][0]; @@ -1370,6 +1378,14 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) } } + for (i = 0; i < ctx->Const.MaxVarying; i++) { + if (outputs & (1 << (VERT_RESULT_VAR0 + i))) { + /* Note: varying results get put into the generic attributes */ + VB->AttribPtr[VERT_ATTRIB_GENERIC0+i] + = &m->attribs[VERT_RESULT_VAR0 + i]; + } + } + #if 0 for (i = 0; i < VB->Count; i++) { printf("Out %d: %f %f %f %f %f %f %f %f\n", i, @@ -1394,15 +1410,7 @@ static void validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage ) { struct arb_vp_machine *m = ARB_VP_MACHINE(stage); - struct gl_vertex_program *program; - - if (ctx->ShaderObjects._VertexShaderPresent) - return; - - program = (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : 0); - if (!program && ctx->_MaintainTnlProgram) { - program = ctx->_TnlProgram; - } + struct gl_vertex_program *program = ctx->VertexProgram._Current; if (program) { if (!program->TnlData) @@ -1472,7 +1480,7 @@ static GLboolean init_vertex_program( GLcontext *ctx, _mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 ); m->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 ); - if (ctx->_MaintainTnlProgram) + if (ctx->VertexProgram._MaintainTnlProgram) _mesa_allow_light_in_model( ctx, GL_FALSE ); m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */ @@ -1529,7 +1537,7 @@ const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage = void _tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program) { - if (target == GL_VERTEX_PROGRAM_ARB) { + if (program->Target == GL_VERTEX_PROGRAM_ARB) { /* free any existing tnl data hanging off the program */ struct gl_vertex_program *vprog = (struct gl_vertex_program *) program; if (vprog->TnlData) { diff --git a/src/mesa/tnl/t_vb_arbprogram.h b/src/mesa/tnl/t_vb_arbprogram.h index 6de8dca328..1bec2a411e 100644 --- a/src/mesa/tnl/t_vb_arbprogram.h +++ b/src/mesa/tnl/t_vb_arbprogram.h @@ -56,6 +56,22 @@ #define REG_TMP0 5 #define REG_TMP11 16 #define REG_OUT0 17 +#define REG_OUT23 40 +#define REG_IN0 41 +#define REG_IN31 72 +#define REG_ID 73 /* 0,0,0,1 */ +#define REG_ONES 74 /* 1,1,1,1 */ +#define REG_SWZ 75 /* 1,-1,0,0 */ +#define REG_NEG 76 /* -1,-1,-1,-1 */ +#define REG_LIT 77 /* 1,0,0,1 */ +#define REG_LIT2 78 /* 1,0,0,1 */ +#define REG_SCRATCH 79 /* internal temporary. XXX we can't actually use this because 70 doesn't fit in the 5-bit 'dst' instruction field! */ +#define REG_UNDEF 127 /* special case - never used */ +#define REG_MAX 128 +#define REG_INVALID ~0 + + +#if 0 #define REG_OUT14 31 #define REG_IN0 32 #define REG_IN31 63 @@ -69,6 +85,7 @@ #define REG_UNDEF 127 /* special case - never used */ #define REG_MAX 128 #define REG_INVALID ~0 +#endif /* ARB_vp instructions are broken down into one or more of the * following micro-instructions, each representable in a 64 bit packed @@ -76,16 +93,16 @@ */ struct reg { GLuint file:2; - GLuint idx:7; + GLuint idx:8; }; union instruction { struct { GLuint opcode:7; - GLuint dst:5; + GLuint dst:6; GLuint file0:2; - GLuint idx0:7; + GLuint idx0:8; GLuint file1:2; GLuint idx1:7; GLuint pad:2; @@ -94,18 +111,18 @@ union instruction { struct { GLuint opcode:7; - GLuint dst:5; + GLuint dst:6; GLuint file0:2; - GLuint idx0:7; + GLuint idx0:8; GLuint neg:4; GLuint swz:12; /* xyzw01 */ } rsw; struct { GLuint opcode:7; - GLuint dst:5; + GLuint dst:6; GLuint file:2; - GLuint idx:7; + GLuint idx:8; GLuint mask:4; GLuint pad:7; GLuint pad2; diff --git a/src/mesa/tnl/t_vb_arbshader.c b/src/mesa/tnl/t_vb_arbshader.c index 13aa3ea910..6d59114657 100644 --- a/src/mesa/tnl/t_vb_arbshader.c +++ b/src/mesa/tnl/t_vb_arbshader.c @@ -38,264 +38,295 @@ typedef struct { - GLvector4f outputs[VERT_RESULT_MAX]; - GLvector4f varyings[MAX_VARYING_VECTORS]; - GLvector4f ndc_coords; - GLubyte *clipmask; - GLubyte ormask; - GLubyte andmask; + GLvector4f outputs[VERT_RESULT_MAX]; + GLvector4f varyings[MAX_VARYING_VECTORS]; + GLvector4f ndc_coords; + GLubyte *clipmask; + GLubyte ormask; + GLubyte andmask; } arbvs_stage_data; #define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr) -static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage) +static GLboolean +construct_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *vb = &tnl->vb; - arbvs_stage_data *store; - GLuint size = vb->Size; - GLuint i; - - stage->privatePtr = _mesa_malloc (sizeof (arbvs_stage_data)); - store = ARBVS_STAGE_DATA(stage); - if (store == NULL) - return GL_FALSE; - - for (i = 0; i < VERT_RESULT_MAX; i++) - { - _mesa_vector4f_alloc (&store->outputs[i], 0, size, 32); - store->outputs[i].size = 4; - } - for (i = 0; i < MAX_VARYING_VECTORS; i++) - { - _mesa_vector4f_alloc (&store->varyings[i], 0, size, 32); - store->varyings[i].size = 4; - } - _mesa_vector4f_alloc (&store->ndc_coords, 0, size, 32); - store->clipmask = (GLubyte *) ALIGN_MALLOC (size, 32); - - return GL_TRUE; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *vb = &tnl->vb; + arbvs_stage_data *store; + GLuint size = vb->Size; + GLuint i; + + stage->privatePtr = _mesa_malloc(sizeof(arbvs_stage_data)); + store = ARBVS_STAGE_DATA(stage); + if (store == NULL) + return GL_FALSE; + + for (i = 0; i < VERT_RESULT_MAX; i++) { + _mesa_vector4f_alloc(&store->outputs[i], 0, size, 32); + store->outputs[i].size = 4; + } + for (i = 0; i < MAX_VARYING_VECTORS; i++) { + _mesa_vector4f_alloc(&store->varyings[i], 0, size, 32); + store->varyings[i].size = 4; + } + _mesa_vector4f_alloc(&store->ndc_coords, 0, size, 32); + store->clipmask = (GLubyte *) ALIGN_MALLOC(size, 32); + + return GL_TRUE; } -static void destruct_arb_vertex_shader (struct tnl_pipeline_stage *stage) +static void +destruct_arb_vertex_shader(struct tnl_pipeline_stage *stage) { - arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); - - if (store != NULL) - { - GLuint i; - - for (i = 0; i < VERT_RESULT_MAX; i++) - _mesa_vector4f_free (&store->outputs[i]); - for (i = 0; i < MAX_VARYING_VECTORS; i++) - _mesa_vector4f_free (&store->varyings[i]); - _mesa_vector4f_free (&store->ndc_coords); - ALIGN_FREE (store->clipmask); - - _mesa_free (store); - stage->privatePtr = NULL; - } + arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); + + if (store != NULL) { + GLuint i; + + for (i = 0; i < VERT_RESULT_MAX; i++) + _mesa_vector4f_free(&store->outputs[i]); + for (i = 0; i < MAX_VARYING_VECTORS; i++) + _mesa_vector4f_free(&store->varyings[i]); + _mesa_vector4f_free(&store->ndc_coords); + ALIGN_FREE(store->clipmask); + + _mesa_free(store); + stage->privatePtr = NULL; + } } -static void validate_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage) +static void +validate_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) { } -static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, - struct vertex_buffer *vb) +static GLvoid +fetch_input_float(struct gl2_program_intf **pro, GLuint index, GLuint attr, + GLuint i, struct vertex_buffer *vb) { - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint stride = vb->AttribPtr[attr]->stride; + const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; + const GLuint stride = vb->AttribPtr[attr]->stride; GLfloat *data = (GLfloat *) (ptr + stride * i); - (**pro).UpdateFixedAttrib (pro, index, data, 0, sizeof (GLfloat), GL_TRUE); + (**pro).UpdateFixedAttrib(pro, index, data, 0, sizeof(GLfloat), GL_TRUE); } -static GLvoid fetch_input_vec3 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, - struct vertex_buffer *vb) +static GLvoid +fetch_input_vec3(struct gl2_program_intf **pro, GLuint index, GLuint attr, + GLuint i, struct vertex_buffer *vb) { - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint stride = vb->AttribPtr[attr]->stride; + const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; + const GLuint stride = vb->AttribPtr[attr]->stride; GLfloat *data = (GLfloat *) (ptr + stride * i); - (**pro).UpdateFixedAttrib (pro, index, data, 0, 3 * sizeof (GLfloat), GL_TRUE); + (**pro).UpdateFixedAttrib(pro, index, data, 0, 3 * sizeof(GLfloat), + GL_TRUE); } -static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, - struct vertex_buffer *vb) +static void +fetch_input_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr, + GLuint i, struct vertex_buffer *vb) { - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint size = vb->AttribPtr[attr]->size; - const GLuint stride = vb->AttribPtr[attr]->stride; - const GLfloat *data = (const GLfloat *) (ptr + stride * i); - GLfloat vec[4]; - - switch (size) - { - case 2: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = 0.0f; - vec[3] = 1.0f; - break; - case 3: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = data[2]; - vec[3] = 1.0f; - break; - case 4: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = data[2]; - vec[3] = data[3]; - break; - } - (**pro).UpdateFixedAttrib (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE); + const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; + const GLuint size = vb->AttribPtr[attr]->size; + const GLuint stride = vb->AttribPtr[attr]->stride; + const GLfloat *data = (const GLfloat *) (ptr + stride * i); + GLfloat vec[4]; + + switch (size) { + case 2: + vec[0] = data[0]; + vec[1] = data[1]; + vec[2] = 0.0f; + vec[3] = 1.0f; + break; + case 3: + vec[0] = data[0]; + vec[1] = data[1]; + vec[2] = data[2]; + vec[3] = 1.0f; + break; + case 4: + vec[0] = data[0]; + vec[1] = data[1]; + vec[2] = data[2]; + vec[3] = data[3]; + break; + } + (**pro).UpdateFixedAttrib(pro, index, vec, 0, 4 * sizeof(GLfloat), + GL_TRUE); } static GLvoid -fetch_gen_attrib (struct gl2_program_intf **pro, GLuint index, GLuint i, struct vertex_buffer *vb) +fetch_gen_attrib(struct gl2_program_intf **pro, GLuint index, GLuint i, + struct vertex_buffer *vb) { const GLuint attr = _TNL_ATTRIB_GENERIC0 + index; const GLubyte *ptr = (const GLubyte *) (vb->AttribPtr[attr]->data); const GLuint stride = vb->AttribPtr[attr]->stride; const GLfloat *data = (const GLfloat *) (ptr + stride * i); - (**pro).WriteAttrib (pro, index, data); + (**pro).WriteAttrib(pro, index, data); } -static GLvoid fetch_output_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, - arbvs_stage_data *store) +static GLvoid +fetch_output_float(struct gl2_program_intf **pro, GLuint index, GLuint attr, + GLuint i, arbvs_stage_data * store) { - (**pro).UpdateFixedAttrib (pro, index, &store->outputs[attr].data[i], 0, sizeof (GLfloat), - GL_FALSE); + (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], 0, + sizeof(GLfloat), GL_FALSE); } -static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, - GLuint offset, arbvs_stage_data *store) +static void +fetch_output_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr, + GLuint i, GLuint offset, arbvs_stage_data * store) { - (**pro).UpdateFixedAttrib (pro, index, &store->outputs[attr].data[i], offset, - 4 * sizeof (GLfloat), GL_FALSE); + (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], + offset, 4 * sizeof(GLfloat), GL_FALSE); } -static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage) +static GLboolean +run_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *vb = &tnl->vb; - arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); - struct gl2_program_intf **pro; - GLsizei i, j; - - if (!ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - pro = ctx->ShaderObjects.CurrentProgram; - (**pro).UpdateFixedUniforms (pro); - - for (i = 0; i < vb->Count; i++) - { - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb); - fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb); - fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb); - fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb); + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *vb = &tnl->vb; + arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); + struct gl2_program_intf **pro; + GLsizei i, j; + +#if 00 + if (!ctx->ShaderObjects._VertexShaderPresent) + return GL_TRUE; +#else + return GL_TRUE; +#endif + + pro = ctx->ShaderObjects.CurrentProgram; + (**pro).UpdateFixedUniforms(pro); + + for (i = 0; i < vb->Count; i++) { + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, + vb); + fetch_input_vec3(pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, + vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, + vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, + _TNL_ATTRIB_COLOR1, i, vb); + fetch_input_float(pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, + vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, + _TNL_ATTRIB_TEX0, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, + _TNL_ATTRIB_TEX1, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, + _TNL_ATTRIB_TEX2, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, + _TNL_ATTRIB_TEX3, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, + _TNL_ATTRIB_TEX4, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, + _TNL_ATTRIB_TEX5, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, + _TNL_ATTRIB_TEX6, i, vb); + fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, + _TNL_ATTRIB_TEX7, i, vb); for (j = 0; j < MAX_VERTEX_ATTRIBS; j++) - fetch_gen_attrib (pro, j, i, vb); - - _slang_exec_vertex_shader (pro); - - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, 0, store); - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store); - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store); - fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store); - for (j = 0; j < 8; j++) - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store); - fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store); - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store); - fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store); - /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */ - - for (j = 0; j < MAX_VARYING_VECTORS; j++) - { - GLuint k; - - for (k = 0; k < VARYINGS_PER_VECTOR; k++) - { - (**pro).UpdateVarying (pro, j * VARYINGS_PER_VECTOR + k, - &store->varyings[j].data[i][k], GL_TRUE); - } - } - } - - vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS]; - vb->ClipPtr->count = vb->Count; - - vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0]; - vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0]; - vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0]; - - vb->SecondaryColorPtr[0] = - vb->AttribPtr[VERT_ATTRIB_COLOR1] = &store->outputs[VERT_RESULT_COL1]; - - vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1]; - - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - vb->TexCoordPtr[i] = - vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->outputs[VERT_RESULT_TEX0 + i]; - } - - vb->FogCoordPtr = - vb->AttribPtr[VERT_ATTRIB_FOG] = &store->outputs[VERT_RESULT_FOGC]; - - vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ]; - - for (i = 0; i < MAX_VARYING_VECTORS; i++) { - vb->VaryingPtr[i] = &store->varyings[i]; - vb->AttribPtr[_TNL_ATTRIB_GENERIC0 + i] = vb->VaryingPtr[i]; - } - - store->ormask = 0; - store->andmask = CLIP_FRUSTUM_BITS; - - if (tnl->NeedNdcCoords) - { - vb->NdcPtr = _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords, - store->clipmask, &store->ormask, &store->andmask); - } - else - { - vb->NdcPtr = NULL; - _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, store->clipmask, &store->ormask, - &store->andmask); - } - - if (store->andmask) - return GL_FALSE; - - vb->ClipAndMask = store->andmask; - vb->ClipOrMask = store->ormask; - vb->ClipMask = store->clipmask; - - return GL_TRUE; + fetch_gen_attrib(pro, j, i, vb); + + _slang_exec_vertex_shader(pro); + + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, + 0, store); + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, + i, 0, store); + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, + VERT_RESULT_COL1, i, 0, store); + fetch_output_float(pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, + VERT_RESULT_FOGC, i, store); + for (j = 0; j < 8; j++) + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_TEXCOORD, + VERT_RESULT_TEX0 + j, i, j, store); + fetch_output_float(pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, + i, store); + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, + i, 0, store); + fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, + VERT_RESULT_BFC1, i, 0, store); + /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */ + + for (j = 0; j < MAX_VARYING_VECTORS; j++) { + GLuint k; + + for (k = 0; k < VARYINGS_PER_VECTOR; k++) { + (**pro).UpdateVarying(pro, j * VARYINGS_PER_VECTOR + k, + &store->varyings[j].data[i][k], GL_TRUE); + } + } + } + + vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS]; + vb->ClipPtr->count = vb->Count; + + vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0]; + vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0]; + vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0]; + + vb->SecondaryColorPtr[0] = + vb->AttribPtr[VERT_ATTRIB_COLOR1] = &store->outputs[VERT_RESULT_COL1]; + + vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1]; + + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + vb->TexCoordPtr[i] = + vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = + &store->outputs[VERT_RESULT_TEX0 + i]; + } + + vb->FogCoordPtr = + vb->AttribPtr[VERT_ATTRIB_FOG] = &store->outputs[VERT_RESULT_FOGC]; + + vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ]; + + for (i = 0; i < MAX_VARYING_VECTORS; i++) { + vb->VaryingPtr[i] = &store->varyings[i]; + vb->AttribPtr[_TNL_ATTRIB_GENERIC0 + i] = vb->VaryingPtr[i]; + } + + store->ormask = 0; + store->andmask = CLIP_FRUSTUM_BITS; + + if (tnl->NeedNdcCoords) { + vb->NdcPtr = + _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords, + store->clipmask, &store->ormask, + &store->andmask); + } + else { + vb->NdcPtr = NULL; + _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, + store->clipmask, &store->ormask, + &store->andmask); + } + + if (store->andmask) + return GL_FALSE; + + vb->ClipAndMask = store->andmask; + vb->ClipOrMask = store->ormask; + vb->ClipMask = store->clipmask; + + return GL_TRUE; } const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = { - "ARB_vertex_shader", - NULL, - construct_arb_vertex_shader, - destruct_arb_vertex_shader, - validate_arb_vertex_shader, - run_arb_vertex_shader + "ARB_vertex_shader", + NULL, + construct_arb_vertex_shader, + destruct_arb_vertex_shader, + validate_arb_vertex_shader, + run_arb_vertex_shader }; #endif /* FEATURE_ARB_vertex_shader */ - diff --git a/src/mesa/tnl/t_vb_cull.c b/src/mesa/tnl/t_vb_cull.c index 8848dac10c..21a32e5b1d 100644 --- a/src/mesa/tnl/t_vb_cull.c +++ b/src/mesa/tnl/t_vb_cull.c @@ -57,10 +57,7 @@ static GLboolean run_cull_stage( GLcontext *ctx, GLuint count = VB->Count; GLuint i; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (ctx->VertexProgram._Enabled || + if (ctx->VertexProgram._Current || !ctx->Transform.CullVertexFlag) return GL_TRUE; diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 51f28c4059..5440ff7894 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -148,10 +148,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) struct fog_stage_data *store = FOG_STAGE_DATA(stage); GLvector4f *input; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (!ctx->Fog.Enabled || ctx->VertexProgram._Enabled) + if (!ctx->Fog.Enabled || ctx->VertexProgram._Current) return GL_TRUE; diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 47c5b400aa..12f2cc7735 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -203,10 +203,7 @@ static GLboolean run_lighting( GLcontext *ctx, GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; GLuint idx; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled) + if (!ctx->Light.Enabled || ctx->VertexProgram._Current) return GL_TRUE; /* Make sure we can talk about position x,y and z: @@ -264,10 +261,7 @@ static void validate_lighting( GLcontext *ctx, { light_func *tab; - if (ctx->ShaderObjects._VertexShaderPresent) - return; - - if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled) + if (!ctx->Light.Enabled || ctx->VertexProgram._Current) return; if (ctx->Visual.rgbMode) { diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 0f91784e80..01fad0cee2 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -95,12 +95,7 @@ validate_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) { struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); - if (ctx->ShaderObjects._VertexShaderPresent) { - store->NormalTransform = NULL; - return; - } - - if (ctx->VertexProgram._Enabled || + if (ctx->VertexProgram._Current || (!ctx->Light.Enabled && !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) { store->NormalTransform = NULL; diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 2f502d61d1..9327f8c273 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -47,10 +47,7 @@ struct point_stage_data { static GLboolean run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) { - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) { + if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) { struct point_stage_data *store = POINT_STAGE_DATA(stage); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data; diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index f11ac616f1..c901de0588 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -39,6 +39,7 @@ #include "light.h" #include "macros.h" #include "imports.h" +#include "program.h" #include "simple_list.h" #include "mtypes.h" #include "program_instruction.h" @@ -55,7 +56,7 @@ */ struct vp_stage_data { /** The results of running the vertex program go into these arrays. */ - GLvector4f attribs[15]; + GLvector4f attribs[VERT_RESULT_MAX]; GLvector4f ndcCoords; /**< normalized device coords */ GLubyte *clipmask; /**< clip flags */ @@ -75,16 +76,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) TNLcontext *tnl = TNL_CONTEXT(ctx); struct vp_stage_data *store = VP_STAGE_DATA(stage); struct vertex_buffer *VB = &tnl->vb; - struct gl_vertex_program *program = ctx->VertexProgram.Current; + struct gl_vertex_program *program = ctx->VertexProgram._Current; struct vp_machine machine; GLuint i; - if (ctx->ShaderObjects._VertexShaderPresent) + if (!program || !program->IsNVProgram) return GL_TRUE; - if (!ctx->VertexProgram._Enabled || - !program->IsNVProgram) - return GL_TRUE; + _mesa_load_state_parameters(ctx, program->Base.Parameters); /* load program parameter registers (they're read-only) */ _mesa_init_vp_per_primitive_registers(ctx); @@ -140,9 +139,16 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* copy the output registers into the VB->attribs arrays */ /* XXX (optimize) could use a conditional and smaller loop limit here */ - for (attr = 0; attr < 15; attr++) { + for (attr = 0; attr < VERT_RESULT_MAX; attr++) { COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); } +#if 0 + printf("HPOS: %f %f %f %f\n", + machine.Outputs[0][0], + machine.Outputs[0][1], + machine.Outputs[0][2], + machine.Outputs[0][3]); +#endif } /* Setup the VB pointers so that the next pipeline stages get @@ -227,8 +233,7 @@ static GLboolean init_vp( GLcontext *ctx, return GL_FALSE; /* Allocate arrays of vertex output values */ - /* XXX change '15' to a named constant */ - for (i = 0; i < 15; i++) { + for (i = 0; i < VERT_RESULT_MAX; i++) { _mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 ); store->attribs[i].size = 4; } diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index 5f7b2dccd8..e98ab743c5 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -488,10 +488,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx, struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); GLuint i; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled) + if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) return GL_TRUE; for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { @@ -516,10 +513,7 @@ static void validate_texgen_stage( GLcontext *ctx, struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); GLuint i; - if (ctx->ShaderObjects._VertexShaderPresent) - return; - - if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled) + if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) return; for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c index fa9222c0f1..674d36f8cb 100644 --- a/src/mesa/tnl/t_vb_texmat.c +++ b/src/mesa/tnl/t_vb_texmat.c @@ -61,10 +61,7 @@ static GLboolean run_texmat_stage( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLuint i; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Enabled) + if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Current) return GL_TRUE; /* ENABLE_TEXMAT implies that the texture matrix is not the diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 100fca2a22..276305b5e6 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -126,10 +126,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - if (ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; - - if (ctx->VertexProgram._Enabled) + if (ctx->VertexProgram._Current) return GL_TRUE; if (ctx->_NeedEyeCoords) { diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 805d05ae72..a68127e653 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -382,11 +382,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); } @@ -1495,7 +1498,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 +1506,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 ) diff --git a/src/mesa/tnl/t_vtx_eval.c b/src/mesa/tnl/t_vtx_eval.c index 71564076e3..bb621ecbe3 100644 --- a/src/mesa/tnl/t_vtx_eval.c +++ b/src/mesa/tnl/t_vtx_eval.c @@ -123,8 +123,7 @@ void _tnl_update_eval( GLcontext *ctx ) * We do this after the conventional attributes since the spec says that * these generic maps have higher priority. */ - if (ctx->VertexProgram._Enabled && - ctx->VertexProgram._Current && + if (ctx->VertexProgram._Current && ctx->VertexProgram._Current->IsNVProgram) { for (attr = 0; attr < 16; attr++) { if (ctx->Eval.Map1Attrib[attr]) -- cgit v1.2.3 From 1fbb1c8d783e4d2cae08415619bac9ddbf74cdef Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 13 Dec 2006 15:33:41 -0700 Subject: Obsolete. --- src/mesa/tnl/t_vb_arbshader.c | 332 ------------------------------------------ 1 file changed, 332 deletions(-) delete mode 100644 src/mesa/tnl/t_vb_arbshader.c (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbshader.c b/src/mesa/tnl/t_vb_arbshader.c deleted file mode 100644 index 6d59114657..0000000000 --- a/src/mesa/tnl/t_vb_arbshader.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Michal Krol - */ - -#include "glheader.h" -#include "imports.h" -#include "macros.h" -#include "shaderobjects.h" -#include "shaderobjects_3dlabs.h" -#include "t_pipeline.h" -#include "slang_utility.h" -#include "slang_link.h" - -#if FEATURE_ARB_vertex_shader - -typedef struct -{ - GLvector4f outputs[VERT_RESULT_MAX]; - GLvector4f varyings[MAX_VARYING_VECTORS]; - GLvector4f ndc_coords; - GLubyte *clipmask; - GLubyte ormask; - GLubyte andmask; -} arbvs_stage_data; - -#define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr) - -static GLboolean -construct_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *vb = &tnl->vb; - arbvs_stage_data *store; - GLuint size = vb->Size; - GLuint i; - - stage->privatePtr = _mesa_malloc(sizeof(arbvs_stage_data)); - store = ARBVS_STAGE_DATA(stage); - if (store == NULL) - return GL_FALSE; - - for (i = 0; i < VERT_RESULT_MAX; i++) { - _mesa_vector4f_alloc(&store->outputs[i], 0, size, 32); - store->outputs[i].size = 4; - } - for (i = 0; i < MAX_VARYING_VECTORS; i++) { - _mesa_vector4f_alloc(&store->varyings[i], 0, size, 32); - store->varyings[i].size = 4; - } - _mesa_vector4f_alloc(&store->ndc_coords, 0, size, 32); - store->clipmask = (GLubyte *) ALIGN_MALLOC(size, 32); - - return GL_TRUE; -} - -static void -destruct_arb_vertex_shader(struct tnl_pipeline_stage *stage) -{ - arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); - - if (store != NULL) { - GLuint i; - - for (i = 0; i < VERT_RESULT_MAX; i++) - _mesa_vector4f_free(&store->outputs[i]); - for (i = 0; i < MAX_VARYING_VECTORS; i++) - _mesa_vector4f_free(&store->varyings[i]); - _mesa_vector4f_free(&store->ndc_coords); - ALIGN_FREE(store->clipmask); - - _mesa_free(store); - stage->privatePtr = NULL; - } -} - -static void -validate_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) -{ -} - -static GLvoid -fetch_input_float(struct gl2_program_intf **pro, GLuint index, GLuint attr, - GLuint i, struct vertex_buffer *vb) -{ - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint stride = vb->AttribPtr[attr]->stride; - GLfloat *data = (GLfloat *) (ptr + stride * i); - - (**pro).UpdateFixedAttrib(pro, index, data, 0, sizeof(GLfloat), GL_TRUE); -} - -static GLvoid -fetch_input_vec3(struct gl2_program_intf **pro, GLuint index, GLuint attr, - GLuint i, struct vertex_buffer *vb) -{ - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint stride = vb->AttribPtr[attr]->stride; - GLfloat *data = (GLfloat *) (ptr + stride * i); - - (**pro).UpdateFixedAttrib(pro, index, data, 0, 3 * sizeof(GLfloat), - GL_TRUE); -} - -static void -fetch_input_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr, - GLuint i, struct vertex_buffer *vb) -{ - const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data; - const GLuint size = vb->AttribPtr[attr]->size; - const GLuint stride = vb->AttribPtr[attr]->stride; - const GLfloat *data = (const GLfloat *) (ptr + stride * i); - GLfloat vec[4]; - - switch (size) { - case 2: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = 0.0f; - vec[3] = 1.0f; - break; - case 3: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = data[2]; - vec[3] = 1.0f; - break; - case 4: - vec[0] = data[0]; - vec[1] = data[1]; - vec[2] = data[2]; - vec[3] = data[3]; - break; - } - (**pro).UpdateFixedAttrib(pro, index, vec, 0, 4 * sizeof(GLfloat), - GL_TRUE); -} - -static GLvoid -fetch_gen_attrib(struct gl2_program_intf **pro, GLuint index, GLuint i, - struct vertex_buffer *vb) -{ - const GLuint attr = _TNL_ATTRIB_GENERIC0 + index; - const GLubyte *ptr = (const GLubyte *) (vb->AttribPtr[attr]->data); - const GLuint stride = vb->AttribPtr[attr]->stride; - const GLfloat *data = (const GLfloat *) (ptr + stride * i); - - (**pro).WriteAttrib(pro, index, data); -} - -static GLvoid -fetch_output_float(struct gl2_program_intf **pro, GLuint index, GLuint attr, - GLuint i, arbvs_stage_data * store) -{ - (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], 0, - sizeof(GLfloat), GL_FALSE); -} - -static void -fetch_output_vec4(struct gl2_program_intf **pro, GLuint index, GLuint attr, - GLuint i, GLuint offset, arbvs_stage_data * store) -{ - (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], - offset, 4 * sizeof(GLfloat), GL_FALSE); -} - -static GLboolean -run_arb_vertex_shader(GLcontext * ctx, struct tnl_pipeline_stage *stage) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *vb = &tnl->vb; - arbvs_stage_data *store = ARBVS_STAGE_DATA(stage); - struct gl2_program_intf **pro; - GLsizei i, j; - -#if 00 - if (!ctx->ShaderObjects._VertexShaderPresent) - return GL_TRUE; -#else - return GL_TRUE; -#endif - - pro = ctx->ShaderObjects.CurrentProgram; - (**pro).UpdateFixedUniforms(pro); - - for (i = 0; i < vb->Count; i++) { - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, - vb); - fetch_input_vec3(pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, - vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, - vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, - _TNL_ATTRIB_COLOR1, i, vb); - fetch_input_float(pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, - vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, - _TNL_ATTRIB_TEX0, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, - _TNL_ATTRIB_TEX1, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, - _TNL_ATTRIB_TEX2, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, - _TNL_ATTRIB_TEX3, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, - _TNL_ATTRIB_TEX4, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, - _TNL_ATTRIB_TEX5, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, - _TNL_ATTRIB_TEX6, i, vb); - fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, - _TNL_ATTRIB_TEX7, i, vb); - for (j = 0; j < MAX_VERTEX_ATTRIBS; j++) - fetch_gen_attrib(pro, j, i, vb); - - _slang_exec_vertex_shader(pro); - - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, - 0, store); - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, - i, 0, store); - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, - VERT_RESULT_COL1, i, 0, store); - fetch_output_float(pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, - VERT_RESULT_FOGC, i, store); - for (j = 0; j < 8; j++) - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_TEXCOORD, - VERT_RESULT_TEX0 + j, i, j, store); - fetch_output_float(pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, - i, store); - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, - i, 0, store); - fetch_output_vec4(pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, - VERT_RESULT_BFC1, i, 0, store); - /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */ - - for (j = 0; j < MAX_VARYING_VECTORS; j++) { - GLuint k; - - for (k = 0; k < VARYINGS_PER_VECTOR; k++) { - (**pro).UpdateVarying(pro, j * VARYINGS_PER_VECTOR + k, - &store->varyings[j].data[i][k], GL_TRUE); - } - } - } - - vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS]; - vb->ClipPtr->count = vb->Count; - - vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0]; - vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0]; - vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0]; - - vb->SecondaryColorPtr[0] = - vb->AttribPtr[VERT_ATTRIB_COLOR1] = &store->outputs[VERT_RESULT_COL1]; - - vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1]; - - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - vb->TexCoordPtr[i] = - vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = - &store->outputs[VERT_RESULT_TEX0 + i]; - } - - vb->FogCoordPtr = - vb->AttribPtr[VERT_ATTRIB_FOG] = &store->outputs[VERT_RESULT_FOGC]; - - vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ]; - - for (i = 0; i < MAX_VARYING_VECTORS; i++) { - vb->VaryingPtr[i] = &store->varyings[i]; - vb->AttribPtr[_TNL_ATTRIB_GENERIC0 + i] = vb->VaryingPtr[i]; - } - - store->ormask = 0; - store->andmask = CLIP_FRUSTUM_BITS; - - if (tnl->NeedNdcCoords) { - vb->NdcPtr = - _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords, - store->clipmask, &store->ormask, - &store->andmask); - } - else { - vb->NdcPtr = NULL; - _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, - store->clipmask, &store->ormask, - &store->andmask); - } - - if (store->andmask) - return GL_FALSE; - - vb->ClipAndMask = store->andmask; - vb->ClipOrMask = store->ormask; - vb->ClipMask = store->clipmask; - - return GL_TRUE; -} - -const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = { - "ARB_vertex_shader", - NULL, - construct_arb_vertex_shader, - destruct_arb_vertex_shader, - validate_arb_vertex_shader, - run_arb_vertex_shader -}; - -#endif /* FEATURE_ARB_vertex_shader */ -- cgit v1.2.3 From 60a7200c0de7fc2925430b466739b4021087d14c Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 10:08:59 -0700 Subject: updated includes --- src/mesa/tnl/t_vb_arbprogram.c | 4 +++- src/mesa/tnl/t_vb_program.c | 3 ++- src/mesa/tnl/t_vp_build.c | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index b7975f3a4e..c59d98e118 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -37,13 +37,15 @@ #include "arbprogparse.h" #include "light.h" #include "program.h" +#include "prog_instruction.h" +#include "prog_parameter.h" +#include "prog_statevars.h" #include "programopt.h" #include "math/m_matrix.h" #include "t_context.h" #include "t_pipeline.h" #include "t_vb_arbprogram.h" #include "tnl.h" -#include "program_instruction.h" #define DISASSEM 0 diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index c901de0588..9df649c5e6 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -42,7 +42,8 @@ #include "program.h" #include "simple_list.h" #include "mtypes.h" -#include "program_instruction.h" +#include "prog_instruction.h" +#include "prog_statevars.h" #include "nvvertexec.h" #include "nvprogram.h" diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index a68127e653..5e146bfb36 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; -- cgit v1.2.3 From a7e252026db542d362bc4688d49c7e28c2f9f1ea Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 10:09:12 -0700 Subject: updated includes --- src/mesa/tnl/t_vb_arbprogram_sse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram_sse.c b/src/mesa/tnl/t_vb_arbprogram_sse.c index b9126d6d88..d0f66fd619 100644 --- a/src/mesa/tnl/t_vb_arbprogram_sse.c +++ b/src/mesa/tnl/t_vb_arbprogram_sse.c @@ -43,7 +43,7 @@ #include "mtypes.h" #include "arbprogparse.h" #include "program.h" -#include "program_instruction.h" +#include "prog_instruction.h" #include "math/m_matrix.h" #include "math/m_translate.h" #include "t_context.h" -- cgit v1.2.3 From 9abf73b8cc204a9348c751022bace78560d7cb3e Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 10:09:33 -0700 Subject: varying changes --- src/mesa/tnl/t_context.c | 2 +- src/mesa/tnl/t_context.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index b07f90af02..3887f18213 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -199,7 +199,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled)) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); -#if NEW_SLANG +#if 1 /* XXX NEW_SLANG */ RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); #else diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index d5414bd730..ea2a6bed54 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -422,7 +422,7 @@ struct vertex_buffer GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */ GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */ GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */ - GLvector4f *VaryingPtr[MAX_VARYING_VECTORS]; + GLvector4f *VaryingPtr[MAX_VARYING]; struct tnl_prim *Primitive; GLuint PrimitiveCount; -- cgit v1.2.3 From f167d0e7d588ab65067ab2e7499664ebc5ab02ec Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 15 Dec 2006 15:37:32 -0700 Subject: added assertion to catch use of too many temporaries --- src/mesa/tnl/t_vb_arbprogram.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index c59d98e118..1f17a7e389 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -832,6 +832,7 @@ static struct reg cvp_load_reg( struct compilation *cp, switch (file) { case PROGRAM_TEMPORARY: + assert(REG_TMP0 + index <= REG_TMP11); return cvp_make_reg(FILE_REG, REG_TMP0 + index); case PROGRAM_INPUT: -- cgit v1.2.3 From b456413d7644978bf7bd40d9c1bcba83f637f685 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 16 Dec 2006 12:50:51 -0700 Subject: cases for NOP, BRA --- src/mesa/tnl/t_vb_arbprogram.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 1f17a7e389..ef7b9eaa6c 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -1026,6 +1026,13 @@ static void cvp_emit_inst( struct compilation *cp, } break; + case OPCODE_NOP: + break; + + case OPCODE_BRA: + /* XXX implement */ + break; + default: result = cvp_choose_result( cp, &inst->DstReg, &fixup ); nr_args = _mesa_num_inst_src_regs(inst->Opcode); -- cgit v1.2.3 From 2a62cbd24b02b0c222d9857ccf9a13e5e167f03a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Dec 2006 17:19:45 -0700 Subject: handle PROGRAM_UNIFORM, fix a _mesa_problem() call --- src/mesa/tnl/t_vb_arbprogram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index ef7b9eaa6c..906fd3f1e8 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -859,6 +859,7 @@ static struct reg cvp_load_reg( struct compilation *cp, case PROGRAM_STATE_VAR: case PROGRAM_CONSTANT: + case PROGRAM_UNIFORM: reg = cvp_make_reg(FILE_STATE_PARAM, index); if (rel) return cvp_emit_rel(cp, reg, tmpreg); @@ -870,7 +871,7 @@ static struct reg cvp_load_reg( struct compilation *cp, case PROGRAM_WRITE_ONLY: case PROGRAM_ADDRESS: default: - _mesa_problem(NULL, "Invalid register file %d in cvp_load_reg()"); + _mesa_problem(NULL, "Invalid register file %d in cvp_load_reg()", file); assert(0); return tmpreg; /* can't happen */ } -- cgit v1.2.3 From e8673143ea3d0edf1be7ba8e0723ddba61d8f3f8 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 9 Jan 2007 17:46:45 -0700 Subject: add code for generic attributes 16..31 --- src/mesa/tnl/t_save_api.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c index dbbd095fe4..616b599218 100644 --- a/src/mesa/tnl/t_save_api.c +++ b/src/mesa/tnl/t_save_api.c @@ -677,12 +677,30 @@ ATTRS( 13 ) ATTRS( 14 ) ATTRS( 15 ) +ATTRS( 16 ) +ATTRS( 17 ) +ATTRS( 18 ) +ATTRS( 19 ) +ATTRS( 20 ) +ATTRS( 21 ) +ATTRS( 22 ) +ATTRS( 23 ) +ATTRS( 24 ) +ATTRS( 25 ) +ATTRS( 26 ) +ATTRS( 27 ) +ATTRS( 28 ) +ATTRS( 29 ) +ATTRS( 30 ) +ATTRS( 31 ) + static void _save_reset_vertex( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint i; + /* conventional attributes */ save_init_0( tnl ); save_init_1( tnl ); save_init_2( tnl ); @@ -699,6 +717,24 @@ static void _save_reset_vertex( GLcontext *ctx ) save_init_13( tnl ); save_init_14( tnl ); save_init_15( tnl ); + + /* generic attributes */ + save_init_16( tnl ); + save_init_17( tnl ); + save_init_18( tnl ); + save_init_19( tnl ); + save_init_20( tnl ); + save_init_21( tnl ); + save_init_22( tnl ); + save_init_23( tnl ); + save_init_24( tnl ); + save_init_25( tnl ); + save_init_26( tnl ); + save_init_27( tnl ); + save_init_28( tnl ); + save_init_29( tnl ); + save_init_30( tnl ); + save_init_31( tnl ); for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++) tnl->save.attrsz[i] = 0; @@ -1024,7 +1060,7 @@ static void GLAPIENTRY _save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) { if (index < MAX_VERTEX_ATTRIBS) - DISPATCH_ATTR2F( index, x, y ); + DISPATCH_ATTR2F( VERT_ATTRIB_GENERIC0 + index, x, y ); else enum_error(); } -- cgit v1.2.3 From 88f721231248854e441ccdaeabe1c471e64ddc0a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 10 Jan 2007 08:15:35 -0700 Subject: Update _save_VertexAttrib() functions for non-aliasing behaviour. --- src/mesa/tnl/t_save_api.c | 129 +++++++++++++++++++++++++++++++++------------- 1 file changed, 93 insertions(+), 36 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c index 616b599218..b08f05374e 100644 --- a/src/mesa/tnl/t_save_api.c +++ b/src/mesa/tnl/t_save_api.c @@ -971,141 +971,198 @@ static void GLAPIENTRY _save_MultiTexCoord4fv( GLenum target, const GLfloat *v ) DISPATCH_ATTR4FV( attr, v ); } -static void GLAPIENTRY _save_VertexAttrib1fNV( GLuint index, GLfloat x ) + + +static void GLAPIENTRY +_save_VertexAttrib1fNV(GLuint index, GLfloat x) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1F( index, x ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) +static void GLAPIENTRY +_save_VertexAttrib1fvNV(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1FV( index, v ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ) +static void GLAPIENTRY +_save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR2F( index, x, y ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) +static void GLAPIENTRY +_save_VertexAttrib2fvNV(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR2FV( index, v ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, - GLfloat z ) +static void GLAPIENTRY +_save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3F( index, x, y, z ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) +static void GLAPIENTRY +_save_VertexAttrib3fvNV(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3FV( index, v ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w ) +static void GLAPIENTRY +_save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4F( index, x, y, z, w ); + } else enum_error(); } -static void GLAPIENTRY _save_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) +static void GLAPIENTRY +_save_VertexAttrib4fvNV(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) + if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4FV( index, v ); + } else enum_error(); } - static void GLAPIENTRY -_save_VertexAttrib1fARB( GLuint index, GLfloat x ) +_save_VertexAttrib1fARB(GLuint index, GLfloat x) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1F( index, x ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) +_save_VertexAttrib1fvARB(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR1FV( index, v ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) +_save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) { - if (index < MAX_VERTEX_ATTRIBS) - DISPATCH_ATTR2F( VERT_ATTRIB_GENERIC0 + index, x, y ); + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; + DISPATCH_ATTR2F( index, x, y ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) +_save_VertexAttrib2fvARB(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR2FV( index, v ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z ) +_save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3F( index, x, y, z ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) +_save_VertexAttrib3fvARB(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR3FV( index, v ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +_save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4F( index, x, y, z, w ); + } else enum_error(); } static void GLAPIENTRY -_save_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) +_save_VertexAttrib4fvARB(GLuint index, const GLfloat *v) { - if (index < MAX_VERTEX_ATTRIBS) + if (index < MAX_VERTEX_ATTRIBS) { + if (index > 0) + index += VERT_ATTRIB_GENERIC0; DISPATCH_ATTR4FV( index, v ); + } else enum_error(); } -- cgit v1.2.3 From 0bad236cfbaabfc0ed4f20088e64fa89f81934ce Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 17 Jan 2007 15:54:14 -0700 Subject: Added OPCODE_INT to convert 4 floats to 4 ints. --- src/mesa/tnl/t_vb_arbprogram.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 906fd3f1e8..5773f0f627 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -338,6 +338,17 @@ static void do_FRC( struct arb_vp_machine *m, union instruction op ) result[3] = arg0[3] - FLOORF(arg0[3]); } +static void do_INT( struct arb_vp_machine *m, union instruction op ) +{ + GLfloat *result = m->File[0][op.alu.dst]; + const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0]; + + result[0] = (GLfloat) (GLint) arg0[0]; + result[1] = (GLfloat) (GLint) arg0[1]; + result[2] = (GLfloat) (GLint) arg0[2]; + result[3] = (GLfloat) (GLint) arg0[3]; +} + /* High precision log base 2: */ static void do_LG2( struct arb_vp_machine *m, union instruction op ) @@ -665,6 +676,7 @@ _tnl_disassem_vba_insn( union instruction op ) case OPCODE_EXP: case OPCODE_FLR: case OPCODE_FRC: + case OPCODE_INT: case OPCODE_LG2: case OPCODE_LIT: case OPCODE_LOG: @@ -739,6 +751,7 @@ static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union i do_EXP, do_FLR, do_FRC, + do_INT, do_NOP,/*KIL*/ do_NOP,/*KIL_NV*/ do_LG2, @@ -1458,6 +1471,10 @@ static GLboolean init_vertex_program( GLcontext *ctx, const GLuint size = VB->Size; GLuint i; + /* spot checks to be sure the opcode table is correct */ + assert(opcode_func[OPCODE_SGE] == do_SGE); + assert(opcode_func[OPCODE_XPD] == do_XPD); + stage->privatePtr = _mesa_calloc(sizeof(*m)); m = ARB_VP_MACHINE(stage); if (!m) -- cgit v1.2.3 From 5ae49cf3ed53fda6a904d7e90feef78495ae6903 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 20 Jan 2007 09:27:40 -0700 Subject: Initial implementation of OPCODE_IF/ELSE/ENDIF instructions. --- src/mesa/tnl/t_vb_arbprogram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 5773f0f627..5726a66c90 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -746,11 +746,14 @@ static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union i do_DP4, do_DPH, do_DST, - do_NOP, + do_NOP,/*ELSE*/ + do_NOP,/*END*/ + do_NOP,/*ENDIF*/ do_EX2, do_EXP, do_FLR, do_FRC, + do_NOP,/*IF*/ do_INT, do_NOP,/*KIL*/ do_NOP,/*KIL_NV*/ -- cgit v1.2.3 From ff917003f6ed35b9ef966397a58c80dc7df98bff Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2007 14:14:14 -0700 Subject: use FRAG_BIT_TEX() --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 5e146bfb36..d80afaf245 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1213,7 +1213,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<state->fragprog_inputs_read & (FRAG_BIT_TEX(i)))) continue; if (p->state->unit[i].texgen_enabled || -- cgit v1.2.3 From e713c21bd09468887faceebcba9a62a406321c07 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2007 14:15:01 -0700 Subject: remove some parenthesis --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index d80afaf245..47fed32904 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1213,7 +1213,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_TEX(i)))) + if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) continue; if (p->state->unit[i].texgen_enabled || -- cgit v1.2.3 From 7aece10039ad4786d7f85d61ec8614b9f287ea23 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 28 Jan 2007 19:01:35 -0700 Subject: noise functions --- src/mesa/tnl/t_vb_arbprogram.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 5726a66c90..22b6089fc8 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -766,6 +766,10 @@ static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union i do_MIN, do_MOV, do_MUL, + do_NOP,/*NOISE1*/ + do_NOP,/*NOISE2*/ + do_NOP,/*NOISE3*/ + do_NOP,/*NOISE4*/ do_NOP,/*PK2H*/ do_NOP,/*PK2US*/ do_NOP,/*PK4B*/ -- cgit v1.2.3 From 01001d80e26143ac768115ccb2266db2b24d4fa0 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Feb 2007 11:28:15 -0700 Subject: Initial support of loop and subroutine instructions. New high-level flow-control instructions, both at IR level and GPU instructions for looping and subroutines. --- src/mesa/tnl/t_vb_arbprogram.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 22b6089fc8..0a443b3e01 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -736,9 +736,13 @@ static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union i do_NOP,/*ARL*/ do_NOP,/*ARL_NV*/ do_NOP,/*ARR*/ + do_NOP,/*BGNLOOP*/ + do_NOP,/*BGNSUB*/ do_NOP,/*BRA*/ + do_NOP,/*BRK*/ do_NOP,/*CAL*/ do_NOP,/*CMP*/ + do_NOP,/*CONT*/ do_NOP,/*COS*/ do_NOP,/*DDX*/ do_NOP,/*DDY*/ @@ -749,6 +753,8 @@ static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union i do_NOP,/*ELSE*/ do_NOP,/*END*/ do_NOP,/*ENDIF*/ + do_NOP,/*ENDLOOP*/ + do_NOP,/*ENDSUB*/ do_EX2, do_EXP, do_FLR, -- cgit v1.2.3 From cf92c727979e434d148b23d20f2e4e0f4bc4de61 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Feb 2007 15:00:07 -0700 Subject: Initial implementation of high-level flow-control instructions. IF/ELSE/ENDIF and BEGIN_LOOP/END_LOOP/BREAK instructions seem to work. Disabled by default though until better tested. Implemented IR_NOT, but needs optimization. --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 47fed32904..6fb14e7caa 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -497,7 +497,7 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, } _mesa_printf("%d:\t", line); - _mesa_print_instruction(inst); + _mesa_print_instruction(inst, 0); } } -- cgit v1.2.3 From 501ee87180047dd04afc69103c31e1eae5374bf1 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 17 Feb 2007 09:15:00 -0700 Subject: Lots of changes to prog_print.c code. Mainly, allow printing programs in either ARB, NV or "debug" formats. --- src/mesa/tnl/t_vp_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 6fb14e7caa..47fed32904 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -497,7 +497,7 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, } _mesa_printf("%d:\t", line); - _mesa_print_instruction(inst, 0); + _mesa_print_instruction(inst); } } -- cgit v1.2.3 From 6531952b3c979be0dc95704beb3c3b9dad1dc37b Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Feb 2007 11:08:21 -0700 Subject: adjustments to STATE_ token layout/format so token[1] is always the array index --- src/mesa/tnl/t_vp_build.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 47fed32904..9065e3421f 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -636,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); } @@ -671,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); @@ -706,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 ); } } @@ -1109,7 +1109,7 @@ static void build_fog( struct tnl_program *p ) } if (p->state->tnl_do_vertex_fog) { - struct ureg params = register_param1(p, STATE_FOG_PARAMS); + struct ureg params = register_param2(p, STATE_FOG, STATE_FOG_PARAMS); struct ureg tmp = get_temp(p); switch (p->state->fog_mode) { @@ -1303,13 +1303,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 ); } } -- cgit v1.2.3 From f958aabdf3e3dc82827628cab97b159bd5089651 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Feb 2007 15:23:11 -0700 Subject: more minor changes to STATE_ indexing --- src/mesa/tnl/t_vp_build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 9065e3421f..8b75dff96a 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -946,7 +946,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, @@ -1328,8 +1328,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); -- cgit v1.2.3 From 776bc9cf55b116e17dddde4d097985b51879c83f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Feb 2007 09:29:46 -0700 Subject: Undo some STATE_POINT/FOG changes. Max length of state token array is now 5. --- src/mesa/tnl/t_vp_build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 283782588a..17f115f4a2 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1323,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_param2(p, STATE_POINT, STATE_POINT_SIZE); - struct ureg state_attenuation = register_param2(p, STATE_POINT, STATE_POINT_ATTENUATION); + struct ureg state_size = register_param1(p, STATE_POINT_SIZE); + struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); struct ureg out = register_output(p, VERT_RESULT_PSIZ); struct ureg ut = get_temp(p); -- cgit v1.2.3 From 6cfe2114f19cdcaa372df1c30a7dc7be3b94a330 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Feb 2007 16:06:54 -0700 Subject: FORCE_PROG_EXECUTE_C cpp flag, misc changes --- src/mesa/tnl/t_vb_arbprogram.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 97ff4c7f10..1d9a6ac460 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -726,8 +726,9 @@ _tnl_disassem_vba_insn( union instruction op ) } } +typedef void (*gpu_function)(struct arb_vp_machine *m, union instruction op); -static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union instruction) = +static gpu_function opcode_func[MAX_OPCODE+3] = { do_NOP, do_ABS, @@ -958,7 +959,10 @@ static GLuint cvp_choose_result( struct compilation *cp, idx = REG_OUT0 + dst->Index; break; default: +#if 0 + /* IF/ELSE/ENDIF instructions will hit this */ assert(0); +#endif return REG_RES; /* can't happen */ } @@ -1279,8 +1283,13 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) GLuint i, j; GLbitfield outputs; +#define FORCE_PROG_EXECUTE_C 0 +#if FORCE_PROG_EXECUTE_C + return GL_TRUE; +#else if (!program) return GL_TRUE; +#endif if (program->Base.Parameters) { _mesa_load_state_parameters(ctx, program->Base.Parameters); @@ -1338,9 +1347,9 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) call_func( p, m ); } else { - GLint j; - for (j = 0; j < p->nr_instructions; j++) { - union instruction inst = p->instructions[j]; + GLint pc; + for (pc = 0; pc < p->nr_instructions; pc++) { + union instruction inst = p->instructions[pc]; opcode_func[inst.alu.opcode]( m, inst ); } } @@ -1468,7 +1477,11 @@ validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage ) struct arb_vp_machine *m = ARB_VP_MACHINE(stage); struct gl_vertex_program *program = ctx->VertexProgram._Current; +#if FORCE_OLD + if (0 &&program) { +#else if (program) { +#endif if (!program->TnlData) compile_vertex_program( program, m->try_codegen ); -- cgit v1.2.3 From e382efc85d02ee5a0c582e1a9d9bc35ad262e70b Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Feb 2007 16:07:17 -0700 Subject: use new _mesa_execute_program() function --- src/mesa/tnl/t_vb_program.c | 179 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 153 insertions(+), 26 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 9df649c5e6..422aae69e2 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,21 +31,12 @@ #include "glheader.h" -#include "api_noop.h" -#include "colormac.h" #include "context.h" -#include "dlist.h" -#include "hash.h" -#include "light.h" #include "macros.h" #include "imports.h" -#include "program.h" -#include "simple_list.h" -#include "mtypes.h" #include "prog_instruction.h" #include "prog_statevars.h" -#include "nvvertexec.h" -#include "nvprogram.h" +#include "prog_execute.h" #include "t_context.h" #include "t_pipeline.h" @@ -68,6 +59,130 @@ struct vp_stage_data { #define VP_STAGE_DATA(stage) ((struct vp_stage_data *)(stage->privatePtr)) +/** + * Initialize virtual machine state prior to executing vertex program. + */ +static void +init_machine(GLcontext *ctx, struct gl_program_machine *machine) +{ + /* Input registers get initialized from the current vertex attribs */ + MEMCPY(machine->VertAttribs, ctx->Current.Attrib, + MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat)); + + if (ctx->VertexProgram.Current->IsNVProgram) { + GLuint i; + /* Output/result regs are initialized to [0,0,0,1] */ + for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) { + ASSIGN_4V(machine->Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F); + } + /* Temp regs are initialized to [0,0,0,0] */ + for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) { + ASSIGN_4V(machine->Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F); + } + for (i = 0; i < MAX_VERTEX_PROGRAM_ADDRESS_REGS; i++) { + ASSIGN_4V(machine->AddressReg[i], 0, 0, 0, 0); + } + } + + /* init condition codes */ + machine->CondCodes[0] = COND_EQ; + machine->CondCodes[1] = COND_EQ; + machine->CondCodes[2] = COND_EQ; + machine->CondCodes[3] = COND_EQ; +} + + +/** + * Copy the 16 elements of a matrix into four consecutive program + * registers starting at 'pos'. + */ +static void +load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16]) +{ + GLuint i; + for (i = 0; i < 4; i++) { + registers[pos + i][0] = mat[0 + i]; + registers[pos + i][1] = mat[4 + i]; + registers[pos + i][2] = mat[8 + i]; + registers[pos + i][3] = mat[12 + i]; + } +} + + +/** + * As above, but transpose the matrix. + */ +static void +load_transpose_matrix(GLfloat registers[][4], GLuint pos, + const GLfloat mat[16]) +{ + MEMCPY(registers[pos], mat, 16 * sizeof(GLfloat)); +} + + +/** + * Load program parameter registers with tracked matrices (if NV program). + * This only needs to be done per glBegin/glEnd, not per-vertex. + */ +static void +load_program_parameters(GLcontext *ctx) +{ + GLuint i; + + for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) { + /* point 'mat' at source matrix */ + GLmatrix *mat; + if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) { + mat = ctx->ModelviewMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) { + mat = ctx->ProjectionMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) { + mat = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top; + } + else if (ctx->VertexProgram.TrackMatrix[i] == GL_COLOR) { + mat = ctx->ColorMatrixStack.Top; + } + else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) { + /* XXX verify the combined matrix is up to date */ + mat = &ctx->_ModelProjectMatrix; + } + else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV && + ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) { + GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV; + ASSERT(n < MAX_PROGRAM_MATRICES); + mat = ctx->ProgramMatrixStack[n].Top; + } + else { + /* no matrix is tracked, but we leave the register values as-is */ + assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE); + continue; + } + + /* load the matrix values into sequential registers */ + if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) { + load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); + } + else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) { + _math_matrix_analyse(mat); /* update the inverse */ + ASSERT(!_math_matrix_is_dirty(mat)); + load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); + } + else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) { + load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); + } + else { + assert(ctx->VertexProgram.TrackMatrixTransform[i] + == GL_INVERSE_TRANSPOSE_NV); + _math_matrix_analyse(mat); /* update the inverse */ + ASSERT(!_math_matrix_is_dirty(mat)); + load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); + } + } +} + + /** * This function executes vertex programs */ @@ -78,21 +193,29 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) struct vp_stage_data *store = VP_STAGE_DATA(stage); struct vertex_buffer *VB = &tnl->vb; struct gl_vertex_program *program = ctx->VertexProgram._Current; - struct vp_machine machine; + struct gl_program_machine machine; GLuint i; +#define FORCE_PROG_EXECUTE_C 0 +#if FORCE_PROG_EXECUTE_C + if (!program) + return GL_TRUE; +#else if (!program || !program->IsNVProgram) return GL_TRUE; +#endif - _mesa_load_state_parameters(ctx, program->Base.Parameters); - - /* load program parameter registers (they're read-only) */ - _mesa_init_vp_per_primitive_registers(ctx); + if (ctx->VertexProgram.Current->IsNVProgram) { + load_program_parameters(ctx); + } + else { + _mesa_load_state_parameters(ctx, program->Base.Parameters); + } for (i = 0; i < VB->Count; i++) { GLuint attr; - _mesa_init_vp_per_vertex_registers(ctx, &machine); + init_machine(ctx, &machine); #if 0 printf("Input %d: %f, %f, %f, %f\n", i, @@ -119,13 +242,13 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) const GLuint size = VB->AttribPtr[attr]->size; const GLuint stride = VB->AttribPtr[attr]->stride; const GLfloat *data = (GLfloat *) (ptr + stride * i); - COPY_CLEAN_4V(machine.Inputs[attr], size, data); + COPY_CLEAN_4V(machine.VertAttribs/*Inputs*/[attr], size, data); } } /* execute the program */ - ASSERT(program); - _mesa_exec_vertex_program(ctx, &machine, program); + _mesa_execute_program(ctx, &program->Base, program->Base.NumInstructions, + &machine, 0); /* Fixup fog an point size results if needed */ if (ctx->Fog.Enabled && @@ -175,6 +298,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) = &store->attribs[VERT_RESULT_TEX0 + i]; } + for (i = 0; i < ctx->Const.MaxVarying; i++) { + if (program->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + /* Note: varying results get put into the generic attributes */ + VB->AttribPtr[VERT_ATTRIB_GENERIC0+i] + = &store->attribs[VERT_RESULT_VAR0 + i]; + } + } + /* Cliptest and perspective divide. Clip functions must clear * the clipmask. */ @@ -213,8 +344,6 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } - - /** * Called the first time stage->run is called. In effect, don't * allocate data until the first time the stage is run. @@ -247,9 +376,6 @@ static GLboolean init_vp( GLcontext *ctx, } - - - /** * Destructor for this pipeline stage. */ @@ -273,6 +399,7 @@ static void dtr( struct tnl_pipeline_stage *stage ) } } + /** * Public description of this pipeline stage. */ -- cgit v1.2.3 From fce8409cbbe6aa5309163f3d63894233b8833308 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 23 Feb 2007 11:44:44 -0700 Subject: s/GLint/gl_state_index/, length is now 5 not 6 --- src/mesa/tnl/t_vp_build.c | 61 ++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 17f115f4a2..f9e5045be7 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -414,40 +414,37 @@ static struct ureg get_identity_param( struct tnl_program *p ) return p->identity; } -static struct ureg register_param6( struct tnl_program *p, +static struct ureg register_param5(struct tnl_program *p, GLint s0, GLint s1, GLint s2, GLint s3, - GLint s4, - GLint s5) + GLint s4) { - GLint tokens[6]; + gl_state_index tokens[STATE_LENGTH]; GLint idx; tokens[0] = s0; tokens[1] = s1; tokens[2] = s2; tokens[3] = s3; tokens[4] = s4; - tokens[5] = s5; idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); return make_ureg(PROGRAM_STATE_VAR, idx); } -#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0) -#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0) -#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0) +#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) +#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) +#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) +#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) -static void register_matrix_param6( struct tnl_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4, - GLint s5, +static void register_matrix_param5( struct tnl_program *p, + GLint s0, /* modelview, projection, etc */ + GLint s1, /* texture matrix number */ + GLint s2, /* first row */ + GLint s3, /* last row */ + GLint s4, /* inverse, transpose, etc */ struct ureg *matrix ) { GLint i; @@ -455,8 +452,8 @@ static void register_matrix_param6( struct tnl_program *p, /* This is a bit sad as the support is there to pull the whole * matrix out in one go: */ - for (i = 0; i <= s4 - s3; i++) - matrix[i] = register_param6( p, s0, s1, s2, i, i, s5 ); + for (i = 0; i <= s3 - s2; i++) + matrix[i] = register_param5( p, s0, s1, i, i, s4 ); } @@ -636,14 +633,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_MODELVIEW_MATRIX, 0, 0, 3, - 0, 0, modelview ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + 0, modelview ); emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); } else { - register_matrix_param6( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, modelview ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, modelview ); emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); } @@ -671,8 +668,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_MODELVIEW_MATRIX, 0, 0, 2, - STATE_MATRIX_INVTRANS, 0, mvinv ); + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, + STATE_MATRIX_INVTRANS, mvinv ); p->eye_normal = reserve_temp(p); @@ -706,13 +703,13 @@ static void build_hpos( struct tnl_program *p ) struct ureg mvp[4]; if (PREFER_DP4) { - register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, - 0, 0, mvp ); + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + 0, mvp ); emit_matrix_transform_vec4( p, hpos, mvp, pos ); } else { - register_matrix_param6( p, STATE_MVP_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, mvp ); + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, mvp ); emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); } } @@ -1300,13 +1297,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_TEXTURE_MATRIX, i, 0, 3, - 0, 0, texmat ); + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + 0, texmat ); emit_matrix_transform_vec4( p, out, texmat, in ); } else { - register_matrix_param6( p, STATE_TEXTURE_MATRIX, i, 0, 3, - STATE_MATRIX_TRANSPOSE, 0, texmat ); + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + STATE_MATRIX_TRANSPOSE, texmat ); emit_transpose_matrix_transform_vec4( p, out, texmat, in ); } } -- cgit v1.2.3 From 36a0ee199ddc5f29273f9761eeed8e18ad5c874f Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 23 Feb 2007 13:38:37 -0700 Subject: expose _mesa_load_tracked_matrices() --- src/mesa/tnl/t_vb_program.c | 14 ++++++++------ src/mesa/tnl/tnl.h | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 422aae69e2..72a65f89f1 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -38,6 +38,7 @@ #include "prog_statevars.h" #include "prog_execute.h" +#include "tnl.h" #include "t_context.h" #include "t_pipeline.h" @@ -121,11 +122,12 @@ load_transpose_matrix(GLfloat registers[][4], GLuint pos, /** - * Load program parameter registers with tracked matrices (if NV program). - * This only needs to be done per glBegin/glEnd, not per-vertex. + * Load current vertex program's parameter registers with tracked + * matrices (if NV program). This only needs to be done per + * glBegin/glEnd, not per-vertex. */ -static void -load_program_parameters(GLcontext *ctx) +void +_mesa_load_tracked_matrices(GLcontext *ctx) { GLuint i; @@ -160,7 +162,7 @@ load_program_parameters(GLcontext *ctx) continue; } - /* load the matrix values into sequential registers */ + /* load the matrix values into sequential registers */ if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) { load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); } @@ -206,7 +208,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) #endif if (ctx->VertexProgram.Current->IsNVProgram) { - load_program_parameters(ctx); + _mesa_load_tracked_matrices(ctx); } else { _mesa_load_state_parameters(ctx, program->Base.Parameters); diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index 17cb30adc7..20bed5546d 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -82,4 +82,7 @@ _tnl_draw_prims( GLcontext *ctx, GLuint min_index, GLuint max_index); +extern void +_mesa_load_tracked_matrices(GLcontext *ctx); + #endif -- cgit v1.2.3 From 197af3dc3242af4cac5213e095ac6639f6c782cd Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 24 Feb 2007 11:16:58 -0700 Subject: Use prog_execute.c to run vertex programs until t_vb_arbprogram.c is updated to handle branch instructions, etc. --- src/mesa/tnl/t_vb_arbprogram.c | 16 +++++----------- src/mesa/tnl/t_vb_program.c | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 1d9a6ac460..b322d48b23 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1151,7 +1151,6 @@ static void compile_vertex_program( struct gl_vertex_program *program, - /* ---------------------------------------------------------------------- * Execution */ @@ -1264,6 +1263,7 @@ static INLINE void call_func( struct tnl_compiled_program *p, p->compiled_func(m); } + /** * Execute the given vertex program. * @@ -1283,7 +1283,7 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) GLuint i, j; GLbitfield outputs; -#define FORCE_PROG_EXECUTE_C 0 +#define FORCE_PROG_EXECUTE_C 1 #if FORCE_PROG_EXECUTE_C return GL_TRUE; #else @@ -1498,11 +1498,6 @@ validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } - - - - - /** * Called the first time stage->run is called. In effect, don't * allocate data until the first time the stage is run. @@ -1563,8 +1558,6 @@ static GLboolean init_vertex_program( GLcontext *ctx, } - - /** * Destructor for this pipeline stage. */ @@ -1589,6 +1582,7 @@ static void dtr( struct tnl_pipeline_stage *stage ) } } + /** * Public description of this pipeline stage. */ diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 72a65f89f1..62c78dc7d1 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -198,7 +198,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) struct gl_program_machine machine; GLuint i; -#define FORCE_PROG_EXECUTE_C 0 +#define FORCE_PROG_EXECUTE_C 1 #if FORCE_PROG_EXECUTE_C if (!program) return GL_TRUE; -- cgit v1.2.3 From 9854a17f292193c9720cf25ab00818ecc210f911 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 12:47:25 -0700 Subject: only copy used outputs --- src/mesa/tnl/t_vb_program.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 62c78dc7d1..82e007a3ac 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -244,7 +244,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) const GLuint size = VB->AttribPtr[attr]->size; const GLuint stride = VB->AttribPtr[attr]->stride; const GLfloat *data = (GLfloat *) (ptr + stride * i); - COPY_CLEAN_4V(machine.VertAttribs/*Inputs*/[attr], size, data); + COPY_CLEAN_4V(machine.VertAttribs[attr], size, data); } } @@ -264,9 +264,10 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } /* copy the output registers into the VB->attribs arrays */ - /* XXX (optimize) could use a conditional and smaller loop limit here */ for (attr = 0; attr < VERT_RESULT_MAX; attr++) { - COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); + if (program->Base.OutputsWritten & (1 << attr)) { + COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); + } } #if 0 printf("HPOS: %f %f %f %f\n", -- cgit v1.2.3 From e71a33bbf87649150bc748b85ca7213af7c737f4 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 17:29:00 -0700 Subject: Optimize the loop for copying output results. --- src/mesa/tnl/t_vb_program.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 82e007a3ac..4ea134a97e 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -196,7 +196,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) struct vertex_buffer *VB = &tnl->vb; struct gl_vertex_program *program = ctx->VertexProgram._Current; struct gl_program_machine machine; - GLuint i; + GLuint outputs[VERT_RESULT_MAX], numOutputs; + GLuint i, j; #define FORCE_PROG_EXECUTE_C 1 #if FORCE_PROG_EXECUTE_C @@ -214,6 +215,13 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) _mesa_load_state_parameters(ctx, program->Base.Parameters); } + numOutputs = 0; + for (i = 0; i < VERT_RESULT_MAX; i++) { + if (program->Base.OutputsWritten & (1 << i)) { + outputs[numOutputs++] = i; + } + } + for (i = 0; i < VB->Count; i++) { GLuint attr; @@ -264,10 +272,9 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } /* copy the output registers into the VB->attribs arrays */ - for (attr = 0; attr < VERT_RESULT_MAX; attr++) { - if (program->Base.OutputsWritten & (1 << attr)) { - COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); - } + for (j = 0; j < numOutputs; j++) { + const GLuint attr = outputs[j]; + COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); } #if 0 printf("HPOS: %f %f %f %f\n", -- cgit v1.2.3 From 29796b62bd4a0f536525c8704577434e2248aab7 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 17:33:46 -0700 Subject: remove unused VaryingPtr --- src/mesa/tnl/t_context.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 733b3a5fe1..31b89aca41 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -217,7 +217,6 @@ struct vertex_buffer GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */ GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */ GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */ - GLvector4f *VaryingPtr[MAX_VARYING]; const struct _mesa_prim *Primitive; GLuint PrimitiveCount; -- cgit v1.2.3 From 12fd8faa5dd10457b2360493e9a56ab12659f282 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 18:08:16 -0700 Subject: s/attribs/results/ --- src/mesa/tnl/t_vb_program.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 4ea134a97e..3fe796ac56 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -49,7 +49,7 @@ */ struct vp_stage_data { /** The results of running the vertex program go into these arrays. */ - GLvector4f attribs[VERT_RESULT_MAX]; + GLvector4f results[VERT_RESULT_MAX]; GLvector4f ndcCoords; /**< normalized device coords */ GLubyte *clipmask; /**< clip flags */ @@ -274,7 +274,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* copy the output registers into the VB->attribs arrays */ for (j = 0; j < numOutputs; j++) { const GLuint attr = outputs[j]; - COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]); + COPY_4V(store->results[attr].data[i], machine.Outputs[attr]); } #if 0 printf("HPOS: %f %f %f %f\n", @@ -288,31 +288,31 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* Setup the VB pointers so that the next pipeline stages get * their data from the right place (the program output arrays). */ - VB->ClipPtr = &store->attribs[VERT_RESULT_HPOS]; + VB->ClipPtr = &store->results[VERT_RESULT_HPOS]; VB->ClipPtr->size = 4; VB->ClipPtr->count = VB->Count; - VB->ColorPtr[0] = &store->attribs[VERT_RESULT_COL0]; - VB->ColorPtr[1] = &store->attribs[VERT_RESULT_BFC0]; - VB->SecondaryColorPtr[0] = &store->attribs[VERT_RESULT_COL1]; - VB->SecondaryColorPtr[1] = &store->attribs[VERT_RESULT_BFC1]; - VB->FogCoordPtr = &store->attribs[VERT_RESULT_FOGC]; + VB->ColorPtr[0] = &store->results[VERT_RESULT_COL0]; + VB->ColorPtr[1] = &store->results[VERT_RESULT_BFC0]; + VB->SecondaryColorPtr[0] = &store->results[VERT_RESULT_COL1]; + VB->SecondaryColorPtr[1] = &store->results[VERT_RESULT_BFC1]; + VB->FogCoordPtr = &store->results[VERT_RESULT_FOGC]; - VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->attribs[VERT_RESULT_COL0]; - VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->attribs[VERT_RESULT_COL1]; - VB->AttribPtr[VERT_ATTRIB_FOG] = &store->attribs[VERT_RESULT_FOGC]; - VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->attribs[VERT_RESULT_PSIZ]; + VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->results[VERT_RESULT_COL0]; + VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->results[VERT_RESULT_COL1]; + VB->AttribPtr[VERT_ATTRIB_FOG] = &store->results[VERT_RESULT_FOGC]; + VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->results[VERT_RESULT_PSIZ]; for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] - = &store->attribs[VERT_RESULT_TEX0 + i]; + = &store->results[VERT_RESULT_TEX0 + i]; } for (i = 0; i < ctx->Const.MaxVarying; i++) { if (program->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { /* Note: varying results get put into the generic attributes */ VB->AttribPtr[VERT_ATTRIB_GENERIC0+i] - = &store->attribs[VERT_RESULT_VAR0 + i]; + = &store->results[VERT_RESULT_VAR0 + i]; } } @@ -374,8 +374,8 @@ static GLboolean init_vp( GLcontext *ctx, /* Allocate arrays of vertex output values */ for (i = 0; i < VERT_RESULT_MAX; i++) { - _mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 ); - store->attribs[i].size = 4; + _mesa_vector4f_alloc( &store->results[i], 0, size, 32 ); + store->results[i].size = 4; } /* a few other misc allocations */ @@ -398,7 +398,7 @@ static void dtr( struct tnl_pipeline_stage *stage ) /* free the vertex program result arrays */ for (i = 0; i < VERT_RESULT_MAX; i++) - _mesa_vector4f_free( &store->attribs[i] ); + _mesa_vector4f_free( &store->results[i] ); /* free misc arrays */ _mesa_vector4f_free( &store->ndcCoords ); -- cgit v1.2.3 From 085d7d59f0e167bb546c4a1675e09631b14fc9f7 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 18:23:37 -0700 Subject: remove unused 'element' parameter from _mesa_execute_program() --- src/mesa/tnl/t_vb_program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 3fe796ac56..05b1a4aaab 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -258,7 +258,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* execute the program */ _mesa_execute_program(ctx, &program->Base, program->Base.NumInstructions, - &machine, 0); + &machine); /* Fixup fog an point size results if needed */ if (ctx->Fog.Enabled && -- cgit v1.2.3 From 8b34b7da4131d2b07037ce062c522fddd614f127 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 25 Feb 2007 18:26:50 -0700 Subject: remove 'maxInst' parameter from _mesa_execute_program() --- src/mesa/tnl/t_vb_program.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 05b1a4aaab..17eefe7032 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -257,8 +257,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } /* execute the program */ - _mesa_execute_program(ctx, &program->Base, program->Base.NumInstructions, - &machine); + _mesa_execute_program(ctx, &program->Base, &machine); /* Fixup fog an point size results if needed */ if (ctx->Fog.Enabled && -- cgit v1.2.3 From fdcbbeb55ecafe119bb98dcedb8492416f5bc966 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 19 Mar 2007 14:44:15 -0600 Subject: Properly compute render_inputs_bitset when using a vertex program/shader. This fixes a performance regression introduced early in glsl-compiler-1 work. --- src/mesa/tnl/t_context.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 3b2f91acba..f665485f42 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -150,13 +150,19 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled)) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); -#if 1 /* XXX NEW_SLANG */ - RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, - _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); -#else - if (ctx->ShaderObjects._VertexShaderPresent || ctx->ShaderObjects._FragmentShaderPresent) - RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); -#endif + /* check for varying vars which are written by the vertex program */ + { + struct gl_vertex_program *vp = ctx->VertexProgram._Current; + if (vp) { + GLuint i; + for (i = 0; i < MAX_VARYING; i++) { + if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + RENDERINPUTS_SET(tnl->render_inputs_bitset, + _TNL_ATTRIB_GENERIC(i)); + } + } + } + } } -- cgit v1.2.3 From 63556fa9949f543a8134b6b5ff3d216acb71dd9f Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 23 Mar 2007 14:47:46 -0600 Subject: Add the ability to generate programs that doesn't use condition codes. ctx->Shader.EmitCondCodes determines if we use condition codes. If not, IF statement uses first operand's X component as the condition. Added OPCODE_BRK0, OPCODE_BRK1, OPCODE_CONT0, OPCODE_CONT1 to handle the common cases of conditional break/continue. --- src/mesa/tnl/t_vb_arbprogram.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index b322d48b23..425a866994 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -741,9 +741,13 @@ static gpu_function opcode_func[MAX_OPCODE+3] = do_NOP,/*BGNSUB*/ do_NOP,/*BRA*/ do_NOP,/*BRK*/ + do_NOP,/*BRK0*/ + do_NOP,/*BRK1*/ do_NOP,/*CAL*/ do_NOP,/*CMP*/ do_NOP,/*CONT*/ + do_NOP,/*CONT0*/ + do_NOP,/*CONT1*/ do_NOP,/*COS*/ do_NOP,/*DDX*/ do_NOP,/*DDY*/ -- cgit v1.2.3 From b50b036ffb795a12106bd59b1a08b0287a8b3388 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 24 Mar 2007 10:16:49 -0600 Subject: When computing render_inputs_bitset, omit primary color if we have a fragment program and it doesn't need FRAG_ATTRIB_COL0. Silences valgrind warnings. --- src/mesa/tnl/t_context.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index f665485f42..fa42a3df98 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -102,6 +102,8 @@ void _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) { TNLcontext *tnl = TNL_CONTEXT(ctx); + const struct gl_vertex_program *vp = ctx->VertexProgram._Current; + const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; if (new_state & (_NEW_HINT)) { ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); @@ -118,7 +120,9 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) RENDERINPUTS_ZERO( tnl->render_inputs_bitset ); RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS ); - RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); + if (!fp || fp->Base.InputsRead & FRAG_BIT_COL0) { + RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); + } for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->Texture._EnabledCoordUnits & (1 << i)) { RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) ); @@ -151,15 +155,12 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); /* check for varying vars which are written by the vertex program */ - { - struct gl_vertex_program *vp = ctx->VertexProgram._Current; - if (vp) { - GLuint i; - for (i = 0; i < MAX_VARYING; i++) { - if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { - RENDERINPUTS_SET(tnl->render_inputs_bitset, - _TNL_ATTRIB_GENERIC(i)); - } + if (vp) { + GLuint i; + for (i = 0; i < MAX_VARYING; i++) { + if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + RENDERINPUTS_SET(tnl->render_inputs_bitset, + _TNL_ATTRIB_GENERIC(i)); } } } -- cgit v1.2.3