aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2004-01-23 14:46:27 +0000
committerKeith Whitwell <[email protected]>2004-01-23 14:46:27 +0000
commit3abf746a7eae52220485cd031aecec2ca9e6103e (patch)
treec5b0f5e9e1751cb18043824027b2e0c2b06b1b03 /src/mesa
parent5c161cf615a073a9a69916957babdd234eba2174 (diff)
Don't set extra bits in FLUSH_VERTICES, fix several state bugs.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/arbfragparse.c8
-rw-r--r--src/mesa/main/arbfragparse.h4
-rw-r--r--src/mesa/main/enable.c25
-rw-r--r--src/mesa/main/light.c8
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/program.c3
-rw-r--r--src/mesa/main/state.c24
-rw-r--r--src/mesa/main/texstate.c6
8 files changed, 30 insertions, 50 deletions
diff --git a/src/mesa/main/arbfragparse.c b/src/mesa/main/arbfragparse.c
index 1723e6c5d9a..9a986b4a835 100644
--- a/src/mesa/main/arbfragparse.c
+++ b/src/mesa/main/arbfragparse.c
@@ -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;
diff --git a/src/mesa/main/arbfragparse.h b/src/mesa/main/arbfragparse.h
index 17e8dcf6239..0d3e69fa8ef 100644
--- a/src/mesa/main/arbfragparse.h
+++ b/src/mesa/main/arbfragparse.h
@@ -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
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index a882cf4580c..7f076867f92 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -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 */
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 44feeb507e9..94060592bbc 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -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 );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a9c5f2ceca4..9685dfc11ca 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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
diff --git a/src/mesa/main/program.c b/src/mesa/main/program.c
index aca9be979dd..7294d6c7f73 100644
--- a/src/mesa/main/program.c
+++ b/src/mesa/main/program.c
@@ -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) ||
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 0ed7300c191..3e7554f44fa 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -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;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index b1554ab3c86..e27c42e07b6 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -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 );
}