mesa: another fix for program/texture state validation

This fixes a regression introduced in 46ae1abbac

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.
This commit is contained in:
Brian Paul
2009-02-10 16:28:25 -07:00
parent c936a6083e
commit 537d3ed6f3

View File

@@ -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 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. */ /* These _Enabled flags indicate if the program is enabled AND valid. */
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
&& ctx->VertexProgram.Current->Base.Instructions; && ctx->VertexProgram.Current->Base.Instructions;
@@ -187,6 +190,25 @@ update_program(GLcontext *ctx)
&& ctx->FragmentProgram.Current->Base.Instructions; && ctx->FragmentProgram.Current->Base.Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
&& ctx->ATIFragmentShader.Current->Instructions[0]; && 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 * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
@@ -429,6 +451,7 @@ _mesa_update_state_locked( GLcontext *ctx )
if (MESA_VERBOSE & VERBOSE_STATE) if (MESA_VERBOSE & VERBOSE_STATE)
_mesa_print_state("_mesa_update_state", new_state); _mesa_print_state("_mesa_update_state", new_state);
/* Determine which state flags effect vertex/fragment program state */
if (ctx->FragmentProgram._MaintainTexEnvProgram) { if (ctx->FragmentProgram._MaintainTexEnvProgram) {
prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR); prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
} }
@@ -438,8 +461,13 @@ _mesa_update_state_locked( GLcontext *ctx )
_NEW_FOG | _NEW_LIGHT | _NEW_FOG | _NEW_LIGHT |
_MESA_NEW_NEED_EYE_COORDS); _MESA_NEW_NEED_EYE_COORDS);
} }
/*
* Now update derived state info
*/
if (new_state & prog_flags) if (new_state & prog_flags)
update_program( ctx ); update_program_enables( ctx );
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_update_modelview_project( ctx, new_state ); _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) if (new_state & _MESA_NEW_NEED_EYE_COORDS)
_mesa_update_tnl_spaces( ctx, new_state ); _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. * Give the driver a chance to act upon the new_state flags.