diff options
author | Brian <[email protected]> | 2007-10-29 11:30:09 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-10-29 15:15:34 -0600 |
commit | 27153bf02dab57d11565fa7730de4767618ce62d (patch) | |
tree | 4573a5a48eaf5ed102db616aa139d89166e9b04d /src/mesa/tnl/t_vp_build.c | |
parent | 83ce6c51d7189094cf2a13fdcc0882a051a3bd41 (diff) |
Refactor _tnl_UpdateFixedFunctionProgram().
New _mesa_get_fixed_func_vertex_program() function...
Diffstat (limited to 'src/mesa/tnl/t_vp_build.c')
-rw-r--r-- | src/mesa/tnl/t_vp_build.c | 81 |
1 files changed, 49 insertions, 32 deletions
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index dc2d5e0065a..86c6ccc1c0e 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1534,49 +1534,66 @@ static GLuint hash_key( struct state_key *key ) return hash; } -void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) + +/** + * Return a vertex program which implements the current fixed-function + * transform/lighting/texgen operations. + * XXX move this into core mesa (main/) + */ +struct gl_vertex_program * +_mesa_get_fixed_func_vertex_program(GLcontext *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); + struct gl_vertex_program *prog; struct state_key *key; GLuint hash; - const struct gl_vertex_program *prev = ctx->VertexProgram._Current; - if (!ctx->VertexProgram._Current || - ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) { - /* Grab all the relevent state and put it in a single structure: - */ - key = make_state_key(ctx); - hash = hash_key(key); + /* Grab all the relevent state and put it in a single structure: + */ + key = make_state_key(ctx); + hash = hash_key(key); - /* Look for an already-prepared program for this state: - */ - ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *) - search_cache( tnl->vp_cache, hash, key, sizeof(*key) ); + /* Look for an already-prepared program for this state: + */ + prog = (struct gl_vertex_program *) + search_cache( tnl->vp_cache, hash, key, sizeof(*key) ); - /* OK, we'll have to build a new one: - */ - if (!ctx->VertexProgram._TnlProgram) { - if (0) - _mesa_printf("Build new TNL program\n"); + if (!prog) { + /* OK, we'll have to build a new one */ + if (0) + _mesa_printf("Build new TNL program\n"); - ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + prog = (struct gl_vertex_program *) + ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); - create_new_program( key, ctx->VertexProgram._TnlProgram, - ctx->Const.VertexProgram.MaxTemps ); + create_new_program( key, prog, + ctx->Const.VertexProgram.MaxTemps ); - if (ctx->Driver.ProgramStringNotify) - ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, - &ctx->VertexProgram._TnlProgram->Base ); +#if 0 + if (ctx->Driver.ProgramStringNotify) + ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, + &prog->Base ); +#endif + cache_item(tnl->vp_cache, hash, key, prog); + } + else { + /* use cached program */ + _mesa_free(key); + } - 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->VertexProgram._TnlProgram; + return prog; +} + + +void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx ) +{ + const struct gl_vertex_program *prev = ctx->VertexProgram._Current; + + if (!ctx->VertexProgram._Current || + ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) { + ctx->VertexProgram._Current + = ctx->VertexProgram._TnlProgram + = _mesa_get_fixed_func_vertex_program(ctx); } /* Tell the driver about the change. Could define a new target for |