summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_vp_build.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-05-10 13:57:50 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-05-10 13:57:50 +0000
commitdbeea25bb834479a29712100888c862348112018 (patch)
treed232684123377493b1cb2ed788fb1238788439c9 /src/mesa/tnl/t_vp_build.c
parentf29f2fc29464780eea6d877569cd5b7032266b88 (diff)
Double-buffer generated instructions and only notify driver when the
generated program differs from the previous one.
Diffstat (limited to 'src/mesa/tnl/t_vp_build.c')
-rw-r--r--src/mesa/tnl/t_vp_build.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 22dc595abb..04af02e491 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -317,6 +317,8 @@ static void emit_op3fn(struct tnl_program *p,
struct vp_instruction *inst = &p->program->Instructions[nr];
inst->Opcode = op;
+ inst->StringPos = 0;
+ inst->Data = 0;
emit_arg( &inst->SrcReg[0], src0 );
emit_arg( &inst->SrcReg[1], src1 );
@@ -1094,6 +1096,8 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct tnl_program p;
+ GLuint db_NumInstructions;
+ struct vp_instruction *db_Instructions;
if (ctx->VertexProgram._Enabled)
return;
@@ -1114,9 +1118,10 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
p.temp_flag = 0;
p.temp_reserved = ~((1<<MAX_NV_VERTEX_PROGRAM_TEMPS)-1);
- if (p.program->Instructions == NULL) {
- p.program->Instructions = MALLOC(sizeof(struct vp_instruction) * 100);
- }
+ db_Instructions = p.program->Instructions;
+ db_NumInstructions = p.program->Base.NumInstructions;
+
+ p.program->Instructions = MALLOC(sizeof(struct vp_instruction) * 100);
/* Initialize the arb_program struct */
p.program->Base.String = 0;
@@ -1124,9 +1129,12 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
p.program->Base.NumTemporaries =
p.program->Base.NumParameters =
p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
+
if (p.program->Parameters)
- _mesa_free_parameter_list(p.program->Parameters);
- p.program->Parameters = _mesa_new_parameter_list();
+ _mesa_free_parameters(p.program->Parameters);
+ else
+ p.program->Parameters = _mesa_new_parameter_list();
+
p.program->InputsRead = 0;
p.program->OutputsWritten = 0;
@@ -1167,4 +1175,18 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
if (DISASSEM) {
_mesa_printf ("\n");
}
+
+
+ /* Notify driver the fragment program has (actually) changed.
+ */
+ if (db_Instructions == NULL ||
+ db_NumInstructions != p.program->Base.NumInstructions ||
+ memcmp(db_Instructions, p.program->Instructions,
+ db_NumInstructions * sizeof(*db_Instructions)) != 0) {
+ _mesa_printf("new program string\n");
+ ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
+ &p.program->Base );
+ }
+
+ FREE(db_Instructions);
}