From af74abab6b9a1e32a1cc5cac7e547b953dcee0ab Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Sep 2008 10:04:56 +0100 Subject: [PATCH] mesa: get fixed-function program generation working again --- src/mesa/main/state.c | 62 ++++++++++++++++++++++++----------- src/mesa/main/texenvprogram.c | 3 ++ 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 5827f2211c0..e340cd66866 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -219,23 +219,6 @@ update_program(GLcontext *ctx) shProg->FragmentProgram); } else { - if (ctx->VertexProgram._Enabled) { - /* use user-defined vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - ctx->VertexProgram.Current); - } - else if (ctx->VertexProgram._MaintainTnlProgram) { - /* Use vertex program generated from fixed-function state. - * The _Current pointer will get set in - * _tnl_UpdateFixedFunctionProgram() later if appropriate. - */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - } - else { - /* no vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - } - if (ctx->FragmentProgram._Enabled) { /* use user-defined vertex program */ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, @@ -243,15 +226,38 @@ update_program(GLcontext *ctx) } else if (ctx->FragmentProgram._MaintainTexEnvProgram) { /* Use fragment program generated from fixed-function state. - * The _Current pointer will get set in _mesa_UpdateTexEnvProgram() - * later if appropriate. */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + _mesa_get_fixed_func_fragment_program(ctx)); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + ctx->FragmentProgram._Current); } else { /* no fragment program */ _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); } + + /* Examine vertex program after fragment program as + * _mesa_get_fixed_func_vertex_program() needs to know active + * fragprog inputs. + */ + if (ctx->VertexProgram._Enabled) { + /* use user-defined vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + ctx->VertexProgram.Current); + } + else if (ctx->VertexProgram._MaintainTnlProgram) { + /* Use vertex program generated from fixed-function state. + */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + _mesa_get_fixed_func_vertex_program(ctx)); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, + ctx->VertexProgram._Current); + } + else { + /* no vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); + } } if (ctx->VertexProgram._Current) @@ -260,12 +266,28 @@ update_program(GLcontext *ctx) assert(ctx->FragmentProgram._Current->Base.Parameters); + /* XXX: get rid of _Active flag. + */ +#if 1 ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled; if (ctx->FragmentProgram._MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) { if (ctx->FragmentProgram._UseTexEnvProgram) ctx->FragmentProgram._Active = GL_TRUE; } +#endif + + /* Let the driver know what's happening: + */ + if (ctx->FragmentProgram._Current != prevFP && ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, + (struct gl_program *) ctx->FragmentProgram._Current); + } + + if (ctx->VertexProgram._Current != prevVP && ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, + (struct gl_program *) ctx->VertexProgram._Current); + } } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 713ff3d2564..25e280bc3f3 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1190,6 +1190,9 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx) * If _MaintainTexEnvProgram is set we'll generate a fragment program that * implements the current texture env/combine mode. * This function generates that program and puts it into effect. + * + * XXX: remove this function. currently only called by some drivers, + * not by mesa core. We now handle this properly from inside mesa. */ void _mesa_UpdateTexEnvProgram( GLcontext *ctx ) -- 2.30.2