From: Brian Date: Wed, 13 Dec 2006 22:31:14 +0000 (-0700) Subject: Move all the code for computing ctx->_TriangleCaps into state.c. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8dcfcad7a2598ba835930aac8f3fd6576e464c1c;p=mesa.git Move all the code for computing ctx->_TriangleCaps into state.c. ctx->_TriangleCaps should probably go away altogether someday... --- diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 91268b596d2..076d8731f8f 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -49,8 +49,11 @@ } +/** + * Helper to enable/disable client-side state. + */ static void -client_state( GLcontext *ctx, GLenum cap, GLboolean state ) +client_state(GLcontext *ctx, GLenum cap, GLboolean state) { GLuint flag; GLuint *var; @@ -134,17 +137,14 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->Array.ArrayObj->_Enabled &= ~flag; if (ctx->Driver.Enable) { - (*ctx->Driver.Enable)( ctx, cap, state ); + ctx->Driver.Enable( ctx, cap, state ); } } /** * Enable GL capability. - * - * \param cap capability. - * - * \sa glEnable(). + * \param cap state to enable/disable. * * Get's the current context, assures that we're outside glBegin()/glEnd() and * calls client_state(). @@ -160,10 +160,7 @@ _mesa_EnableClientState( GLenum cap ) /** * Disable GL capability. - * - * \param cap capability. - * - * \sa glDisable(). + * \param cap state to enable/disable. * * Get's the current context, assures that we're outside glBegin()/glEnd() and * calls client_state(). @@ -195,10 +192,10 @@ _mesa_DisableClientState( GLenum cap ) /** - * Perform glEnable() and glDisable() calls. + * Helper function to enable or disable state. * * \param ctx GL context. - * \param cap capability. + * \param cap the state to enable/disable * \param state whether to enable or disable the specified capability. * * Updates the current context and flushes the vertices as needed. For @@ -206,7 +203,8 @@ _mesa_DisableClientState( GLenum cap ) * are effectivly present before updating. Notifies the driver via * dd_function_table::Enable. */ -void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) +void +_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) { if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s %s (newstate is %x)\n", @@ -285,7 +283,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; - case GL_CULL_VERTEX_EXT: CHECK_EXTENSION(EXT_cull_vertex, cap); if (ctx->Transform.CullVertexFlag == state) @@ -293,13 +290,12 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.CullVertexFlag = state; break; - case GL_DEPTH_TEST: if (state && ctx->DrawBuffer->Visual.depthBits == 0) { _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); return; } - if (ctx->Depth.Test==state) + if (ctx->Depth.Test == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.Test = state; @@ -308,13 +304,13 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) if (ctx->NoDither) { state = GL_FALSE; /* MESA_NO_DITHER env var */ } - if (ctx->Color.DitherFlag==state) + if (ctx->Color.DitherFlag == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.DitherFlag = state; break; case GL_FOG: - if (ctx->Fog.Enabled==state) + if (ctx->Fog.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.Enabled = state; @@ -351,26 +347,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Enabled = state; - - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: if (ctx->Line.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.StippleFlag = state; - ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: if (ctx->Color.IndexLogicOpEnabled == state) @@ -505,41 +493,38 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: - if (ctx->Point.SmoothFlag==state) + if (ctx->Point.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_POINT_SMOOTH; break; case GL_POLYGON_SMOOTH: - if (ctx->Polygon.SmoothFlag==state) + if (ctx->Polygon.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: - if (ctx->Polygon.StippleFlag==state) + if (ctx->Polygon.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.StippleFlag = state; - ctx->_TriangleCaps ^= DD_TRI_STIPPLE; break; case GL_POLYGON_OFFSET_POINT: - if (ctx->Polygon.OffsetPoint==state) + if (ctx->Polygon.OffsetPoint == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetPoint = state; break; case GL_POLYGON_OFFSET_LINE: - if (ctx->Polygon.OffsetLine==state) + if (ctx->Polygon.OffsetLine == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetLine = state; break; case GL_POLYGON_OFFSET_FILL: /*case GL_POLYGON_OFFSET_EXT:*/ - if (ctx->Polygon.OffsetFill==state) + if (ctx->Polygon.OffsetFill == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetFill = state; @@ -551,7 +536,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->Transform.RescaleNormals = state; break; case GL_SCISSOR_TEST: - if (ctx->Scissor.Enabled==state) + if (ctx->Scissor.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_SCISSOR); ctx->Scissor.Enabled = state; @@ -568,7 +553,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) "glEnable(GL_STENCIL_TEST) but no stencil buffer"); return; } - if (ctx->Stencil.Enabled==state) + if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; @@ -916,11 +901,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.TestTwoSide = state; - if (state) { - ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; - } else { - ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; - } break; #if FEATURE_ARB_fragment_program @@ -973,20 +953,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) } if (ctx->Driver.Enable) { - (*ctx->Driver.Enable)( ctx, cap, state ); + ctx->Driver.Enable( ctx, cap, state ); } } /** - * Enable GL capability. - * - * \param cap capability. - * - * \sa glEnable(). - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls _mesa_set_enable(). + * Enable GL capability. Called by glEnable() + * \param cap state to enable. */ void GLAPIENTRY _mesa_Enable( GLenum cap ) @@ -999,14 +973,8 @@ _mesa_Enable( GLenum cap ) /** - * Disable GL capability. - * - * \param cap capability. - * - * \sa glDisable(). - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls _mesa_set_enable(). + * Disable GL capability. Called by glDisable() + * \param cap state to disable. */ void GLAPIENTRY _mesa_Disable( GLenum cap ) @@ -1032,10 +1000,11 @@ _mesa_Disable( GLenum cap ) return GL_FALSE; \ } + /** - * Test whether a capability is enabled. + * Return simple enable/disable state. * - * \param cap capability. + * \param cap state variable to query. * * Returns the state of the specified capability from the current GL context. * For the capabilities associated with extensions verifies that those diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 135323f9c15..7845ea018ef 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -409,7 +409,9 @@ _mesa_enable_2_1_extensions(GLcontext *ctx) #if FEATURE_EXT_texture_sRGB ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif - /* plus: shading language extensions, non-square uniform matrices */ +#ifdef FEATURE_ARB_shading_language_120 + ctx->Extensions.ARB_shading_language_120 = GL_TRUE; +#endif } diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 984f7b2abc4..92d8a0ae0d4 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.3 * * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * @@ -44,7 +44,7 @@ _mesa_ShadeModel( GLenum mode ) _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); if (mode != GL_FLAT && mode != GL_SMOOTH) { - _mesa_error( ctx, GL_INVALID_ENUM, "glShadeModel" ); + _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel"); return; } @@ -53,9 +53,8 @@ _mesa_ShadeModel( GLenum mode ) FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.ShadeModel = mode; - ctx->_TriangleCaps ^= DD_FLATSHADE; if (ctx->Driver.ShadeModel) - (*ctx->Driver.ShadeModel)( ctx, mode ); + ctx->Driver.ShadeModel( ctx, mode ); } @@ -442,11 +441,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Model.TwoSide = newbool; - - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LIGHT_MODEL_COLOR_CONTROL: if (params[0] == (GLfloat) GL_SINGLE_COLOR) @@ -728,7 +722,7 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) } if (ctx->Driver.ColorMaterial) - (*ctx->Driver.ColorMaterial)( ctx, face, mode ); + ctx->Driver.ColorMaterial( ctx, face, mode ); } diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c index c30d9ac109e..dc7195d4ebf 100644 --- a/src/mesa/main/lines.c +++ b/src/mesa/main/lines.c @@ -1,13 +1,8 @@ -/** - * \file lines.c - * Line operations. - */ - /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -43,12 +38,6 @@ * \param width line width in pixels. * * \sa glLineWidth(). - * - * Verifies the parameter and updates gl_line_attrib::Width. On a change, - * flushes the vertices, updates the clamped line width and marks the - * DD_LINE_WIDTH flag in __GLcontextRec::_TriangleCaps for the drivers if the - * width is different from one. Notifies the driver via the - * dd_function_table::LineWidth callback. */ void GLAPIENTRY _mesa_LineWidth( GLfloat width ) @@ -70,14 +59,8 @@ _mesa_LineWidth( GLfloat width ) ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth); - - if (width != 1.0) - ctx->_TriangleCaps |= DD_LINE_WIDTH; - else - ctx->_TriangleCaps &= ~DD_LINE_WIDTH; - if (ctx->Driver.LineWidth) - (*ctx->Driver.LineWidth)(ctx, width); + ctx->Driver.LineWidth(ctx, width); } diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index aa36fb62877..c6b032460e8 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -244,19 +244,9 @@ _mesa_update_point(GLcontext *ctx) ctx->Point.MinSize, ctx->Point.MaxSize); - if (ctx->Point._Size == 1.0F) - ctx->_TriangleCaps &= ~DD_POINT_SIZE; - else - ctx->_TriangleCaps |= DD_POINT_SIZE; - ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || ctx->Point.Params[1] != 0.0 || ctx->Point.Params[2] != 0.0); - - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - else - ctx->_TriangleCaps &= ~DD_POINT_ATTEN; } diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index b771408cf36..814f7ec5faa 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -166,14 +166,6 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); return; } - - ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; - if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - - if (ctx->Driver.PolygonMode) { - (*ctx->Driver.PolygonMode)( ctx, face, mode ); - } } #if _HAVE_FULL_GL @@ -320,32 +312,6 @@ _mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) #endif -/**********************************************************************/ -/** \name State Management */ -/*@{*/ - -/* - * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET - * in ctx->_TriangleCaps if needed. - */ -void _mesa_update_polygon( GLcontext *ctx ) -{ - ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); - - if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - - /* Any Polygon offsets enabled? */ - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) { - ctx->_TriangleCaps |= DD_TRI_OFFSET; - } -} - -/*@}*/ - - /**********************************************************************/ /** \name Initialization */ /*@{*/ diff --git a/src/mesa/main/polygon.h b/src/mesa/main/polygon.h index 2550ed16877..78e8394d053 100644 --- a/src/mesa/main/polygon.h +++ b/src/mesa/main/polygon.h @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -60,9 +60,6 @@ _mesa_PolygonStipple( const GLubyte *mask ); extern void GLAPIENTRY _mesa_GetPolygonStipple( GLubyte *mask ); -extern void -_mesa_update_polygon( GLcontext *ctx ); - extern void _mesa_init_polygon( GLcontext * ctx ); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index e62fbe47d15..4184aeb9d92 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -821,16 +821,6 @@ _mesa_init_exec_table(struct _glapi_table *exec) /*@{*/ -static void -update_separate_specular( GLcontext *ctx ) -{ - if (NEED_SECONDARY_COLOR(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; - else - ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; -} - - /** * Update state dependent on vertex arrays. */ @@ -1014,16 +1004,88 @@ update_color(GLcontext *ctx) /** - * If __GLcontextRec::NewState is non-zero then this function \b must be called - * before rendering any primitive. Basically, function pointers and - * miscellaneous flags are updated to reflect the current state of the state - * machine. + * Update the ctx->_TriangleCaps bitfield. + * XXX that bitfield should really go away someday! + * This function must be called after other update_*() functions since + * there are dependencies on some other derived values. + */ +static void +update_tricaps(GLcontext *ctx, GLbitfield new_state) +{ + ctx->_TriangleCaps = 0; + + /* + * Points + */ + if (new_state & _NEW_POINT) { + if (ctx->Point.SmoothFlag) + ctx->_TriangleCaps |= DD_POINT_SMOOTH; + if (ctx->Point._Size != 1.0F) + ctx->_TriangleCaps |= DD_POINT_SIZE; + if (ctx->Point._Attenuated) + ctx->_TriangleCaps |= DD_POINT_ATTEN; + } + + /* + * Lines + */ + if (new_state & _NEW_LINE) { + if (ctx->Line.SmoothFlag) + ctx->_TriangleCaps |= DD_LINE_SMOOTH; + if (ctx->Line.StippleFlag) + ctx->_TriangleCaps |= DD_LINE_STIPPLE; + if (ctx->Line._Width != 1.0) + ctx->_TriangleCaps |= DD_LINE_WIDTH; + } + + /* + * Polygons + */ + if (new_state & _NEW_POLYGON) { + if (ctx->Polygon.SmoothFlag) + ctx->_TriangleCaps |= DD_TRI_SMOOTH; + if (ctx->Polygon.StippleFlag) + ctx->_TriangleCaps |= DD_TRI_STIPPLE; + if (ctx->Polygon.FrontMode != GL_FILL + || ctx->Polygon.BackMode != GL_FILL) + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + if (ctx->Polygon.CullFlag + && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; + } + + /* + * Lighting and shading + */ + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + if (ctx->Light.ShadeModel == GL_FLAT) + ctx->_TriangleCaps |= DD_FLATSHADE; + if (NEED_SECONDARY_COLOR(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + + /* + * Stencil + */ + if (ctx->Stencil._TestTwoSide) + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; +} + + +/** + * Compute derived GL state. + * If __GLcontextRec::NewState is non-zero then this function \b must + * be called before rendering anything. * * Calls dd_function_table::UpdateState to perform any internal state * management necessary. * * \sa _mesa_update_modelview_project(), _mesa_update_texture(), - * _mesa_update_buffer_bounds(), _mesa_update_polygon(), + * _mesa_update_buffer_bounds(), * _mesa_update_lighting() and _mesa_update_tnl_spaces(). */ void @@ -1052,9 +1114,6 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_POINT) _mesa_update_point( ctx ); - if (new_state & _NEW_POLYGON) - _mesa_update_polygon( ctx ); - if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); @@ -1064,9 +1123,6 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_pixel( ctx, new_state ); - if (new_state & _DD_NEW_SEPARATE_SPECULAR) - update_separate_specular( ctx ); - if (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) update_arrays( ctx ); @@ -1076,6 +1132,10 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_COLOR) update_color( ctx ); + if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT + | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) + update_tricaps( ctx, new_state ); + if (ctx->_MaintainTexEnvProgram) { if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG)) _mesa_UpdateTexEnvProgram(ctx); @@ -1122,3 +1182,5 @@ _mesa_update_state( GLcontext *ctx ) /*@}*/ + +