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.
This commit is contained in:
Brian
2006-12-13 14:58:13 -07:00
parent fe1d01cb39
commit a328e469d3
16 changed files with 333 additions and 303 deletions

View File

@@ -86,7 +86,7 @@ _tnl_CreateContext( GLcontext *ctx )
_tnl_array_init( ctx ); _tnl_array_init( ctx );
_tnl_vtx_init( ctx ); _tnl_vtx_init( ctx );
if (ctx->_MaintainTnlProgram) { if (ctx->VertexProgram._MaintainTnlProgram) {
_tnl_ProgramCacheInit( ctx ); _tnl_ProgramCacheInit( ctx );
_tnl_install_pipeline( ctx, _tnl_vp_pipeline ); _tnl_install_pipeline( ctx, _tnl_vp_pipeline );
} else { } else {
@@ -136,7 +136,7 @@ _tnl_DestroyContext( GLcontext *ctx )
_tnl_destroy_pipeline( ctx ); _tnl_destroy_pipeline( ctx );
_ae_destroy_context( ctx ); _ae_destroy_context( ctx );
if (ctx->_MaintainTnlProgram) if (ctx->VertexProgram._MaintainTnlProgram)
_tnl_ProgramCacheDestroy( ctx ); _tnl_ProgramCacheDestroy( ctx );
FREE(tnl); FREE(tnl);
@@ -183,7 +183,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
} }
if (ctx->Fog.Enabled || if (ctx->Fog.Enabled ||
(ctx->FragmentProgram._Active && (ctx->FragmentProgram._Current &&
(ctx->FragmentProgram._Current->FogOption != GL_NONE || (ctx->FragmentProgram._Current->FogOption != GL_NONE ||
ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC))) ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC)))
RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); 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)) (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); 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) if (ctx->ShaderObjects._VertexShaderPresent || ctx->ShaderObjects._FragmentShaderPresent)
RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC ); RENDERINPUTS_SET_RANGE( tnl->render_inputs_bitset, _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC );
#endif
} }

View File

@@ -132,7 +132,7 @@ void _tnl_run_pipeline( GLcontext *ctx )
* (ie const or non-const). * (ie const or non-const).
*/ */
if (check_input_changes( ctx ) || tnl->pipeline.new_state) { if (check_input_changes( ctx ) || tnl->pipeline.new_state) {
if (ctx->_MaintainTnlProgram) if (ctx->VertexProgram._MaintainTnlProgram)
_tnl_UpdateFixedFunctionProgram( ctx ); _tnl_UpdateFixedFunctionProgram( ctx );
for (i = 0; i < tnl->pipeline.nr_stages ; i++) { 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) #if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
&_tnl_arb_vertex_program_stage, &_tnl_arb_vertex_program_stage,
&_tnl_vertex_program_stage, &_tnl_vertex_program_stage,
#endif
#if FEATURE_ARB_vertex_shader
&_tnl_arb_vertex_shader_stage,
#endif #endif
&_tnl_render_stage, &_tnl_render_stage,
NULL NULL

View File

@@ -37,6 +37,7 @@
#include "arbprogparse.h" #include "arbprogparse.h"
#include "light.h" #include "light.h"
#include "program.h" #include "program.h"
#include "programopt.h"
#include "math/m_matrix.h" #include "math/m_matrix.h"
#include "t_context.h" #include "t_context.h"
#include "t_pipeline.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]; GLfloat *result = m->File[0][op.alu.dst];
const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0]; const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
result[0] = (GLfloat)ApproxExp2(arg0[0]); result[0] = ApproxExp2(arg0[0]);
PUFF(result); PUFF(result);
} }
@@ -566,7 +567,7 @@ static void print_reg( GLuint file, GLuint reg )
_mesa_printf("TMP%d", reg - REG_TMP0); _mesa_printf("TMP%d", reg - REG_TMP0);
else if (reg >= REG_IN0 && reg <= REG_IN31) else if (reg >= REG_IN0 && reg <= REG_IN31)
_mesa_printf("IN%d", reg - REG_IN0); _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); _mesa_printf("OUT%d", reg - REG_OUT0);
else if (reg == REG_ADDR) else if (reg == REG_ADDR)
_mesa_printf("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) = static void (* const opcode_func[MAX_OPCODE+3])(struct arb_vp_machine *, union instruction) =
{ {
do_NOP,
do_ABS, do_ABS,
do_ADD, do_ADD,
do_NOP,/*ARA*/ do_NOP,/*ARA*/
@@ -853,6 +855,7 @@ static struct reg cvp_load_reg( struct compilation *cp,
return reg; return reg;
case PROGRAM_STATE_VAR: case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT:
reg = cvp_make_reg(FILE_STATE_PARAM, index); reg = cvp_make_reg(FILE_STATE_PARAM, index);
if (rel) if (rel)
return cvp_emit_rel(cp, reg, tmpreg); 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); struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
GLuint i; 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) if (program->TnlData)
free_tnl_data( program ); 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. /* Test userclip planes. This contributes to VB->ClipMask.
*/ */
/** XXX NEW_SLANG _Enabled ??? */
if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled || if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
ctx->VertexProgram.Current->IsPositionInvariant)) { ctx->VertexProgram.Current->IsPositionInvariant)) {
userclip( ctx, userclip( ctx,
@@ -1221,21 +1235,14 @@ static INLINE void call_func( struct tnl_compiled_program *p,
static GLboolean static GLboolean
run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) 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 vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct arb_vp_machine *m = ARB_VP_MACHINE(stage); struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
struct tnl_compiled_program *p; struct tnl_compiled_program *p;
GLuint i, j; GLuint i, j;
GLbitfield outputs; GLbitfield outputs;
if (ctx->ShaderObjects._VertexShaderPresent) if (!program)
return GL_TRUE;
program = ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : NULL;
if (!program && ctx->_MaintainTnlProgram) {
program = ctx->_TnlProgram;
}
if (!program || program->IsNVProgram)
return GL_TRUE; return GL_TRUE;
if (program->Base.Parameters) { 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 /* If the program is position invariant, multiply the input position
* by the MVP matrix and store in the vertex position result register. * by the MVP matrix and store in the vertex position result register.
*/ */
#if 0
if (program->IsPositionInvariant) { if (program->IsPositionInvariant) {
TRANSFORM_POINT( m->File[0][REG_OUT0+0], TRANSFORM_POINT( m->File[0][REG_OUT0+0],
ctx->_ModelProjectMatrix.m, ctx->_ModelProjectMatrix.m,
m->File[0][REG_IN0+0]); m->File[0][REG_IN0+0]);
} }
#endif
for (j = 0; j < m->nr_outputs; j++) { for (j = 0; j < m->nr_outputs; j++) {
GLuint idx = REG_OUT0 + m->output[j].idx; GLuint idx = REG_OUT0 + m->output[j].idx;
m->output[j].data[0] = m->File[0][idx][0]; 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 #if 0
for (i = 0; i < VB->Count; i++) { for (i = 0; i < VB->Count; i++) {
printf("Out %d: %f %f %f %f %f %f %f %f\n", 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 ) validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage )
{ {
struct arb_vp_machine *m = ARB_VP_MACHINE(stage); struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
struct gl_vertex_program *program; struct gl_vertex_program *program = ctx->VertexProgram._Current;
if (ctx->ShaderObjects._VertexShaderPresent)
return;
program = (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : 0);
if (!program && ctx->_MaintainTnlProgram) {
program = ctx->_TnlProgram;
}
if (program) { if (program) {
if (!program->TnlData) if (!program->TnlData)
@@ -1472,7 +1480,7 @@ static GLboolean init_vertex_program( GLcontext *ctx,
_mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 ); _mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 );
m->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*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 ); _mesa_allow_light_in_model( ctx, GL_FALSE );
m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */ m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */
@@ -1529,7 +1537,7 @@ const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage =
void void
_tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program) _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 */ /* free any existing tnl data hanging off the program */
struct gl_vertex_program *vprog = (struct gl_vertex_program *) program; struct gl_vertex_program *vprog = (struct gl_vertex_program *) program;
if (vprog->TnlData) { if (vprog->TnlData) {

View File

@@ -56,6 +56,22 @@
#define REG_TMP0 5 #define REG_TMP0 5
#define REG_TMP11 16 #define REG_TMP11 16
#define REG_OUT0 17 #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_OUT14 31
#define REG_IN0 32 #define REG_IN0 32
#define REG_IN31 63 #define REG_IN31 63
@@ -69,6 +85,7 @@
#define REG_UNDEF 127 /* special case - never used */ #define REG_UNDEF 127 /* special case - never used */
#define REG_MAX 128 #define REG_MAX 128
#define REG_INVALID ~0 #define REG_INVALID ~0
#endif
/* ARB_vp instructions are broken down into one or more of the /* ARB_vp instructions are broken down into one or more of the
* following micro-instructions, each representable in a 64 bit packed * following micro-instructions, each representable in a 64 bit packed
@@ -76,16 +93,16 @@
*/ */
struct reg { struct reg {
GLuint file:2; GLuint file:2;
GLuint idx:7; GLuint idx:8;
}; };
union instruction { union instruction {
struct { struct {
GLuint opcode:7; GLuint opcode:7;
GLuint dst:5; GLuint dst:6;
GLuint file0:2; GLuint file0:2;
GLuint idx0:7; GLuint idx0:8;
GLuint file1:2; GLuint file1:2;
GLuint idx1:7; GLuint idx1:7;
GLuint pad:2; GLuint pad:2;
@@ -94,18 +111,18 @@ union instruction {
struct { struct {
GLuint opcode:7; GLuint opcode:7;
GLuint dst:5; GLuint dst:6;
GLuint file0:2; GLuint file0:2;
GLuint idx0:7; GLuint idx0:8;
GLuint neg:4; GLuint neg:4;
GLuint swz:12; /* xyzw01 */ GLuint swz:12; /* xyzw01 */
} rsw; } rsw;
struct { struct {
GLuint opcode:7; GLuint opcode:7;
GLuint dst:5; GLuint dst:6;
GLuint file:2; GLuint file:2;
GLuint idx:7; GLuint idx:8;
GLuint mask:4; GLuint mask:4;
GLuint pad:7; GLuint pad:7;
GLuint pad2; GLuint pad2;

View File

@@ -48,7 +48,8 @@ typedef struct
#define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr) #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); TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *vb = &tnl->vb; struct vertex_buffer *vb = &tnl->vb;
@@ -61,13 +62,11 @@ static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipelin
if (store == NULL) if (store == NULL)
return GL_FALSE; return GL_FALSE;
for (i = 0; i < VERT_RESULT_MAX; i++) for (i = 0; i < VERT_RESULT_MAX; i++) {
{
_mesa_vector4f_alloc(&store->outputs[i], 0, size, 32); _mesa_vector4f_alloc(&store->outputs[i], 0, size, 32);
store->outputs[i].size = 4; store->outputs[i].size = 4;
} }
for (i = 0; i < MAX_VARYING_VECTORS; i++) for (i = 0; i < MAX_VARYING_VECTORS; i++) {
{
_mesa_vector4f_alloc(&store->varyings[i], 0, size, 32); _mesa_vector4f_alloc(&store->varyings[i], 0, size, 32);
store->varyings[i].size = 4; store->varyings[i].size = 4;
} }
@@ -77,12 +76,12 @@ static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipelin
return GL_TRUE; 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); arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
if (store != NULL) if (store != NULL) {
{
GLuint i; GLuint i;
for (i = 0; i < VERT_RESULT_MAX; i++) for (i = 0; i < VERT_RESULT_MAX; i++)
@@ -97,12 +96,14 @@ static void destruct_arb_vertex_shader (struct tnl_pipeline_stage *stage)
} }
} }
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, static GLvoid
struct vertex_buffer *vb) 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 GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
const GLuint stride = vb->AttribPtr[attr]->stride; const GLuint stride = vb->AttribPtr[attr]->stride;
@@ -111,18 +112,21 @@ static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GL
(**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, static GLvoid
struct vertex_buffer *vb) 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 GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
const GLuint stride = vb->AttribPtr[attr]->stride; const GLuint stride = vb->AttribPtr[attr]->stride;
GLfloat *data = (GLfloat *) (ptr + stride * i); 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, static void
struct vertex_buffer *vb) 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 GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
const GLuint size = vb->AttribPtr[attr]->size; const GLuint size = vb->AttribPtr[attr]->size;
@@ -130,8 +134,7 @@ static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuin
const GLfloat *data = (const GLfloat *) (ptr + stride * i); const GLfloat *data = (const GLfloat *) (ptr + stride * i);
GLfloat vec[4]; GLfloat vec[4];
switch (size) switch (size) {
{
case 2: case 2:
vec[0] = data[0]; vec[0] = data[0];
vec[1] = data[1]; vec[1] = data[1];
@@ -151,11 +154,13 @@ static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuin
vec[3] = data[3]; vec[3] = data[3];
break; break;
} }
(**pro).UpdateFixedAttrib (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE); (**pro).UpdateFixedAttrib(pro, index, vec, 0, 4 * sizeof(GLfloat),
GL_TRUE);
} }
static GLvoid 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 GLuint attr = _TNL_ATTRIB_GENERIC0 + index;
const GLubyte *ptr = (const GLubyte *) (vb->AttribPtr[attr]->data); const GLubyte *ptr = (const GLubyte *) (vb->AttribPtr[attr]->data);
@@ -165,21 +170,24 @@ fetch_gen_attrib (struct gl2_program_intf **pro, GLuint index, GLuint i, struct
(**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, static GLvoid
arbvs_stage_data *store) 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), (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i], 0,
GL_FALSE); sizeof(GLfloat), GL_FALSE);
} }
static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i, static void
GLuint offset, arbvs_stage_data *store) 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, (**pro).UpdateFixedAttrib(pro, index, &store->outputs[attr].data[i],
4 * sizeof (GLfloat), GL_FALSE); 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); TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *vb = &tnl->vb; struct vertex_buffer *vb = &tnl->vb;
@@ -187,49 +195,71 @@ static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
struct gl2_program_intf **pro; struct gl2_program_intf **pro;
GLsizei i, j; GLsizei i, j;
#if 00
if (!ctx->ShaderObjects._VertexShaderPresent) if (!ctx->ShaderObjects._VertexShaderPresent)
return GL_TRUE; return GL_TRUE;
#else
return GL_TRUE;
#endif
pro = ctx->ShaderObjects.CurrentProgram; pro = ctx->ShaderObjects.CurrentProgram;
(**pro).UpdateFixedUniforms(pro); (**pro).UpdateFixedUniforms(pro);
for (i = 0; i < vb->Count; i++) for (i = 0; i < vb->Count; i++) {
{ fetch_input_vec4(pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb); vb);
fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb); fetch_input_vec3(pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb); vb);
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb); fetch_input_vec4(pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i,
fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb); vb);
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb); fetch_input_vec4(pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb); _TNL_ATTRIB_COLOR1, i, vb);
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb); fetch_input_float(pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb); vb);
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb); fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb); _TNL_ATTRIB_TEX0, i, vb);
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb); fetch_input_vec4(pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1,
fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb); _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++) for (j = 0; j < MAX_VERTEX_ATTRIBS; j++)
fetch_gen_attrib(pro, j, i, vb); fetch_gen_attrib(pro, j, i, vb);
_slang_exec_vertex_shader(pro); _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_POSITION, VERT_RESULT_HPOS, i,
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store); 0, store);
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store); fetch_output_vec4(pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0,
fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store); 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++) for (j = 0; j < 8; j++)
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store); fetch_output_vec4(pro, SLANG_VERTEX_FIXED_TEXCOORD,
fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store); VERT_RESULT_TEX0 + j, i, j, store);
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store); fetch_output_float(pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ,
fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store); 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 */ /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */
for (j = 0; j < MAX_VARYING_VECTORS; j++) for (j = 0; j < MAX_VARYING_VECTORS; j++) {
{
GLuint k; GLuint k;
for (k = 0; k < VARYINGS_PER_VECTOR; k++) for (k = 0; k < VARYINGS_PER_VECTOR; k++) {
{
(**pro).UpdateVarying(pro, j * VARYINGS_PER_VECTOR + k, (**pro).UpdateVarying(pro, j * VARYINGS_PER_VECTOR + k,
&store->varyings[j].data[i][k], GL_TRUE); &store->varyings[j].data[i][k], GL_TRUE);
} }
@@ -250,7 +280,8 @@ static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
vb->TexCoordPtr[i] = vb->TexCoordPtr[i] =
vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->outputs[VERT_RESULT_TEX0 + i]; vb->AttribPtr[VERT_ATTRIB_TEX0 + i] =
&store->outputs[VERT_RESULT_TEX0 + i];
} }
vb->FogCoordPtr = vb->FogCoordPtr =
@@ -266,15 +297,16 @@ static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
store->ormask = 0; store->ormask = 0;
store->andmask = CLIP_FRUSTUM_BITS; store->andmask = CLIP_FRUSTUM_BITS;
if (tnl->NeedNdcCoords) if (tnl->NeedNdcCoords) {
{ vb->NdcPtr =
vb->NdcPtr = _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords, _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords,
store->clipmask, &store->ormask, &store->andmask); store->clipmask, &store->ormask,
&store->andmask);
} }
else else {
{
vb->NdcPtr = NULL; vb->NdcPtr = NULL;
_mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, store->clipmask, &store->ormask, _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL,
store->clipmask, &store->ormask,
&store->andmask); &store->andmask);
} }
@@ -298,4 +330,3 @@ const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = {
}; };
#endif /* FEATURE_ARB_vertex_shader */ #endif /* FEATURE_ARB_vertex_shader */

View File

@@ -57,10 +57,7 @@ static GLboolean run_cull_stage( GLcontext *ctx,
GLuint count = VB->Count; GLuint count = VB->Count;
GLuint i; GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent) if (ctx->VertexProgram._Current ||
return GL_TRUE;
if (ctx->VertexProgram._Enabled ||
!ctx->Transform.CullVertexFlag) !ctx->Transform.CullVertexFlag)
return GL_TRUE; return GL_TRUE;

View File

@@ -148,10 +148,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
struct fog_stage_data *store = FOG_STAGE_DATA(stage); struct fog_stage_data *store = FOG_STAGE_DATA(stage);
GLvector4f *input; GLvector4f *input;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Fog.Enabled || ctx->VertexProgram._Current)
return GL_TRUE;
if (!ctx->Fog.Enabled || ctx->VertexProgram._Enabled)
return GL_TRUE; return GL_TRUE;

View File

@@ -203,10 +203,7 @@ static GLboolean run_lighting( GLcontext *ctx,
GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
GLuint idx; GLuint idx;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
return GL_TRUE;
if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
return GL_TRUE; return GL_TRUE;
/* Make sure we can talk about position x,y and z: /* Make sure we can talk about position x,y and z:
@@ -264,10 +261,7 @@ static void validate_lighting( GLcontext *ctx,
{ {
light_func *tab; light_func *tab;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
return;
if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
return; return;
if (ctx->Visual.rgbMode) { if (ctx->Visual.rgbMode) {

View File

@@ -95,12 +95,7 @@ validate_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{ {
struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
if (ctx->ShaderObjects._VertexShaderPresent) { if (ctx->VertexProgram._Current ||
store->NormalTransform = NULL;
return;
}
if (ctx->VertexProgram._Enabled ||
(!ctx->Light.Enabled && (!ctx->Light.Enabled &&
!(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) { !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) {
store->NormalTransform = NULL; store->NormalTransform = NULL;

View File

@@ -47,10 +47,7 @@ struct point_stage_data {
static GLboolean static GLboolean
run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{ {
if (ctx->ShaderObjects._VertexShaderPresent) if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) {
return GL_TRUE;
if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) {
struct point_stage_data *store = POINT_STAGE_DATA(stage); struct point_stage_data *store = POINT_STAGE_DATA(stage);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data; const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data;

View File

@@ -39,6 +39,7 @@
#include "light.h" #include "light.h"
#include "macros.h" #include "macros.h"
#include "imports.h" #include "imports.h"
#include "program.h"
#include "simple_list.h" #include "simple_list.h"
#include "mtypes.h" #include "mtypes.h"
#include "program_instruction.h" #include "program_instruction.h"
@@ -55,7 +56,7 @@
*/ */
struct vp_stage_data { struct vp_stage_data {
/** The results of running the vertex program go into these arrays. */ /** The results of running the vertex program go into these arrays. */
GLvector4f attribs[15]; GLvector4f attribs[VERT_RESULT_MAX];
GLvector4f ndcCoords; /**< normalized device coords */ GLvector4f ndcCoords; /**< normalized device coords */
GLubyte *clipmask; /**< clip flags */ GLubyte *clipmask; /**< clip flags */
@@ -75,16 +76,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
TNLcontext *tnl = TNL_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vp_stage_data *store = VP_STAGE_DATA(stage); struct vp_stage_data *store = VP_STAGE_DATA(stage);
struct vertex_buffer *VB = &tnl->vb; 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; struct vp_machine machine;
GLuint i; GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent) if (!program || !program->IsNVProgram)
return GL_TRUE; return GL_TRUE;
if (!ctx->VertexProgram._Enabled || _mesa_load_state_parameters(ctx, program->Base.Parameters);
!program->IsNVProgram)
return GL_TRUE;
/* load program parameter registers (they're read-only) */ /* load program parameter registers (they're read-only) */
_mesa_init_vp_per_primitive_registers(ctx); _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 */ /* copy the output registers into the VB->attribs arrays */
/* XXX (optimize) could use a conditional and smaller loop limit here */ /* 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]); 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 /* Setup the VB pointers so that the next pipeline stages get
@@ -227,8 +233,7 @@ static GLboolean init_vp( GLcontext *ctx,
return GL_FALSE; return GL_FALSE;
/* Allocate arrays of vertex output values */ /* Allocate arrays of vertex output values */
/* XXX change '15' to a named constant */ for (i = 0; i < VERT_RESULT_MAX; i++) {
for (i = 0; i < 15; i++) {
_mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 ); _mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 );
store->attribs[i].size = 4; store->attribs[i].size = 4;
} }

View File

@@ -488,10 +488,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx,
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
GLuint i; GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current)
return GL_TRUE;
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
return GL_TRUE; return GL_TRUE;
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { 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); struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
GLuint i; GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current)
return;
if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
return; return;
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {

View File

@@ -61,10 +61,7 @@ static GLboolean run_texmat_stage( GLcontext *ctx,
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLuint i; GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent) if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Current)
return GL_TRUE;
if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Enabled)
return GL_TRUE; return GL_TRUE;
/* ENABLE_TEXMAT implies that the texture matrix is not the /* ENABLE_TEXMAT implies that the texture matrix is not the

View File

@@ -126,10 +126,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
TNLcontext *tnl = TNL_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb; struct vertex_buffer *VB = &tnl->vb;
if (ctx->ShaderObjects._VertexShaderPresent) if (ctx->VertexProgram._Current)
return GL_TRUE;
if (ctx->VertexProgram._Enabled)
return GL_TRUE; return GL_TRUE;
if (ctx->_NeedEyeCoords) { if (ctx->_NeedEyeCoords) {

View File

@@ -382,11 +382,14 @@ static struct ureg register_const4f( struct tnl_program *p,
{ {
GLfloat values[4]; GLfloat values[4];
GLint idx; GLint idx;
GLuint swizzle;
values[0] = s0; values[0] = s0;
values[1] = s1; values[1] = s1;
values[2] = s2; values[2] = s2;
values[3] = s3; 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); return make_ureg(PROGRAM_STATE_VAR, idx);
} }
@@ -1495,7 +1498,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
GLuint hash; GLuint hash;
const struct gl_vertex_program *prev = ctx->VertexProgram._Current; 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: /* Grab all the relevent state and put it in a single structure:
*/ */
key = make_state_key(ctx); key = make_state_key(ctx);
@@ -1503,46 +1506,43 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
/* Look for an already-prepared program for this state: /* 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) ); search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
/* OK, we'll have to build a new one: /* OK, we'll have to build a new one:
*/ */
if (!ctx->_TnlProgram) { if (!ctx->VertexProgram._TnlProgram) {
if (0) if (0)
_mesa_printf("Build new TNL program\n"); _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); 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 ); ctx->Const.VertexProgram.MaxTemps );
if (ctx->Driver.ProgramStringNotify) if (ctx->Driver.ProgramStringNotify)
ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, 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 { else {
FREE(key); FREE(key);
if (0) if (0)
_mesa_printf("Found existing TNL program for key %x\n", hash); _mesa_printf("Found existing TNL program for key %x\n", hash);
} }
ctx->VertexProgram._Current = ctx->_TnlProgram; ctx->VertexProgram._Current = ctx->VertexProgram._TnlProgram;
}
else {
ctx->VertexProgram._Current = ctx->VertexProgram.Current;
} }
/* Tell the driver about the change. Could define a new target for /* Tell the driver about the change. Could define a new target for
* this? * this?
*/ */
if (ctx->VertexProgram._Current != prev && if (ctx->VertexProgram._Current != prev && ctx->Driver.BindProgram) {
ctx->Driver.BindProgram)
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
(struct gl_program *) ctx->VertexProgram._Current); (struct gl_program *) ctx->VertexProgram._Current);
} }
}
void _tnl_ProgramCacheInit( GLcontext *ctx ) void _tnl_ProgramCacheInit( GLcontext *ctx )
{ {

View File

@@ -123,8 +123,7 @@ void _tnl_update_eval( GLcontext *ctx )
* We do this after the conventional attributes since the spec says that * We do this after the conventional attributes since the spec says that
* these generic maps have higher priority. * these generic maps have higher priority.
*/ */
if (ctx->VertexProgram._Enabled && if (ctx->VertexProgram._Current &&
ctx->VertexProgram._Current &&
ctx->VertexProgram._Current->IsNVProgram) { ctx->VertexProgram._Current->IsNVProgram) {
for (attr = 0; attr < 16; attr++) { for (attr = 0; attr < 16; attr++) {
if (ctx->Eval.Map1Attrib[attr]) if (ctx->Eval.Map1Attrib[attr])