We need to call _mesa_load_state_parameters() whenever a fragment program
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 31 Oct 2006 16:02:56 +0000 (16:02 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 31 Oct 2006 16:02:56 +0000 (16:02 +0000)
is enabled and we've changed any GL state that might be referenced by a
fragment program (such as state.fog.params).  Do this during swrast
validation, not in _swrast_exec_fragment_program().

src/mesa/swrast/s_context.c
src/mesa/swrast/s_nvfragprog.c

index 18f5fe497bb539359354ed19e5c504ab48f7606e..0de6dc25b4a1d47d36b0eecddbe4ca20f41aca34 100644 (file)
@@ -226,6 +226,10 @@ static void
 _swrast_update_fragment_program( GLcontext *ctx )
 {
    if (ctx->FragmentProgram._Enabled) {
+      /* XXX it would be nice to have a per-program bitmask indicating
+       * what global state vars are used (lighting, point, fog, etc) to
+       * avoid doing this when not needed.
+       */
       const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
       _mesa_load_state_parameters(ctx, fp->Base.Parameters);
    }
@@ -521,7 +525,17 @@ _swrast_validate_derived( GLcontext *ctx )
       if (swrast->NewState & (_NEW_FOG | _NEW_PROGRAM))
          _swrast_update_fog_state( ctx );
 
-      if (swrast->NewState & _NEW_PROGRAM)
+      if (swrast->NewState & (_NEW_MODELVIEW |
+                              _NEW_PROJECTION |
+                              _NEW_TEXTURE_MATRIX |
+                              _NEW_FOG |
+                              _NEW_LIGHT |
+                              _NEW_LINE |
+                              _NEW_TEXTURE |
+                              _NEW_TRANSFORM |
+                              _NEW_POINT |
+                              _NEW_VIEWPORT |
+                              _NEW_PROGRAM))
         _swrast_update_fragment_program( ctx );
 
       if (swrast->NewState & _NEW_TEXTURE)
index a34db23fa64376d2e8b0d5bfacd5ad7e2740f9ab..94c249926dcd7b07d497165b92e48ccfa9c91d4a 100644 (file)
@@ -1597,11 +1597,6 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span )
 
    ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
 
-#if 0 /* we really shouldn't need this here... */
-   if (program->Base.Parameters) {
-      _mesa_load_state_parameters(ctx, program->Base.Parameters);
-   }
-#endif
    run_program(ctx, span, 0, span->end);
 
    if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {