diff options
author | Keith Whitwell <[email protected]> | 2003-07-17 13:43:59 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2003-07-17 13:43:59 +0000 |
commit | 6dc85575000127630489b407c50a4b3ea87c9acb (patch) | |
tree | c79b24b7059577caf8201eeb7a42a6890721f52b /src/mesa/main/state.c | |
parent | 44c699949ac09459771304a8aec8f2fc622057fb (diff) |
Merge Jose's documentation and core Mesa changes from embedded branch
Diffstat (limited to 'src/mesa/main/state.c')
-rw-r--r-- | src/mesa/main/state.c | 745 |
1 files changed, 170 insertions, 575 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 2851b8e083b..2683556f02a 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,3 +1,11 @@ +/** + * \file state.c + * State management. + * + * This file manages recalculation of derived values in the __GLcontextRec. + * Also, this is where we initialize the API dispatch table. + */ + /* * Mesa 3-D graphics library * Version: 5.1 @@ -23,12 +31,6 @@ */ -/* - * /brief This file manages recalculation of derived values in the - * __GLcontext. Also, this is where we initialize the API dispatch table. - */ - - #include "glheader.h" #include "accum.h" #include "api_loopback.h" @@ -79,24 +81,37 @@ #if FEATURE_NV_fragment_program #include "nvfragprog.h" #endif +#include "debug.h" + +/* #include "math/m_matrix.h" */ +/* #include "math/m_xform.h" */ -#include "math/m_matrix.h" -#include "math/m_xform.h" +/**********************************************************************/ +/** \name Dispatch table setup */ +/*@{*/ +/** + * Generic no-op dispatch function. + * + * Used in replacement of the functions which are not part of Mesa subset. + * + * Displays a message. + */ static int generic_noop(void) { -#ifdef DEBUG - _mesa_problem(NULL, "User called no-op dispatch function"); -#endif + _mesa_problem(NULL, "User called no-op dispatch function (not part of Mesa subset?)"); return 0; } -/* +/** * Set all pointers in the given dispatch table to point to a - * generic no-op function. + * generic no-op function - generic_noop(). + * + * \param table dispatch table. + * \param tableSize dispatch table size. */ void _mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) @@ -109,13 +124,15 @@ _mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) } - -/* - * Initialize the given dispatch table with pointers to Mesa's - * immediate-mode commands. +/** + * Initialize a dispatch table with pointers to Mesa's immediate-mode + * commands. + * + * Pointers to glBegin()/glEnd() object commands and a few others + * are provided via the GLvertexformat interface. * - * Pointers to begin/end object commands and a few others - * are provided via the vtxfmt interface elsewhere. + * \param exec dispatch table. + * \param tableSize dispatch table size. */ void _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) @@ -123,51 +140,90 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) /* first initialize all dispatch slots to no-op */ _mesa_init_no_op_table(exec, tableSize); +#if _HAVE_FULL_GL _mesa_loopback_init_api_table( exec, GL_TRUE ); +#endif /* load the dispatch slots we understand */ - exec->Accum = _mesa_Accum; exec->AlphaFunc = _mesa_AlphaFunc; - exec->Bitmap = _mesa_Bitmap; exec->BlendFunc = _mesa_BlendFunc; + exec->Clear = _mesa_Clear; + exec->ClearColor = _mesa_ClearColor; + exec->ClearStencil = _mesa_ClearStencil; + exec->ColorMask = _mesa_ColorMask; + exec->CullFace = _mesa_CullFace; + exec->Disable = _mesa_Disable; + exec->DrawBuffer = _mesa_DrawBuffer; + exec->Enable = _mesa_Enable; + exec->Finish = _mesa_Finish; + exec->Flush = _mesa_Flush; + exec->FrontFace = _mesa_FrontFace; + exec->Frustum = _mesa_Frustum; + exec->GetError = _mesa_GetError; + exec->GetFloatv = _mesa_GetFloatv; + exec->GetString = _mesa_GetString; + exec->InitNames = _mesa_InitNames; + exec->LineStipple = _mesa_LineStipple; + exec->LineWidth = _mesa_LineWidth; + exec->LoadIdentity = _mesa_LoadIdentity; + exec->LoadMatrixf = _mesa_LoadMatrixf; + exec->LoadName = _mesa_LoadName; + exec->LogicOp = _mesa_LogicOp; + exec->MatrixMode = _mesa_MatrixMode; + exec->MultMatrixf = _mesa_MultMatrixf; + exec->Ortho = _mesa_Ortho; + exec->PixelStorei = _mesa_PixelStorei; + exec->PopMatrix = _mesa_PopMatrix; + exec->PopName = _mesa_PopName; + exec->PushMatrix = _mesa_PushMatrix; + exec->PushName = _mesa_PushName; + exec->RasterPos2f = _mesa_RasterPos2f; + exec->RasterPos2fv = _mesa_RasterPos2fv; + exec->RasterPos2i = _mesa_RasterPos2i; + exec->RasterPos2iv = _mesa_RasterPos2iv; + exec->ReadBuffer = _mesa_ReadBuffer; + exec->RenderMode = _mesa_RenderMode; + exec->Rotatef = _mesa_Rotatef; + exec->Scalef = _mesa_Scalef; + exec->Scissor = _mesa_Scissor; + exec->SelectBuffer = _mesa_SelectBuffer; + exec->ShadeModel = _mesa_ShadeModel; + exec->StencilFunc = _mesa_StencilFunc; + exec->StencilMask = _mesa_StencilMask; + exec->StencilOp = _mesa_StencilOp; + exec->TexEnvfv = _mesa_TexEnvfv; + exec->TexEnvi = _mesa_TexEnvi; + exec->TexImage2D = _mesa_TexImage2D; + exec->TexParameteri = _mesa_TexParameteri; + exec->Translatef = _mesa_Translatef; + exec->Viewport = _mesa_Viewport; +#if _HAVE_FULL_GL + exec->Accum = _mesa_Accum; + exec->Bitmap = _mesa_Bitmap; exec->CallList = _mesa_CallList; exec->CallLists = _mesa_CallLists; - exec->Clear = _mesa_Clear; exec->ClearAccum = _mesa_ClearAccum; - exec->ClearColor = _mesa_ClearColor; exec->ClearDepth = _mesa_ClearDepth; exec->ClearIndex = _mesa_ClearIndex; - exec->ClearStencil = _mesa_ClearStencil; exec->ClipPlane = _mesa_ClipPlane; - exec->ColorMask = _mesa_ColorMask; exec->ColorMaterial = _mesa_ColorMaterial; exec->CopyPixels = _mesa_CopyPixels; - exec->CullFace = _mesa_CullFace; exec->DeleteLists = _mesa_DeleteLists; exec->DepthFunc = _mesa_DepthFunc; exec->DepthMask = _mesa_DepthMask; exec->DepthRange = _mesa_DepthRange; - exec->Disable = _mesa_Disable; - exec->DrawBuffer = _mesa_DrawBuffer; exec->DrawPixels = _mesa_DrawPixels; - exec->Enable = _mesa_Enable; exec->EndList = _mesa_EndList; exec->FeedbackBuffer = _mesa_FeedbackBuffer; - exec->Finish = _mesa_Finish; - exec->Flush = _mesa_Flush; exec->FogCoordPointerEXT = _mesa_FogCoordPointerEXT; exec->Fogf = _mesa_Fogf; exec->Fogfv = _mesa_Fogfv; exec->Fogi = _mesa_Fogi; exec->Fogiv = _mesa_Fogiv; - exec->FrontFace = _mesa_FrontFace; - exec->Frustum = _mesa_Frustum; exec->GenLists = _mesa_GenLists; - exec->GetBooleanv = _mesa_GetBooleanv; exec->GetClipPlane = _mesa_GetClipPlane; + exec->GetBooleanv = _mesa_GetBooleanv; exec->GetDoublev = _mesa_GetDoublev; - exec->GetError = _mesa_GetError; - exec->GetFloatv = _mesa_GetFloatv; exec->GetIntegerv = _mesa_GetIntegerv; exec->GetLightfv = _mesa_GetLightfv; exec->GetLightiv = _mesa_GetLightiv; @@ -180,20 +236,18 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->GetPixelMapuiv = _mesa_GetPixelMapuiv; exec->GetPixelMapusv = _mesa_GetPixelMapusv; exec->GetPolygonStipple = _mesa_GetPolygonStipple; - exec->GetString = _mesa_GetString; exec->GetTexEnvfv = _mesa_GetTexEnvfv; exec->GetTexEnviv = _mesa_GetTexEnviv; - exec->GetTexGendv = _mesa_GetTexGendv; - exec->GetTexGenfv = _mesa_GetTexGenfv; - exec->GetTexGeniv = _mesa_GetTexGeniv; - exec->GetTexImage = _mesa_GetTexImage; exec->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; exec->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; exec->GetTexParameterfv = _mesa_GetTexParameterfv; exec->GetTexParameteriv = _mesa_GetTexParameteriv; + exec->GetTexGendv = _mesa_GetTexGendv; + exec->GetTexGenfv = _mesa_GetTexGenfv; + exec->GetTexGeniv = _mesa_GetTexGeniv; + exec->GetTexImage = _mesa_GetTexImage; exec->Hint = _mesa_Hint; exec->IndexMask = _mesa_IndexMask; - exec->InitNames = _mesa_InitNames; exec->IsEnabled = _mesa_IsEnabled; exec->IsList = _mesa_IsList; exec->LightModelf = _mesa_LightModelf; @@ -204,14 +258,8 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->Lightfv = _mesa_Lightfv; exec->Lighti = _mesa_Lighti; exec->Lightiv = _mesa_Lightiv; - exec->LineStipple = _mesa_LineStipple; - exec->LineWidth = _mesa_LineWidth; exec->ListBase = _mesa_ListBase; - exec->LoadIdentity = _mesa_LoadIdentity; exec->LoadMatrixd = _mesa_LoadMatrixd; - exec->LoadMatrixf = _mesa_LoadMatrixf; - exec->LoadName = _mesa_LoadName; - exec->LogicOp = _mesa_LogicOp; exec->Map1d = _mesa_Map1d; exec->Map1f = _mesa_Map1f; exec->Map2d = _mesa_Map2d; @@ -220,17 +268,13 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->MapGrid1f = _mesa_MapGrid1f; exec->MapGrid2d = _mesa_MapGrid2d; exec->MapGrid2f = _mesa_MapGrid2f; - exec->MatrixMode = _mesa_MatrixMode; exec->MultMatrixd = _mesa_MultMatrixd; - exec->MultMatrixf = _mesa_MultMatrixf; exec->NewList = _mesa_NewList; - exec->Ortho = _mesa_Ortho; exec->PassThrough = _mesa_PassThrough; exec->PixelMapfv = _mesa_PixelMapfv; exec->PixelMapuiv = _mesa_PixelMapuiv; exec->PixelMapusv = _mesa_PixelMapusv; exec->PixelStoref = _mesa_PixelStoref; - exec->PixelStorei = _mesa_PixelStorei; exec->PixelTransferf = _mesa_PixelTransferf; exec->PixelTransferi = _mesa_PixelTransferi; exec->PixelZoom = _mesa_PixelZoom; @@ -239,17 +283,9 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->PolygonOffset = _mesa_PolygonOffset; exec->PolygonStipple = _mesa_PolygonStipple; exec->PopAttrib = _mesa_PopAttrib; - exec->PopMatrix = _mesa_PopMatrix; - exec->PopName = _mesa_PopName; exec->PushAttrib = _mesa_PushAttrib; - exec->PushMatrix = _mesa_PushMatrix; - exec->PushName = _mesa_PushName; exec->RasterPos2d = _mesa_RasterPos2d; exec->RasterPos2dv = _mesa_RasterPos2dv; - exec->RasterPos2f = _mesa_RasterPos2f; - exec->RasterPos2fv = _mesa_RasterPos2fv; - exec->RasterPos2i = _mesa_RasterPos2i; - exec->RasterPos2iv = _mesa_RasterPos2iv; exec->RasterPos2s = _mesa_RasterPos2s; exec->RasterPos2sv = _mesa_RasterPos2sv; exec->RasterPos3d = _mesa_RasterPos3d; @@ -268,23 +304,11 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->RasterPos4iv = _mesa_RasterPos4iv; exec->RasterPos4s = _mesa_RasterPos4s; exec->RasterPos4sv = _mesa_RasterPos4sv; - exec->ReadBuffer = _mesa_ReadBuffer; exec->ReadPixels = _mesa_ReadPixels; - exec->RenderMode = _mesa_RenderMode; exec->Rotated = _mesa_Rotated; - exec->Rotatef = _mesa_Rotatef; exec->Scaled = _mesa_Scaled; - exec->Scalef = _mesa_Scalef; - exec->Scissor = _mesa_Scissor; exec->SecondaryColorPointerEXT = _mesa_SecondaryColorPointerEXT; - exec->SelectBuffer = _mesa_SelectBuffer; - exec->ShadeModel = _mesa_ShadeModel; - exec->StencilFunc = _mesa_StencilFunc; - exec->StencilMask = _mesa_StencilMask; - exec->StencilOp = _mesa_StencilOp; exec->TexEnvf = _mesa_TexEnvf; - exec->TexEnvfv = _mesa_TexEnvfv; - exec->TexEnvi = _mesa_TexEnvi; exec->TexEnviv = _mesa_TexEnviv; exec->TexGend = _mesa_TexGend; exec->TexGendv = _mesa_TexGendv; @@ -293,29 +317,27 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->TexGeni = _mesa_TexGeni; exec->TexGeniv = _mesa_TexGeniv; exec->TexImage1D = _mesa_TexImage1D; - exec->TexImage2D = _mesa_TexImage2D; exec->TexParameterf = _mesa_TexParameterf; exec->TexParameterfv = _mesa_TexParameterfv; - exec->TexParameteri = _mesa_TexParameteri; exec->TexParameteriv = _mesa_TexParameteriv; exec->Translated = _mesa_Translated; - exec->Translatef = _mesa_Translatef; - exec->Viewport = _mesa_Viewport; +#endif /* 1.1 */ + exec->BindTexture = _mesa_BindTexture; + exec->DeleteTextures = _mesa_DeleteTextures; + exec->GenTextures = _mesa_GenTextures; +#if _HAVE_FULL_GL exec->AreTexturesResident = _mesa_AreTexturesResident; exec->AreTexturesResidentEXT = _mesa_AreTexturesResident; - exec->BindTexture = _mesa_BindTexture; exec->ColorPointer = _mesa_ColorPointer; exec->CopyTexImage1D = _mesa_CopyTexImage1D; exec->CopyTexImage2D = _mesa_CopyTexImage2D; exec->CopyTexSubImage1D = _mesa_CopyTexSubImage1D; exec->CopyTexSubImage2D = _mesa_CopyTexSubImage2D; - exec->DeleteTextures = _mesa_DeleteTextures; exec->DisableClientState = _mesa_DisableClientState; exec->EdgeFlagPointer = _mesa_EdgeFlagPointer; exec->EnableClientState = _mesa_EnableClientState; - exec->GenTextures = _mesa_GenTextures; exec->GenTexturesEXT = _mesa_GenTextures; exec->GetPointerv = _mesa_GetPointerv; exec->IndexPointer = _mesa_IndexPointer; @@ -330,13 +352,17 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->TexSubImage1D = _mesa_TexSubImage1D; exec->TexSubImage2D = _mesa_TexSubImage2D; exec->VertexPointer = _mesa_VertexPointer; +#endif /* 1.2 */ +#if _HAVE_FULL_GL exec->CopyTexSubImage3D = _mesa_CopyTexSubImage3D; exec->TexImage3D = _mesa_TexImage3D; exec->TexSubImage3D = _mesa_TexSubImage3D; +#endif /* OpenGL 1.2 GL_ARB_imaging */ +#if _HAVE_FULL_GL exec->BlendColor = _mesa_BlendColor; exec->BlendEquation = _mesa_BlendEquation; exec->ColorSubTable = _mesa_ColorSubTable; @@ -384,48 +410,59 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->ResetHistogram = _mesa_ResetHistogram; exec->ResetMinmax = _mesa_ResetMinmax; exec->SeparableFilter2D = _mesa_SeparableFilter2D; +#endif /* 2. GL_EXT_blend_color */ #if 0 - exec->BlendColorEXT = _mesa_BlendColorEXT; +/* exec->BlendColorEXT = _mesa_BlendColorEXT; */ #endif /* 3. GL_EXT_polygon_offset */ +#if _HAVE_FULL_GL exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; +#endif /* 6. GL_EXT_texture3d */ #if 0 - exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; - exec->TexImage3DEXT = _mesa_TexImage3DEXT; - exec->TexSubImage3DEXT = _mesa_TexSubImage3D; +/* exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; */ +/* exec->TexImage3DEXT = _mesa_TexImage3DEXT; */ +/* exec->TexSubImage3DEXT = _mesa_TexSubImage3D; */ #endif /* 11. GL_EXT_histogram */ +#if _HAVE_FULL_GL exec->GetHistogramEXT = _mesa_GetHistogram; exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv; exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv; exec->GetMinmaxEXT = _mesa_GetMinmax; exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv; exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv; +#endif /* ?. GL_SGIX_pixel_texture */ +#if _HAVE_FULL_GL exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX; +#endif /* 15. GL_SGIS_pixel_texture */ +#if _HAVE_FULL_GL exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS; exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS; exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS; exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS; exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; +#endif /* 30. GL_EXT_vertex_array */ +#if _HAVE_FULL_GL exec->ColorPointerEXT = _mesa_ColorPointerEXT; exec->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT; exec->IndexPointerEXT = _mesa_IndexPointerEXT; exec->NormalPointerEXT = _mesa_NormalPointerEXT; exec->TexCoordPointerEXT = _mesa_TexCoordPointerEXT; exec->VertexPointerEXT = _mesa_VertexPointerEXT; +#endif /* 37. GL_EXT_blend_minmax */ #if 0 @@ -433,33 +470,46 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) #endif /* 54. GL_EXT_point_parameters */ +#if _HAVE_FULL_GL exec->PointParameterfEXT = _mesa_PointParameterfEXT; exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; +#endif /* 78. GL_EXT_paletted_texture */ #if 0 exec->ColorTableEXT = _mesa_ColorTableEXT; exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; #endif +#if _HAVE_FULL_GL exec->GetColorTableEXT = _mesa_GetColorTable; exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; +#endif /* 97. GL_EXT_compiled_vertex_array */ +#if _HAVE_FULL_GL exec->LockArraysEXT = _mesa_LockArraysEXT; exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; +#endif /* 148. GL_EXT_multi_draw_arrays */ +#if _HAVE_FULL_GL exec->MultiDrawArraysEXT = _mesa_MultiDrawArraysEXT; exec->MultiDrawElementsEXT = _mesa_MultiDrawElementsEXT; +#endif /* 173. GL_INGR_blend_func_separate */ +#if _HAVE_FULL_GL exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; +#endif /* 196. GL_MESA_resize_buffers */ +#if _HAVE_FULL_GL exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; +#endif /* 197. GL_MESA_window_pos */ +#if _HAVE_FULL_GL exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; @@ -484,6 +534,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; +#endif /* 233. GL_NV_vertex_program */ #if FEATURE_NV_vertex_program @@ -532,29 +583,40 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) #endif /* 262. GL_NV_point_sprite */ +#if _HAVE_FULL_GL exec->PointParameteriNV = _mesa_PointParameteriNV; exec->PointParameterivNV = _mesa_PointParameterivNV; +#endif /* 268. GL_EXT_stencil_two_side */ +#if _HAVE_FULL_GL exec->ActiveStencilFaceEXT = _mesa_ActiveStencilFaceEXT; +#endif /* ???. GL_EXT_depth_bounds_test */ exec->DepthBoundsEXT = _mesa_DepthBoundsEXT; /* ARB 1. GL_ARB_multitexture */ +#if _HAVE_FULL_GL exec->ActiveTextureARB = _mesa_ActiveTextureARB; exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; +#endif /* ARB 3. GL_ARB_transpose_matrix */ +#if _HAVE_FULL_GL exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB; exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB; exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB; exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB; +#endif /* ARB 5. GL_ARB_multisample */ +#if _HAVE_FULL_GL exec->SampleCoverageARB = _mesa_SampleCoverageARB; +#endif /* ARB 12. GL_ARB_texture_compression */ +#if _HAVE_FULL_GL exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB; exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB; exec->CompressedTexImage1DARB = _mesa_CompressedTexImage1DARB; @@ -562,6 +624,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->CompressedTexSubImage2DARB = _mesa_CompressedTexSubImage2DARB; exec->CompressedTexSubImage1DARB = _mesa_CompressedTexSubImage1DARB; exec->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB; +#endif /* ARB 14. GL_ARB_point_parameters */ /* reuse EXT_point_parameters functions */ @@ -660,392 +723,20 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) #endif } +/*@}*/ /**********************************************************************/ -/***** State update logic *****/ -/**********************************************************************/ - - -/* - * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET - * in ctx->_TriangleCaps if needed. - */ -static void -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; - } -} - -static void -calculate_model_project_matrix( GLcontext *ctx ) -{ - _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, - ctx->ProjectionMatrixStack.Top, - ctx->ModelviewMatrixStack.Top ); - - _math_matrix_analyse( &ctx->_ModelProjectMatrix ); -} - -static void -update_modelview_scale( GLcontext *ctx ) -{ - ctx->_ModelViewInvScale = 1.0F; - if (ctx->ModelviewMatrixStack.Top->flags & (MAT_FLAG_UNIFORM_SCALE | - MAT_FLAG_GENERAL_SCALE | - MAT_FLAG_GENERAL_3D | - MAT_FLAG_GENERAL) ) { - const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv; - GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; - if (f < 1e-12) f = 1.0; - if (ctx->_NeedEyeCoords) - ctx->_ModelViewInvScale = 1.0F / SQRTF(f); - else - ctx->_ModelViewInvScale = SQRTF(f); - } -} - - -/* Bring uptodate any state that relies on _NeedEyeCoords. - */ -static void -update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords ) -{ - /* Check if the truth-value interpretations of the bitfields have - * changed: - */ - if ((oldneedeyecoords == 0) != (ctx->_NeedEyeCoords == 0)) { - /* Recalculate all state that depends on _NeedEyeCoords. - */ - update_modelview_scale(ctx); - _mesa_compute_light_positions( ctx ); - - if (ctx->Driver.LightingSpaceChange) - ctx->Driver.LightingSpaceChange( ctx ); - } - else { - GLuint new_state = ctx->NewState; - - /* Recalculate that same state only if it has been invalidated - * by other statechanges. - */ - if (new_state & _NEW_MODELVIEW) - update_modelview_scale(ctx); - - if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW)) - _mesa_compute_light_positions( ctx ); - } -} - - -static void -update_drawbuffer( GLcontext *ctx ) -{ - ctx->DrawBuffer->_Xmin = 0; - ctx->DrawBuffer->_Ymin = 0; - ctx->DrawBuffer->_Xmax = ctx->DrawBuffer->Width; - ctx->DrawBuffer->_Ymax = ctx->DrawBuffer->Height; - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > ctx->DrawBuffer->_Xmin) { - ctx->DrawBuffer->_Xmin = ctx->Scissor.X; - } - if (ctx->Scissor.Y > ctx->DrawBuffer->_Ymin) { - ctx->DrawBuffer->_Ymin = ctx->Scissor.Y; - } - if (ctx->Scissor.X + ctx->Scissor.Width < ctx->DrawBuffer->_Xmax) { - ctx->DrawBuffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; - } - if (ctx->Scissor.Y + ctx->Scissor.Height < ctx->DrawBuffer->_Ymax) { - ctx->DrawBuffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; - } - } -} - - -/* NOTE: This routine references Tranform attribute values to compute - * userclip positions in clip space, but is only called on - * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values - * up to date across changes to the Transform attributes. - */ -static void -update_projection( GLcontext *ctx ) -{ - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* Recompute clip plane positions in clipspace. This is also done - * in _mesa_ClipPlane(). - */ - if (ctx->Transform.ClipPlanesEnabled) { - GLuint p; - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], - ctx->Transform.EyeUserPlane[p], - ctx->ProjectionMatrixStack.Top->inv ); - } - } - } -} - - -/* - * Return a bitmask of IMAGE_*_BIT flags which to indicate which - * pixel transfer operations are enabled. - */ -static void -update_image_transfer_state(GLcontext *ctx) -{ - GLuint mask = 0; - - if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || - ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || - ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || - ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) - mask |= IMAGE_SCALE_BIAS_BIT; - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) - mask |= IMAGE_SHIFT_OFFSET_BIT; - - if (ctx->Pixel.MapColorFlag) - mask |= IMAGE_MAP_COLOR_BIT; - - if (ctx->Pixel.ColorTableEnabled) - mask |= IMAGE_COLOR_TABLE_BIT; - - if (ctx->Pixel.Convolution1DEnabled || - ctx->Pixel.Convolution2DEnabled || - ctx->Pixel.Separable2DEnabled) { - mask |= IMAGE_CONVOLUTION_BIT; - if (ctx->Pixel.PostConvolutionScale[0] != 1.0F || - ctx->Pixel.PostConvolutionScale[1] != 1.0F || - ctx->Pixel.PostConvolutionScale[2] != 1.0F || - ctx->Pixel.PostConvolutionScale[3] != 1.0F || - ctx->Pixel.PostConvolutionBias[0] != 0.0F || - ctx->Pixel.PostConvolutionBias[1] != 0.0F || - ctx->Pixel.PostConvolutionBias[2] != 0.0F || - ctx->Pixel.PostConvolutionBias[3] != 0.0F) { - mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS; - } - } - - if (ctx->Pixel.PostConvolutionColorTableEnabled) - mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; - - if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY || - ctx->Pixel.PostColorMatrixScale[0] != 1.0F || - ctx->Pixel.PostColorMatrixBias[0] != 0.0F || - ctx->Pixel.PostColorMatrixScale[1] != 1.0F || - ctx->Pixel.PostColorMatrixBias[1] != 0.0F || - ctx->Pixel.PostColorMatrixScale[2] != 1.0F || - ctx->Pixel.PostColorMatrixBias[2] != 0.0F || - ctx->Pixel.PostColorMatrixScale[3] != 1.0F || - ctx->Pixel.PostColorMatrixBias[3] != 0.0F) - mask |= IMAGE_COLOR_MATRIX_BIT; - - if (ctx->Pixel.PostColorMatrixColorTableEnabled) - mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; - - if (ctx->Pixel.HistogramEnabled) - mask |= IMAGE_HISTOGRAM_BIT; - - if (ctx->Pixel.MinMaxEnabled) - mask |= IMAGE_MIN_MAX_BIT; - - ctx->_ImageTransferState = mask; -} +/** \name State update logic */ +/*@{*/ -/* Note: This routine refers to derived texture attribute values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT - * flags are updated by _mesa_update_textures(), below. - * - * If both TEXTURE and TEXTURE_MATRIX change at once, these values - * will be computed twice. - */ -static void -update_texture_matrices( GLcontext *ctx ) -{ - GLuint i; - ctx->Texture._TexMatEnabled = 0; - for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++) { - if (ctx->TextureMatrixStack[i].Top->flags & MAT_DIRTY) { - _math_matrix_analyse( ctx->TextureMatrixStack[i].Top ); - - if (ctx->Texture.Unit[i]._ReallyEnabled && - ctx->TextureMatrixStack[i].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i); - - if (ctx->Driver.TextureMatrix) - ctx->Driver.TextureMatrix( ctx, i, ctx->TextureMatrixStack[i].Top); - } - } -} -/* Note: This routine refers to derived texture matrix values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT - * flags are updated by _mesa_update_texture_matrices, above. - * - * If both TEXTURE and TEXTURE_MATRIX change at once, these values - * will be computed twice. - */ -static void -update_texture_state( GLcontext *ctx ) -{ - GLuint unit; - - ctx->Texture._EnabledUnits = 0; - ctx->Texture._GenFlags = 0; - ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN; - ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN; - ctx->Texture._TexMatEnabled = 0; - ctx->Texture._TexGenEnabled = 0; - - /* Update texture unit state. - * XXX this loop should probably be broken into separate loops for - * texture coord units and texture image units. - */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint enableBits; - - texUnit->_ReallyEnabled = 0; - texUnit->_GenFlags = 0; - - /* Get the bitmask of texture enables */ - if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) { - enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit]; - } - else { - if (!texUnit->Enabled) - continue; - enableBits = texUnit->Enabled; - } - - /* Look for the highest-priority texture target that's enabled and - * complete. That's the one we'll use for texturing. If we're using - * a fragment program we're guaranteed that bitcount(enabledBits) <= 1. - */ - if (enableBits & TEXTURE_CUBE_BIT) { - struct gl_texture_object *texObj = texUnit->CurrentCubeMap; - if (!texObj->Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->Complete) { - texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT; - texUnit->_Current = texObj; - } - } - - if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_3D_BIT)) { - struct gl_texture_object *texObj = texUnit->Current3D; - if (!texObj->Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->Complete) { - texUnit->_ReallyEnabled = TEXTURE_3D_BIT; - texUnit->_Current = texObj; - } - } - - if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_RECT_BIT)) { - struct gl_texture_object *texObj = texUnit->CurrentRect; - if (!texObj->Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->Complete) { - texUnit->_ReallyEnabled = TEXTURE_RECT_BIT; - texUnit->_Current = texObj; - } - } - - if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_2D_BIT)) { - struct gl_texture_object *texObj = texUnit->Current2D; - if (!texObj->Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->Complete) { - texUnit->_ReallyEnabled = TEXTURE_2D_BIT; - texUnit->_Current = texObj; - } - } - - if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_1D_BIT)) { - struct gl_texture_object *texObj = texUnit->Current1D; - if (!texObj->Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->Complete) { - texUnit->_ReallyEnabled = TEXTURE_1D_BIT; - texUnit->_Current = texObj; - } - } - - if (!texUnit->_ReallyEnabled) { - texUnit->_Current = NULL; - continue; - } - - if (texUnit->_ReallyEnabled) - ctx->Texture._EnabledUnits |= (1 << unit); - - if (texUnit->TexGenEnabled) { - if (texUnit->TexGenEnabled & S_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitS; - } - if (texUnit->TexGenEnabled & T_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitT; - } - if (texUnit->TexGenEnabled & Q_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitQ; - } - if (texUnit->TexGenEnabled & R_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitR; - } - - ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); - ctx->Texture._GenFlags |= texUnit->_GenFlags; - } - - if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); - } - - if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) { - ctx->_NeedNormals |= NEED_NORMALS_TEXGEN; - ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; - } - - if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) { - ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; - } - - ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits; - /* Fragment programs may need texture coordinates but not the - * corresponding texture images. - */ - if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) { - ctx->Texture._EnabledCoordUnits |= - (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0); - } -} - /* * Update items which depend on vertex/fragment programs. @@ -1061,93 +752,44 @@ update_program( GLcontext *ctx ) /* - * If ctx->NewState is non-zero then this function MUST be called before - * rendering any primitive. Basically, function pointers and miscellaneous - * flags are updated to reflect the current state of the state machine. - * - * The above constraint is now maintained largely by the two Exec - * dispatch tables, which trigger the appropriate flush on transition - * between State and Geometry modes. + * 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. * - * Special care is taken with the derived value _NeedEyeCoords. This - * is a bitflag which is updated with information from a number of - * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived - * state references this value, and must be treated with care to - * ensure that updates are done correctly. All state dependent on - * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(), - * and from nowhere else. + * Calls dd_function_table::UpdateState to perform any internal state management + * necessary. + * + * \sa _mesa_update_modelview_project(), _mesa_update_texture(), + * _mesa_update_buffers(), _mesa_update_polygon(), _mesa_update_lighting() and + * _mesa_update_tnl_spaces(). */ void _mesa_update_state( GLcontext *ctx ) { const GLuint new_state = ctx->NewState; - const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); - if (new_state & _NEW_MODELVIEW) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - if (new_state & _NEW_PROJECTION) - update_projection( ctx ); - - if (new_state & _NEW_TEXTURE_MATRIX) - update_texture_matrices( ctx ); - - if (new_state & _NEW_COLOR_MATRIX) - _math_matrix_analyse( ctx->ColorMatrixStack.Top ); - - /* References ColorMatrix.type (derived above). - */ - if (new_state & _IMAGE_NEW_TRANSFER_STATE) - update_image_transfer_state(ctx); + if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) + _mesa_update_modelview_project( ctx, new_state ); - /* Contributes to NeedEyeCoords, NeedNormals. - */ - if (new_state & _NEW_TEXTURE) - update_texture_state( ctx ); + if (new_state & (_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) + _mesa_update_texture( ctx, new_state ); - if (new_state & (_NEW_BUFFERS|_NEW_SCISSOR)) - update_drawbuffer( ctx ); + if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS)) + _mesa_update_buffers( ctx ); if (new_state & _NEW_POLYGON) - update_polygon( ctx ); + _mesa_update_polygon( ctx ); - /* Contributes to NeedEyeCoords, NeedNormals. - */ if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); - /* We can light in object space if the modelview matrix preserves - * lengths and relative angles. - */ - if (new_state & (_NEW_MODELVIEW|_NEW_LIGHT)) { - ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT_MODELVIEW; - if (ctx->Light.Enabled && - !TEST_MAT_FLAGS( ctx->ModelviewMatrixStack.Top, MAT_FLAGS_LENGTH_PRESERVING)) - ctx->_NeedEyeCoords |= NEED_EYE_LIGHT_MODELVIEW; - } if (new_state & _NEW_PROGRAM) update_program( ctx ); -#if 0 - /* XXX this is a bit of a hack. We should be checking elsewhere if - * vertex program mode is enabled. We set _NeedEyeCoords to zero to - * ensure that the combined modelview/projection matrix is computed - * in calculate_model_project_matrix(). - */ - if (ctx->VertexProgram.Enabled) - ctx->_NeedEyeCoords = 0; - /* KW: it's now always computed. - */ -#endif - - /* Keep ModelviewProject uptodate always to allow tnl - * implementations that go model->clip even when eye is required. - */ - if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) - calculate_model_project_matrix(ctx); /* ctx->_NeedEyeCoords is now uptodate. * @@ -1158,10 +800,8 @@ void _mesa_update_state( GLcontext *ctx ) * If the lighting space hasn't changed, may still need to recompute * light positions & normal transforms for other reasons. */ - if (new_state & (_NEW_MODELVIEW | - _NEW_LIGHT | - _MESA_NEW_NEED_EYE_COORDS)) - update_tnl_spaces( ctx, oldneedeyecoords ); + if (new_state & _MESA_NEW_NEED_EYE_COORDS) + _mesa_update_tnl_spaces( ctx, new_state ); /* * Here the driver sets up all the ctx->Driver function pointers @@ -1179,52 +819,7 @@ void _mesa_update_state( GLcontext *ctx ) /* At this point we can do some assertions to be sure the required * device driver function pointers are all initialized. */ - ASSERT(ctx->Driver.GetString); - ASSERT(ctx->Driver.UpdateState); - ASSERT(ctx->Driver.Clear); - ASSERT(ctx->Driver.GetBufferSize); - if (ctx->Visual.accumRedBits > 0) { - ASSERT(ctx->Driver.Accum); - } - ASSERT(ctx->Driver.DrawPixels); - ASSERT(ctx->Driver.ReadPixels); - ASSERT(ctx->Driver.CopyPixels); - ASSERT(ctx->Driver.Bitmap); - ASSERT(ctx->Driver.ResizeBuffers); - ASSERT(ctx->Driver.TexImage1D); - ASSERT(ctx->Driver.TexImage2D); - ASSERT(ctx->Driver.TexImage3D); - ASSERT(ctx->Driver.TexSubImage1D); - ASSERT(ctx->Driver.TexSubImage2D); - ASSERT(ctx->Driver.TexSubImage3D); - ASSERT(ctx->Driver.CopyTexImage1D); - ASSERT(ctx->Driver.CopyTexImage2D); - ASSERT(ctx->Driver.CopyTexSubImage1D); - ASSERT(ctx->Driver.CopyTexSubImage2D); - ASSERT(ctx->Driver.CopyTexSubImage3D); - if (ctx->Extensions.ARB_texture_compression) { -#if 0 /* HW drivers need these, but not SW rasterizers */ - ASSERT(ctx->Driver.CompressedTexImage1D); - ASSERT(ctx->Driver.CompressedTexImage2D); - ASSERT(ctx->Driver.CompressedTexImage3D); - ASSERT(ctx->Driver.CompressedTexSubImage1D); - ASSERT(ctx->Driver.CompressedTexSubImage2D); - ASSERT(ctx->Driver.CompressedTexSubImage3D); -#endif - } + _mesa_check_driver_hooks( ctx ); } -/* Is this helpful? - */ -void -_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag ) -{ - if (flag) - ctx->_NeedEyeCoords &= ~NEED_EYE_DRIVER; - else - ctx->_NeedEyeCoords |= NEED_EYE_DRIVER; - - ctx->NewState |= _NEW_POINT; /* one of the bits from - * _MESA_NEW_NEED_EYE_COORDS. - */ -} +/*@}*/ |