From: Brian Paul Date: Tue, 10 Feb 2009 23:28:25 +0000 (-0700) Subject: mesa: another fix for program/texture state validation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=537d3ed6f3112fdf16fd853ada0e0bcc8bd83227;p=mesa.git mesa: another fix for program/texture state validation This fixes a regression introduced in 46ae1abbac6837d051c10b2e8b57eab3d4958ff4 Break program validation into two steps, do part before texture state validation and do the rest after: 1. Determine Vertex/Fragment _Enabled state. 2. Update texture state. 3. Determine pointers to current Vertex/Fragment programs (which may involve generating new "fixed-function" programs). See comments in the code for more details of the dependencies. --- diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 19d58b596f2..3cf70d6a3ca 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -173,13 +173,16 @@ update_arrays( GLcontext *ctx ) } +/** + * Update the following fields: + * ctx->VertexProgram._Enabled + * ctx->FragmentProgram._Enabled + * ctx->ATIFragmentShader._Enabled + * This needs to be done before texture state validation. + */ static void -update_program(GLcontext *ctx) +update_program_enables(GLcontext *ctx) { - const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; - const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; - const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; - /* These _Enabled flags indicate if the program is enabled AND valid. */ ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled && ctx->VertexProgram.Current->Base.Instructions; @@ -187,6 +190,25 @@ update_program(GLcontext *ctx) && ctx->FragmentProgram.Current->Base.Instructions; ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled && ctx->ATIFragmentShader.Current->Instructions[0]; +} + + +/** + * Update vertex/fragment program state. In particular, update these fields: + * ctx->VertexProgram._Current + * ctx->VertexProgram._TnlProgram, + * These point to the highest priority enabled vertex/fragment program or are + * NULL if fixed-function processing is to be done. + * + * This function needs to be called after texture state validation in case + * we're generating a fragment program from fixed-function texture state. + */ +static void +update_program(GLcontext *ctx) +{ + const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; + const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; + const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; /* * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current @@ -429,6 +451,7 @@ _mesa_update_state_locked( GLcontext *ctx ) if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); + /* Determine which state flags effect vertex/fragment program state */ if (ctx->FragmentProgram._MaintainTexEnvProgram) { prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR); } @@ -438,8 +461,13 @@ _mesa_update_state_locked( GLcontext *ctx ) _NEW_FOG | _NEW_LIGHT | _MESA_NEW_NEED_EYE_COORDS); } + + /* + * Now update derived state info + */ + if (new_state & prog_flags) - update_program( ctx ); + update_program_enables( ctx ); if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) _mesa_update_modelview_project( ctx, new_state ); @@ -500,6 +528,8 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _MESA_NEW_NEED_EYE_COORDS) _mesa_update_tnl_spaces( ctx, new_state ); + if (new_state & prog_flags) + update_program( ctx ); /* * Give the driver a chance to act upon the new_state flags.