Don't set extra bits in FLUSH_VERTICES, fix several state bugs.
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 23 Jan 2004 14:46:27 +0000 (14:46 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 23 Jan 2004 14:46:27 +0000 (14:46 +0000)
src/mesa/main/arbfragparse.c
src/mesa/main/arbfragparse.h
src/mesa/main/enable.c
src/mesa/main/light.c
src/mesa/main/mtypes.h
src/mesa/main/program.c
src/mesa/main/state.c
src/mesa/main/texstate.c

index 1723e6c5d9a8a7784158736060737a5f66c31bb6..9a986b4a835efcc7ed043b9347b3227634eed63e 100644 (file)
@@ -38,8 +38,8 @@
 #include "arbparse.h"
 #include "arbfragparse.h"
 
-static void
-debug_fp_inst(GLint num, struct fp_instruction *fp)
+void
+_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
 {
    GLint a;
  
@@ -228,9 +228,7 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
    }
 
 #if DEBUG_FP
-   debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
-#else
-   (void) debug_fp_inst;
+   _mesa_debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
 #endif
 
    program->Instructions   = ap.FPInstructions;
index 17e8dcf6239b54806fc976036a5884fbb5d22948..0d3e69fa8efa706066d57ee2042d3c425e7d8c49 100644 (file)
@@ -32,4 +32,8 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
                                  const GLubyte * str, GLsizei len,
                                  struct fragment_program *program);
 
+extern void
+_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp);
+
+
 #endif
index a882cf4580c082c5a78752a4f30e356db04513b3..7f076867f92eac53abb7a943d4a81d8d409faa5d 100644 (file)
@@ -353,13 +353,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          else
           ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
  
-         if ((ctx->Light.Enabled &&
-              ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-             || ctx->Fog.ColorSumEnabled)
-            ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-         else
-            ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
       case GL_LINE_SMOOTH:
          if (ctx->Line.SmoothFlag == state)
@@ -791,14 +784,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_FOG);
          ctx->Fog.ColorSumEnabled = state;
-
-         if ((ctx->Light.Enabled &&
-              ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-             || ctx->Fog.ColorSumEnabled)
-            ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-         else
-            ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
 
       /* GL_ARB_multisample */
@@ -861,21 +846,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM);  /* XXX OK? */
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM); 
          ctx->VertexProgram.Enabled = state;
          break;
       case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.PointSizeEnabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->VertexProgram.PointSizeEnabled = state;
          break;
       case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.TwoSideEnabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM);  /* XXX OK? */
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM); 
          ctx->VertexProgram.TwoSideEnabled = state;
          break;
       case GL_MAP1_VERTEX_ATTRIB0_4_NV:
@@ -931,7 +916,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(NV_fragment_program, cap);
          if (ctx->FragmentProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_TEXTURE);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->FragmentProgram.Enabled = state;
          break;
 #endif /* FEATURE_NV_fragment_program */
@@ -967,7 +952,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(ARB_fragment_program, cap);
          if (ctx->FragmentProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_TEXTURE);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->FragmentProgram.Enabled = state;
          break;
 #endif /* FEATURE_ARB_fragment_program */
index 44feeb507e9f594b0828a2ad0b514d8427e4d098..94060592bbc21cc281d063a57dfef150c957681c 100644 (file)
@@ -409,14 +409,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
            return;
         FLUSH_VERTICES(ctx, _NEW_LIGHT);
         ctx->Light.Model.ColorControl = newenum;
-
-        if ((ctx->Light.Enabled &&
-             ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-            || ctx->Fog.ColorSumEnabled)
-           ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-        else
-           ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
index a9c5f2ceca40f8ea256d950727b68522306904ef..9685dfc11caff7d8aec55d23adea0c31c2b8044d 100644 (file)
@@ -1980,7 +1980,7 @@ struct matrix_stack
  */
 /*@{*/
 #define _DD_NEW_FLATSHADE                _NEW_LIGHT
-#define _DD_NEW_SEPARATE_SPECULAR        (_NEW_LIGHT | _NEW_FOG)
+#define _DD_NEW_SEPARATE_SPECULAR        (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
 #define _DD_NEW_TRI_CULL_FRONT_BACK      _NEW_POLYGON
 #define _DD_NEW_TRI_LIGHT_TWOSIDE        _NEW_LIGHT
 #define _DD_NEW_TRI_UNFILLED             _NEW_POLYGON
index aca9be979ddebca618c5177605d4090a09c8e098..7294d6c7f73e81aa3d1c36beea91b277e060f4af 100644 (file)
@@ -798,8 +798,7 @@ _mesa_BindProgram(GLenum target, GLuint id)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   /* texture state is dependent on current fragment and vertex programs */
-   FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_TEXTURE);
+   FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
    if ((target == GL_VERTEX_PROGRAM_NV
         && ctx->Extensions.NV_vertex_program) ||
index 0ed7300c191b4b7a0dd27826445ee323bbc91be7..3e7554f44fad0790fc298c318c784b081c0dfa1e 100644 (file)
@@ -740,16 +740,13 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
 /*@{*/
 
 
-/*
- * Update items which depend on vertex/fragment programs.
- */
 static void
-update_program( GLcontext *ctx )
+update_separate_specular( GLcontext *ctx )
 {
-   if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) {
-      if (ctx->FragmentProgram.Current->InputsRead & (1 << FRAG_ATTRIB_COL1))
-         ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-   }
+   if (NEED_SECONDARY_COLOR(ctx))
+      ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
+   else
+      ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
 }
 
 
@@ -872,7 +869,7 @@ update_arrays( GLcontext *ctx )
  */
 void _mesa_update_state( GLcontext *ctx )
 {
-   const GLuint new_state = ctx->NewState;
+   GLuint new_state = ctx->NewState;
 
    if (MESA_VERBOSE & VERBOSE_STATE)
       _mesa_print_state("_mesa_update_state", new_state);
@@ -880,7 +877,7 @@ void _mesa_update_state( GLcontext *ctx )
    if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
       _mesa_update_modelview_project( ctx, new_state );
 
-   if (new_state & (_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
+   if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
       _mesa_update_texture( ctx, new_state );
 
    if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS))
@@ -895,10 +892,10 @@ void _mesa_update_state( GLcontext *ctx )
    if (new_state & _IMAGE_NEW_TRANSFER_STATE)
       _mesa_update_pixel( ctx, new_state );
 
-   if (new_state & _NEW_PROGRAM)
-      update_program( ctx );
+   if (new_state & _DD_NEW_SEPARATE_SPECULAR)
+      update_separate_specular( ctx );
 
-   if (new_state & _NEW_ARRAY)
+   if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
       update_arrays( ctx );
 
    /* ctx->_NeedEyeCoords is now up to date.
@@ -922,6 +919,7 @@ void _mesa_update_state( GLcontext *ctx )
     * Set ctx->NewState to zero to avoid recursion if
     * Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)
     */
+   new_state = ctx->NewState;
    ctx->NewState = 0;
    ctx->Driver.UpdateState(ctx, new_state);
    ctx->Array.NewState = 0;
index b1554ab3c86858e86f2b233b998a2e06a4beee05..e27c42e07b65e1effcf63bc692d82cf4e7ccddc2 100644 (file)
@@ -2703,6 +2703,10 @@ update_texture_state( GLcontext *ctx )
 {
    GLuint unit;
 
+   ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are 
+                                  * actual changes. 
+                                  */
+
    ctx->Texture._EnabledUnits = 0;
    ctx->Texture._GenFlags = 0;
    ctx->Texture._TexMatEnabled = 0;
@@ -2834,7 +2838,7 @@ void _mesa_update_texture( GLcontext *ctx, GLuint new_state )
    if (new_state & _NEW_TEXTURE_MATRIX)
       update_texture_matrices( ctx );
 
-   if (new_state & _NEW_TEXTURE)
+   if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM))
       update_texture_state( ctx );
 }