X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fstate.c;h=13ed623dcc6e42406003797d6e93d45225256d3e;hb=a96308c37db0bc0086a017d318bc3504aa5f0b1a;hp=3ba8faf9bad1265b7254168b4ce05e4ad1825bd2;hpb=a02fb6afc865a30077ae4d802a7020371c141e73;p=mesa.git diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 3ba8faf9bad..13ed623dcc6 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,8 +1,8 @@ -/* $Id: state.c,v 1.2 2000/02/02 19:34:08 brianp Exp $ */ +/* $Id: state.c,v 1.37 2000/10/30 13:32:01 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * @@ -44,6 +44,7 @@ #include "clip.h" #include "colortab.h" #include "context.h" +#include "convolve.h" #include "copypix.h" #include "cva.h" #include "depth.h" @@ -64,6 +65,7 @@ #include "mmath.h" #include "pipeline.h" #include "pixel.h" +#include "pixeltex.h" #include "points.h" #include "polygon.h" #include "quads.h" @@ -88,8 +90,6 @@ - - static int generic_noop(void) { @@ -100,20 +100,17 @@ generic_noop(void) } +/* + * Set all pointers in the given dispatch table to point to a + * generic no-op function. + */ void -_mesa_init_no_op_table(struct _glapi_table *table) +_mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) { - /* Check to be sure the dispatcher's table is at least as big as Mesa's. */ - const GLuint size = sizeof(struct _glapi_table) / sizeof(void *); - assert(_glapi_get_dispatch_table_size() >= size); - - { - const GLuint n = _glapi_get_dispatch_table_size(); - GLuint i; - void **dispatch = (void **) table; - for (i = 0; i < n; i++) { - dispatch[i] = (void *) generic_noop; - } + GLuint i; + void **dispatch = (void **) table; + for (i = 0; i < tableSize; i++) { + dispatch[i] = (void *) generic_noop; } } @@ -123,10 +120,10 @@ _mesa_init_no_op_table(struct _glapi_table *table) * immediate-mode commands. */ void -_mesa_init_exec_table(struct _glapi_table *exec) +_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) { /* first initialize all dispatch slots to no-op */ - _mesa_init_no_op_table(exec); + _mesa_init_no_op_table(exec, tableSize); /* load the dispatch slots we understand */ exec->Accum = _mesa_Accum; @@ -206,6 +203,13 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->FeedbackBuffer = _mesa_FeedbackBuffer; exec->Finish = _mesa_Finish; exec->Flush = _mesa_Flush; + + exec->FogCoordfEXT = _mesa_FogCoordfEXT; + exec->FogCoordfvEXT = _mesa_FogCoordfvEXT; + exec->FogCoorddEXT = _mesa_FogCoorddEXT; + exec->FogCoorddvEXT = _mesa_FogCoorddvEXT; + exec->FogCoordPointerEXT = _mesa_FogCoordPointerEXT; + exec->Fogf = _mesa_Fogf; exec->Fogfv = _mesa_Fogfv; exec->Fogi = _mesa_Fogi; @@ -356,6 +360,23 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->Scaled = _mesa_Scaled; exec->Scalef = _mesa_Scalef; exec->Scissor = _mesa_Scissor; + exec->SecondaryColor3bEXT = _mesa_SecondaryColor3bEXT; + exec->SecondaryColor3bvEXT = _mesa_SecondaryColor3bvEXT; + exec->SecondaryColor3sEXT = _mesa_SecondaryColor3sEXT; + exec->SecondaryColor3svEXT = _mesa_SecondaryColor3svEXT; + exec->SecondaryColor3iEXT = _mesa_SecondaryColor3iEXT; + exec->SecondaryColor3ivEXT = _mesa_SecondaryColor3ivEXT; + exec->SecondaryColor3fEXT = _mesa_SecondaryColor3fEXT; + exec->SecondaryColor3fvEXT = _mesa_SecondaryColor3fvEXT; + exec->SecondaryColor3dEXT = _mesa_SecondaryColor3dEXT; + exec->SecondaryColor3dvEXT = _mesa_SecondaryColor3dvEXT; + exec->SecondaryColor3ubEXT = _mesa_SecondaryColor3ubEXT; + exec->SecondaryColor3ubvEXT = _mesa_SecondaryColor3ubvEXT; + exec->SecondaryColor3usEXT = _mesa_SecondaryColor3usEXT; + exec->SecondaryColor3usvEXT = _mesa_SecondaryColor3usvEXT; + exec->SecondaryColor3uiEXT = _mesa_SecondaryColor3uiEXT; + exec->SecondaryColor3uivEXT = _mesa_SecondaryColor3uivEXT; + exec->SecondaryColorPointerEXT = _mesa_SecondaryColorPointerEXT; exec->SelectBuffer = _mesa_SelectBuffer; exec->ShadeModel = _mesa_ShadeModel; exec->StencilFunc = _mesa_StencilFunc; @@ -474,7 +495,6 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->TexImage3D = _mesa_TexImage3D; exec->TexSubImage3D = _mesa_TexSubImage3D; - /* OpenGL 1.2 GL_ARB_imaging */ exec->BlendColor = _mesa_BlendColor; exec->BlendEquation = _mesa_BlendEquation; @@ -511,39 +531,106 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->ResetMinmax = _mesa_ResetMinmax; exec->SeparableFilter2D = _mesa_SeparableFilter2D; + /* 2. GL_EXT_blend_color */ +#if 0 + exec->BlendColorEXT = _mesa_BlendColorEXT; +#endif + + /* 3. GL_EXT_polygon_offset */ + exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; + /* 6. GL_EXT_texture3d */ +#if 0 exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; exec->TexImage3DEXT = _mesa_TexImage3DEXT; exec->TexSubImage3DEXT = _mesa_TexSubImage3D; +#endif - /* GL_EXT_paletted_texture */ - exec->ColorTableEXT = _mesa_ColorTableEXT; - exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; - exec->GetColorTableEXT = _mesa_GetColorTableEXT; - exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfvEXT; - exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameterivEXT; - - /* GL_EXT_compiled_vertex_array */ - exec->LockArraysEXT = _mesa_LockArraysEXT; - exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; + /* 11. GL_EXT_histogram */ + exec->GetHistogramEXT = _mesa_GetHistogram; + exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv; + exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv; + exec->GetMinmaxEXT = _mesa_GetMinmax; + exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv; + exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv; + + /* ?. GL_SGIX_pixel_texture */ + exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX; + + /* 15. GL_SGIS_pixel_texture */ + exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS; + exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS; + exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS; + exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS; + exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; + exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; + + /* 30. GL_EXT_vertex_array */ + exec->ColorPointerEXT = _mesa_ColorPointerEXT; + exec->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT; + exec->IndexPointerEXT = _mesa_IndexPointerEXT; + exec->NormalPointerEXT = _mesa_NormalPointerEXT; + exec->TexCoordPointerEXT = _mesa_TexCoordPointerEXT; + exec->VertexPointerEXT = _mesa_VertexPointerEXT; + + /* 37. GL_EXT_blend_minmax */ +#if 0 + exec->BlendEquationEXT = _mesa_BlendEquationEXT; +#endif - /* GL_EXT_point_parameters */ + /* 54. GL_EXT_point_parameters */ exec->PointParameterfEXT = _mesa_PointParameterfEXT; exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; /* 77. GL_PGI_misc_hints */ exec->HintPGI = _mesa_HintPGI; - /* GL_EXT_polygon_offset */ - exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; + /* 78. GL_EXT_paletted_texture */ +#if 0 + exec->ColorTableEXT = _mesa_ColorTableEXT; + exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; +#endif + exec->GetColorTableEXT = _mesa_GetColorTable; + exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; + exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; - /* GL_EXT_blend_minmax */ - exec->BlendEquationEXT = _mesa_BlendEquationEXT; + /* 97. GL_EXT_compiled_vertex_array */ + exec->LockArraysEXT = _mesa_LockArraysEXT; + exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; - /* GL_EXT_blend_color */ - exec->BlendColorEXT = _mesa_BlendColorEXT; + /* 173. GL_INGR_blend_func_separate */ + exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; - /* GL_ARB_multitexture */ + /* 196. GL_MESA_resize_buffers */ + exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; + + /* 197. GL_MESA_window_pos */ + exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; + exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; + exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; + exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA; + exec->WindowPos2iMESA = _mesa_WindowPos2iMESA; + exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA; + exec->WindowPos2sMESA = _mesa_WindowPos2sMESA; + exec->WindowPos2svMESA = _mesa_WindowPos2svMESA; + exec->WindowPos3dMESA = _mesa_WindowPos3dMESA; + exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA; + exec->WindowPos3fMESA = _mesa_WindowPos3fMESA; + exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA; + exec->WindowPos3iMESA = _mesa_WindowPos3iMESA; + exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA; + exec->WindowPos3sMESA = _mesa_WindowPos3sMESA; + exec->WindowPos3svMESA = _mesa_WindowPos3svMESA; + exec->WindowPos4dMESA = _mesa_WindowPos4dMESA; + exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA; + exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; + exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA; + exec->WindowPos4iMESA = _mesa_WindowPos4iMESA; + exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; + exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; + exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; + + /* ARB 1. GL_ARB_multitexture */ exec->ActiveTextureARB = _mesa_ActiveTextureARB; exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; exec->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; @@ -579,159 +666,29 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; exec->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; - /* GL_INGR_blend_func_separate */ - exec->BlendFuncSeparateINGR = _mesa_BlendFuncSeparateINGR; - - /* GL_MESA_window_pos */ - exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; - - /* GL_MESA_resize_buffers */ - exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; - - /* GL_ARB_transpose_matrix */ + /* ARB 3. GL_ARB_transpose_matrix */ exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB; exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB; exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB; exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB; -} - - -/**********************************************************************/ -/***** State update logic *****/ -/**********************************************************************/ + /* ARB 12. GL_ARB_texture_compression */ + exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB; + exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB; + exec->CompressedTexImage1DARB = _mesa_CompressedTexImage1DARB; + exec->CompressedTexSubImage3DARB = _mesa_CompressedTexSubImage3DARB; + exec->CompressedTexSubImage2DARB = _mesa_CompressedTexSubImage2DARB; + exec->CompressedTexSubImage1DARB = _mesa_CompressedTexSubImage1DARB; + exec->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB; -/* - * Since the device driver may or may not support pixel logic ops we - * have to make some extensive tests to determine whether or not - * software-implemented logic operations have to be used. - */ -static void update_pixel_logic( GLcontext *ctx ) -{ - if (ctx->Visual->RGBAflag) { - /* RGBA mode blending w/ Logic Op */ - if (ctx->Color.ColorLogicOpEnabled) { - if (ctx->Driver.LogicOp - && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { - /* Device driver can do logic, don't have to do it in software */ - ctx->Color.SWLogicOpEnabled = GL_FALSE; - } - else { - /* Device driver can't do logic op so we do it in software */ - ctx->Color.SWLogicOpEnabled = GL_TRUE; - } - } - else { - /* no logic op */ - if (ctx->Driver.LogicOp) { - (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); - } - ctx->Color.SWLogicOpEnabled = GL_FALSE; - } - } - else { - /* CI mode Logic Op */ - if (ctx->Color.IndexLogicOpEnabled) { - if (ctx->Driver.LogicOp - && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { - /* Device driver can do logic, don't have to do it in software */ - ctx->Color.SWLogicOpEnabled = GL_FALSE; - } - else { - /* Device driver can't do logic op so we do it in software */ - ctx->Color.SWLogicOpEnabled = GL_TRUE; - } - } - else { - /* no logic op */ - if (ctx->Driver.LogicOp) { - (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); - } - ctx->Color.SWLogicOpEnabled = GL_FALSE; - } - } } -/* - * Check if software implemented RGBA or Color Index masking is needed. - */ -static void update_pixel_masking( GLcontext *ctx ) -{ - if (ctx->Visual->RGBAflag) { - GLuint *colorMask = (GLuint *) ctx->Color.ColorMask; - if (*colorMask == 0xffffffff) { - /* disable masking */ - if (ctx->Driver.ColorMask) { - (void) (*ctx->Driver.ColorMask)( ctx, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - } - ctx->Color.SWmasking = GL_FALSE; - } - else { - /* Ask driver to do color masking, if it can't then - * do it in software - */ - GLboolean red = ctx->Color.ColorMask[RCOMP] ? GL_TRUE : GL_FALSE; - GLboolean green = ctx->Color.ColorMask[GCOMP] ? GL_TRUE : GL_FALSE; - GLboolean blue = ctx->Color.ColorMask[BCOMP] ? GL_TRUE : GL_FALSE; - GLboolean alpha = ctx->Color.ColorMask[ACOMP] ? GL_TRUE : GL_FALSE; - if (ctx->Driver.ColorMask - && (*ctx->Driver.ColorMask)( ctx, red, green, blue, alpha )) { - ctx->Color.SWmasking = GL_FALSE; - } - else { - ctx->Color.SWmasking = GL_TRUE; - } - } - } - else { - if (ctx->Color.IndexMask==0xffffffff) { - /* disable masking */ - if (ctx->Driver.IndexMask) { - (void) (*ctx->Driver.IndexMask)( ctx, 0xffffffff ); - } - ctx->Color.SWmasking = GL_FALSE; - } - else { - /* Ask driver to do index masking, if it can't then - * do it in software - */ - if (ctx->Driver.IndexMask - && (*ctx->Driver.IndexMask)( ctx, ctx->Color.IndexMask )) { - ctx->Color.SWmasking = GL_FALSE; - } - else { - ctx->Color.SWmasking = GL_TRUE; - } - } - } -} - +/**********************************************************************/ +/***** State update logic *****/ +/**********************************************************************/ -static void update_fog_mode( GLcontext *ctx ) -{ - int old_mode = ctx->FogMode; - - if (ctx->Fog.Enabled) { - if (ctx->Texture.Enabled) - ctx->FogMode = FOG_FRAGMENT; - else if (ctx->Hint.Fog == GL_NICEST) - ctx->FogMode = FOG_FRAGMENT; - else - ctx->FogMode = FOG_VERTEX; - - if (ctx->Driver.GetParameteri) - if ((ctx->Driver.GetParameteri)( ctx, DD_HAVE_HARDWARE_FOG )) - ctx->FogMode = FOG_FRAGMENT; - } - else { - ctx->FogMode = FOG_NONE; - } - - if (old_mode != ctx->FogMode) - ctx->NewState |= NEW_FOG; -} /* @@ -742,31 +699,43 @@ static void update_rasterflags( GLcontext *ctx ) { ctx->RasterMask = 0; - if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT; - if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT; - if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT; - if (ctx->FogMode==FOG_FRAGMENT) ctx->RasterMask |= FOG_BIT; - if (ctx->Color.SWLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT; - if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT; - if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT; - if (ctx->Color.SWmasking) ctx->RasterMask |= MASKING_BIT; + if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT; + if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT; + if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT; + if (ctx->Fog.Enabled) ctx->RasterMask |= FOG_BIT; + if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT; + if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT; + if (ctx->Visual.RGBAflag) { + const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); + if (colorMask != 0xffffffff) ctx->RasterMask |= MASKING_BIT; + if (ctx->Color.ColorLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT; + if (ctx->Texture.ReallyEnabled) ctx->RasterMask |= TEXTURE_BIT; + } + else { + if (ctx->Color.IndexMask != 0xffffffff) ctx->RasterMask |= MASKING_BIT; + if (ctx->Color.IndexLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT; + } - if (ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[ACOMP] + if (ctx->DrawBuffer->UseSoftwareAlphaBuffers + && ctx->Color.ColorMask[ACOMP] && ctx->Color.DrawBuffer != GL_NONE) ctx->RasterMask |= ALPHABUF_BIT; - if ( ctx->Viewport.X<0 + if ( ctx->Viewport.X < 0 || ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width - || ctx->Viewport.Y<0 + || ctx->Viewport.Y < 0 || ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) { ctx->RasterMask |= WINCLIP_BIT; } + if (ctx->Depth.OcclusionTest) + ctx->RasterMask |= OCCLUSION_BIT; + + /* If we're not drawing to exactly one color buffer set the * MULTI_DRAW_BIT flag. Also set it if we're drawing to no * buffers or the RGBA or CI mask disables all writes. */ - ctx->TriangleCaps &= ~DD_MULTIDRAW; if (ctx->Color.MultiDrawBuffer) { @@ -777,17 +746,15 @@ static void update_rasterflags( GLcontext *ctx ) ctx->RasterMask |= MULTI_DRAW_BIT; ctx->TriangleCaps |= DD_MULTIDRAW; } - else if (ctx->Visual->RGBAflag && ctx->Color.ColorMask==0) { + else if (ctx->Visual.RGBAflag && *((GLuint *) ctx->Color.ColorMask) == 0) { /* all RGBA channels disabled */ ctx->RasterMask |= MULTI_DRAW_BIT; ctx->TriangleCaps |= DD_MULTIDRAW; - ctx->Color.DrawDestMask = 0; } - else if (!ctx->Visual->RGBAflag && ctx->Color.IndexMask==0) { + else if (!ctx->Visual.RGBAflag && ctx->Color.IndexMask==0) { /* all color index bits disabled */ ctx->RasterMask |= MULTI_DRAW_BIT; ctx->TriangleCaps |= DD_MULTIDRAW; - ctx->Color.DrawDestMask = 0; } } @@ -795,27 +762,36 @@ static void update_rasterflags( GLcontext *ctx ) void gl_print_state( const char *msg, GLuint state ) { fprintf(stderr, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", msg, state, - (state & NEW_LIGHTING) ? "lighting, " : "", - (state & NEW_RASTER_OPS) ? "raster-ops, " : "", - (state & NEW_TEXTURING) ? "texturing, " : "", - (state & NEW_POLYGON) ? "polygon, " : "", - (state & NEW_DRVSTATE0) ? "driver-0, " : "", - (state & NEW_DRVSTATE1) ? "driver-1, " : "", - (state & NEW_DRVSTATE2) ? "driver-2, " : "", - (state & NEW_DRVSTATE3) ? "driver-3, " : "", - (state & NEW_MODELVIEW) ? "modelview, " : "", - (state & NEW_PROJECTION) ? "projection, " : "", - (state & NEW_TEXTURE_MATRIX) ? "texture-matrix, " : "", - (state & NEW_USER_CLIP) ? "user-clip, " : "", - (state & NEW_TEXTURE_ENV) ? "texture-env, " : "", - (state & NEW_CLIENT_STATE) ? "client-state, " : "", - (state & NEW_FOG) ? "fog, " : "", - (state & NEW_NORMAL_TRANSFORM) ? "normal-transform, " : "", - (state & NEW_VIEWPORT) ? "viewport, " : "", - (state & NEW_TEXTURE_ENABLE) ? "texture-enable, " : ""); + (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "", + (state & _NEW_PROJECTION) ? "ctx->Projection, " : "", + (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "", + (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "", + (state & _NEW_ACCUM) ? "ctx->Accum, " : "", + (state & _NEW_COLOR) ? "ctx->Color, " : "", + (state & _NEW_DEPTH) ? "ctx->Depth, " : "", + (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "", + (state & _NEW_FOG) ? "ctx->Fog, " : "", + (state & _NEW_HINT) ? "ctx->Hint, " : "", + (state & _NEW_IMAGING) ? "ctx->Histogram/MinMax/Convolve/Seperable, ": "", + (state & _NEW_LIGHT) ? "ctx->Light, " : "", + (state & _NEW_LINE) ? "ctx->Line, " : "", + (state & _NEW_FEEDBACK_SELECT) ? "ctx->Feedback/Select, " : "", + (state & _NEW_PIXEL) ? "ctx->Pixel, " : "", + (state & _NEW_POINT) ? "ctx->Point, " : "", + (state & _NEW_POLYGON) ? "ctx->Polygon, " : "", + (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "", + (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "", + (state & _NEW_TEXTURE) ? "ctx->Texture, " : "", + (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "", + (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "", + (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "", + (state & _NEW_ARRAY) ? "ctx->Array, " : "", + (state & _NEW_COLORTABLE) ? "ctx->{*}ColorTable, " : "", + (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "", + (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : ""); } @@ -851,27 +827,14 @@ void gl_update_state( GLcontext *ctx ) if (MESA_VERBOSE & VERBOSE_STATE) gl_print_state("", ctx->NewState); - if (ctx->NewState & NEW_CLIENT_STATE) + if (ctx->NewState & _NEW_ARRAY) gl_update_client_state( ctx ); - if ((ctx->NewState & NEW_TEXTURE_ENABLE) && - (ctx->Enabled & ENABLE_TEX_ANY) != ctx->Texture.Enabled) - ctx->NewState |= NEW_TEXTURING | NEW_RASTER_OPS; - - if (ctx->NewState & NEW_TEXTURE_ENV) { - if (ctx->Texture.Unit[0].EnvMode == ctx->Texture.Unit[0].LastEnvMode && - ctx->Texture.Unit[1].EnvMode == ctx->Texture.Unit[1].LastEnvMode) - ctx->NewState &= ~NEW_TEXTURE_ENV; - ctx->Texture.Unit[0].LastEnvMode = ctx->Texture.Unit[0].EnvMode; - ctx->Texture.Unit[1].LastEnvMode = ctx->Texture.Unit[1].EnvMode; - } - - if (ctx->NewState & NEW_TEXTURE_MATRIX) { - ctx->Enabled &= ~(ENABLE_TEXMAT0|ENABLE_TEXMAT1); + if (ctx->NewState & _NEW_TEXTURE_MATRIX) { + ctx->Enabled &= ~(ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2); - for (i=0; i < MAX_TEXTURE_UNITS; i++) { - if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) - { + for (i=0; i < ctx->Const.MaxTextureUnits; i++) { + if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) { gl_matrix_analyze( &ctx->TextureMatrix[i] ); ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS; @@ -882,101 +845,85 @@ void gl_update_state( GLcontext *ctx ) } } - if (ctx->NewState & (NEW_TEXTURING | NEW_TEXTURE_ENABLE)) { + if (ctx->NewState & _NEW_TEXTURE) { + ctx->Texture.MultiTextureEnabled = GL_FALSE; ctx->Texture.NeedNormals = GL_FALSE; gl_update_dirty_texobjs(ctx); - ctx->Enabled &= ~(ENABLE_TEXGEN0|ENABLE_TEXGEN1); + ctx->Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2); ctx->Texture.ReallyEnabled = 0; - for (i=0; i < MAX_TEXTURE_UNITS; i++) { + for (i=0; i < ctx->Const.MaxTextureUnits; i++) { if (ctx->Texture.Unit[i].Enabled) { gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] ); ctx->Texture.ReallyEnabled |= - ctx->Texture.Unit[i].ReallyEnabled<<(i*4); + ctx->Texture.Unit[i].ReallyEnabled << (i * 4); if (ctx->Texture.Unit[i].GenFlags != 0) { ctx->Enabled |= ENABLE_TEXGEN0 << i; - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) { ctx->Texture.NeedNormals = GL_TRUE; ctx->Texture.NeedEyeCoords = GL_TRUE; } - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) { ctx->Texture.NeedEyeCoords = GL_TRUE; } } + + if (i > 0 && ctx->Texture.Unit[i].ReallyEnabled) { + ctx->Texture.MultiTextureEnabled = GL_TRUE; + } } + else { + ctx->Texture.Unit[i].ReallyEnabled = 0; + } } - - ctx->Texture.Enabled = ctx->Enabled & ENABLE_TEX_ANY; + ctx->Enabled = (ctx->Enabled & ~ENABLE_TEX_ANY) | ctx->Texture.ReallyEnabled; ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); } - if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING | NEW_FOG)) { - - - if (ctx->NewState & NEW_RASTER_OPS) { - update_pixel_logic(ctx); - update_pixel_masking(ctx); - update_fog_mode(ctx); - update_rasterflags(ctx); - if (ctx->Driver.Dither) { - (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag ); - } - - /* Check if incoming colors can be modified during rasterization */ - if (ctx->Fog.Enabled || - ctx->Texture.Enabled || - ctx->Color.BlendEnabled || - ctx->Color.SWmasking || - ctx->Color.SWLogicOpEnabled) { - ctx->MutablePixels = GL_TRUE; - } - else { - ctx->MutablePixels = GL_FALSE; - } - - /* update scissor region */ - ctx->DrawBuffer->Xmin = 0; - ctx->DrawBuffer->Ymin = 0; - ctx->DrawBuffer->Xmax = ctx->DrawBuffer->Width-1; - ctx->DrawBuffer->Ymax = ctx->DrawBuffer->Height-1; - 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 - 1 < ctx->DrawBuffer->Xmax) { - ctx->DrawBuffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1; - } - if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->DrawBuffer->Ymax) { - ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1; - } - } + if (ctx->NewState & _SWRAST_NEW_RASTERMASK) + update_rasterflags(ctx); + + if (ctx->NewState & (_NEW_BUFFERS|_NEW_SCISSOR)) { + /* update scissor region */ + 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; + } } + } - if (ctx->NewState & NEW_LIGHTING) { - ctx->TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); - if (ctx->Light.Enabled) { - if (ctx->Light.Model.TwoSide) - ctx->TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); - gl_update_lighting(ctx); - } + if (ctx->NewState & _NEW_LIGHT) { + ctx->TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); + if (ctx->Light.Enabled) { + if (ctx->Light.Model.TwoSide) + ctx->TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); + gl_update_lighting(ctx); } } - if (ctx->NewState & (NEW_POLYGON | NEW_LIGHTING)) { + if (ctx->NewState & (_NEW_POLYGON | _NEW_LIGHT)) { ctx->TriangleCaps &= ~DD_TRI_CULL_FRONT_BACK; - if (ctx->NewState & NEW_POLYGON) { + if (ctx->NewState & _NEW_POLYGON) { /* Setup CullBits bitmask */ if (ctx->Polygon.CullFlag) { ctx->backface_sign = 1; @@ -1011,30 +958,16 @@ void gl_update_state( GLcontext *ctx ) ctx->Polygon.OffsetLine || ctx->Polygon.OffsetFill) ctx->TriangleCaps |= DD_TRI_OFFSET; - - /* reset Z offsets now */ - ctx->PointZoffset = 0.0; - ctx->LineZoffset = 0.0; - ctx->PolygonZoffset = 0.0; } } - if (ctx->NewState & ~(NEW_CLIENT_STATE| - NEW_DRIVER_STATE|NEW_USER_CLIP| - NEW_POLYGON)) + if (ctx->NewState & (_NEW_LIGHT| + _NEW_TEXTURE| + _NEW_FOG| + _NEW_POLYGON)) gl_update_clipmask(ctx); - if (ctx->NewState & (NEW_LIGHTING| - NEW_RASTER_OPS| - NEW_TEXTURING| - NEW_TEXTURE_ENABLE| - NEW_TEXTURE_ENV| - NEW_POLYGON| - NEW_DRVSTATE0| - NEW_DRVSTATE1| - NEW_DRVSTATE2| - NEW_DRVSTATE3| - NEW_USER_CLIP)) + if (ctx->NewState & ctx->Driver.UpdateStateNotify) { ctx->IndirectTriangles = ctx->TriangleCaps & ~ctx->Driver.TriangleCaps; ctx->IndirectTriangles |= DD_SW_RASTERIZE; @@ -1085,13 +1018,13 @@ void gl_update_state( GLcontext *ctx ) /* Should only be calc'd when !need_eye_coords and not culling. */ - if (ctx->NewState & (NEW_MODELVIEW|NEW_PROJECTION)) { - if (ctx->NewState & NEW_MODELVIEW) { + if (ctx->NewState & (_NEW_MODELVIEW|_NEW_PROJECTION)) { + if (ctx->NewState & _NEW_MODELVIEW) { gl_matrix_analyze( &ctx->ModelView ); ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS; } - if (ctx->NewState & NEW_PROJECTION) { + if (ctx->NewState & _NEW_PROJECTION) { gl_matrix_analyze( &ctx->ProjectionMatrix ); ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS; @@ -1101,21 +1034,26 @@ void gl_update_state( GLcontext *ctx ) } gl_calculate_model_project_matrix( ctx ); - ctx->ModelProjectWinMatrixUptodate = 0; + } + + if (ctx->NewState & _NEW_COLOR_MATRIX) { + gl_matrix_analyze( &ctx->ColorMatrix ); } /* Figure out whether we can light in object space or not. If we * can, find the current positions of the lights in object space */ if ((ctx->Enabled & (ENABLE_POINT_ATTEN | ENABLE_LIGHT | ENABLE_FOG | - ENABLE_TEXGEN0 | ENABLE_TEXGEN1)) && - (ctx->NewState & (NEW_LIGHTING | - NEW_FOG | - NEW_MODELVIEW | - NEW_PROJECTION | - NEW_TEXTURING | - NEW_RASTER_OPS | - NEW_USER_CLIP))) + ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2)) && + (ctx->NewState & (_NEW_LIGHT | + _NEW_TEXTURE | + _NEW_FOG | + _NEW_TRANSFORM | + _NEW_MODELVIEW | + _NEW_PROJECTION | + _NEW_POINT | + _NEW_RENDERMODE | + _NEW_TRANSFORM))) { GLboolean oldcoord, oldnorm; @@ -1123,23 +1061,21 @@ void gl_update_state( GLcontext *ctx ) oldnorm = ctx->NeedEyeNormals; ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); - ctx->NeedEyeCoords = ((ctx->Fog.Enabled && ctx->Hint.Fog != GL_NICEST) || - ctx->Point.Attenuated); + ctx->NeedEyeCoords = (ctx->Fog.Enabled || ctx->Point.Attenuated); ctx->NeedEyeNormals = GL_FALSE; if (ctx->Light.Enabled) { - if (ctx->Light.Flags & LIGHT_POSITIONAL) { - /* Need length for attenuation */ - if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING)) - ctx->NeedEyeCoords = GL_TRUE; - } else if (ctx->Light.NeedVertices) { - /* Need angle for spot calculations */ - if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_ANGLE_PRESERVING)) - ctx->NeedEyeCoords = GL_TRUE; + if ((ctx->Light.Flags & LIGHT_POSITIONAL) || + ctx->Light.NeedVertices || + !TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING)) { + /* Need length for attenuation or need angle for spotlights + * or non-uniform scale matrix + */ + ctx->NeedEyeCoords = GL_TRUE; } ctx->NeedEyeNormals = ctx->NeedEyeCoords; } - if (ctx->Texture.Enabled || ctx->RenderMode==GL_FEEDBACK) { + if (ctx->Texture.ReallyEnabled || ctx->RenderMode==GL_FEEDBACK) { if (ctx->Texture.NeedEyeCoords) ctx->NeedEyeCoords = GL_TRUE; if (ctx->Texture.NeedNormals) ctx->NeedNormals = ctx->NeedEyeNormals = GL_TRUE; @@ -1153,8 +1089,8 @@ void gl_update_state( GLcontext *ctx ) if (ctx->Light.Enabled) { gl_update_lighting_function(ctx); - if ( (ctx->NewState & NEW_LIGHTING) || - ((ctx->NewState & (NEW_MODELVIEW| NEW_PROJECTION)) && + if ( (ctx->NewState & _NEW_LIGHT) || + ((ctx->NewState & (_NEW_MODELVIEW|_NEW_PROJECTION)) && !ctx->NeedEyeCoords) || oldcoord != ctx->NeedEyeCoords || oldnorm != ctx->NeedEyeNormals) { @@ -1162,17 +1098,14 @@ void gl_update_state( GLcontext *ctx ) } ctx->rescale_factor = 1.0F; - if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE | MAT_FLAG_GENERAL_SCALE | MAT_FLAG_GENERAL_3D | - MAT_FLAG_GENERAL) ) - - { - GLfloat *m = ctx->ModelView.inv; - GLfloat f = m[2]*m[2] + m[6]*m[6] + m[10]*m[10]; - if (f > 1e-12 && (f-1)*(f-1) > 1e-12) - ctx->rescale_factor = 1.0/GL_SQRT(f); + MAT_FLAG_GENERAL) ) { + const GLfloat *m = ctx->ModelView.inv; + const GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; + if (f > 1e-12 && (f - 1.0) * (f - 1.0) > 1e-12) + ctx->rescale_factor = 1.0 / GL_SQRT(f); } } @@ -1182,3 +1115,61 @@ void gl_update_state( GLcontext *ctx ) gl_update_pipelines(ctx); ctx->NewState = 0; } + + + + +/* + * Return a bitmask of IMAGE_*_BIT flags which to indicate which + * pixel transfer operations are enabled. + */ +void +_mesa_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.PostConvolutionColorTableEnabled) + mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; + + if (ctx->ColorMatrix.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; +}