state.c revision 350353adcd75f94fda63c787c86961716114e0bf
1/* $Id: state.c,v 1.100 2003/03/15 17:33:26 brianp Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 5.1 6 * 7 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a 10 * copy of this software and associated documentation files (the "Software"), 11 * to deal in the Software without restriction, including without limitation 12 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 * and/or sell copies of the Software, and to permit persons to whom the 14 * Software is furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 */ 26 27 28/* 29 * This file manages recalculation of derived values in the 30 * __GLcontext. 31 */ 32 33 34#include "glheader.h" 35#include "accum.h" 36#include "api_loopback.h" 37#include "attrib.h" 38#include "blend.h" 39#include "buffers.h" 40#include "clip.h" 41#include "colortab.h" 42#include "context.h" 43#include "convolve.h" 44#include "depth.h" 45#include "dlist.h" 46#include "drawpix.h" 47#include "enable.h" 48#include "eval.h" 49#include "get.h" 50#include "feedback.h" 51#include "fog.h" 52#include "hint.h" 53#include "histogram.h" 54#include "imports.h" 55#include "light.h" 56#include "lines.h" 57#include "matrix.h" 58#include "pixel.h" 59#include "points.h" 60#include "polygon.h" 61#include "rastpos.h" 62#include "state.h" 63#include "stencil.h" 64#include "teximage.h" 65#include "texobj.h" 66#include "texstate.h" 67#include "mtypes.h" 68#include "varray.h" 69#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program 70#include "nvprogram.h" 71#endif 72 73#include "math/m_matrix.h" 74#include "math/m_xform.h" 75 76 77static int 78generic_noop(void) 79{ 80#ifdef DEBUG 81 _mesa_problem(NULL, "User called no-op dispatch function"); 82#endif 83 return 0; 84} 85 86 87/* 88 * Set all pointers in the given dispatch table to point to a 89 * generic no-op function. 90 */ 91void 92_mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) 93{ 94 GLuint i; 95 void **dispatch = (void **) table; 96 for (i = 0; i < tableSize; i++) { 97 dispatch[i] = (void *) generic_noop; 98 } 99} 100 101 102 103/* 104 * Initialize the given dispatch table with pointers to Mesa's 105 * immediate-mode commands. 106 * 107 * Pointers to begin/end object commands and a few others 108 * are provided via the vtxfmt interface elsewhere. 109 */ 110void 111_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) 112{ 113 /* first initialize all dispatch slots to no-op */ 114 _mesa_init_no_op_table(exec, tableSize); 115 116 _mesa_loopback_init_api_table( exec, GL_TRUE ); 117 118 /* load the dispatch slots we understand */ 119 exec->Accum = _mesa_Accum; 120 exec->AlphaFunc = _mesa_AlphaFunc; 121 exec->Bitmap = _mesa_Bitmap; 122 exec->BlendFunc = _mesa_BlendFunc; 123 exec->CallList = _mesa_CallList; 124 exec->CallLists = _mesa_CallLists; 125 exec->Clear = _mesa_Clear; 126 exec->ClearAccum = _mesa_ClearAccum; 127 exec->ClearColor = _mesa_ClearColor; 128 exec->ClearDepth = _mesa_ClearDepth; 129 exec->ClearIndex = _mesa_ClearIndex; 130 exec->ClearStencil = _mesa_ClearStencil; 131 exec->ClipPlane = _mesa_ClipPlane; 132 exec->ColorMask = _mesa_ColorMask; 133 exec->ColorMaterial = _mesa_ColorMaterial; 134 exec->CopyPixels = _mesa_CopyPixels; 135 exec->CullFace = _mesa_CullFace; 136 exec->DeleteLists = _mesa_DeleteLists; 137 exec->DepthFunc = _mesa_DepthFunc; 138 exec->DepthMask = _mesa_DepthMask; 139 exec->DepthRange = _mesa_DepthRange; 140 exec->Disable = _mesa_Disable; 141 exec->DrawBuffer = _mesa_DrawBuffer; 142 exec->DrawPixels = _mesa_DrawPixels; 143 exec->Enable = _mesa_Enable; 144 exec->EndList = _mesa_EndList; 145 exec->FeedbackBuffer = _mesa_FeedbackBuffer; 146 exec->Finish = _mesa_Finish; 147 exec->Flush = _mesa_Flush; 148 exec->FogCoordPointerEXT = _mesa_FogCoordPointerEXT; 149 exec->Fogf = _mesa_Fogf; 150 exec->Fogfv = _mesa_Fogfv; 151 exec->Fogi = _mesa_Fogi; 152 exec->Fogiv = _mesa_Fogiv; 153 exec->FrontFace = _mesa_FrontFace; 154 exec->Frustum = _mesa_Frustum; 155 exec->GenLists = _mesa_GenLists; 156 exec->GetBooleanv = _mesa_GetBooleanv; 157 exec->GetClipPlane = _mesa_GetClipPlane; 158 exec->GetDoublev = _mesa_GetDoublev; 159 exec->GetError = _mesa_GetError; 160 exec->GetFloatv = _mesa_GetFloatv; 161 exec->GetIntegerv = _mesa_GetIntegerv; 162 exec->GetLightfv = _mesa_GetLightfv; 163 exec->GetLightiv = _mesa_GetLightiv; 164 exec->GetMapdv = _mesa_GetMapdv; 165 exec->GetMapfv = _mesa_GetMapfv; 166 exec->GetMapiv = _mesa_GetMapiv; 167 exec->GetMaterialfv = _mesa_GetMaterialfv; 168 exec->GetMaterialiv = _mesa_GetMaterialiv; 169 exec->GetPixelMapfv = _mesa_GetPixelMapfv; 170 exec->GetPixelMapuiv = _mesa_GetPixelMapuiv; 171 exec->GetPixelMapusv = _mesa_GetPixelMapusv; 172 exec->GetPolygonStipple = _mesa_GetPolygonStipple; 173 exec->GetString = _mesa_GetString; 174 exec->GetTexEnvfv = _mesa_GetTexEnvfv; 175 exec->GetTexEnviv = _mesa_GetTexEnviv; 176 exec->GetTexGendv = _mesa_GetTexGendv; 177 exec->GetTexGenfv = _mesa_GetTexGenfv; 178 exec->GetTexGeniv = _mesa_GetTexGeniv; 179 exec->GetTexImage = _mesa_GetTexImage; 180 exec->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; 181 exec->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; 182 exec->GetTexParameterfv = _mesa_GetTexParameterfv; 183 exec->GetTexParameteriv = _mesa_GetTexParameteriv; 184 exec->Hint = _mesa_Hint; 185 exec->IndexMask = _mesa_IndexMask; 186 exec->InitNames = _mesa_InitNames; 187 exec->IsEnabled = _mesa_IsEnabled; 188 exec->IsList = _mesa_IsList; 189 exec->LightModelf = _mesa_LightModelf; 190 exec->LightModelfv = _mesa_LightModelfv; 191 exec->LightModeli = _mesa_LightModeli; 192 exec->LightModeliv = _mesa_LightModeliv; 193 exec->Lightf = _mesa_Lightf; 194 exec->Lightfv = _mesa_Lightfv; 195 exec->Lighti = _mesa_Lighti; 196 exec->Lightiv = _mesa_Lightiv; 197 exec->LineStipple = _mesa_LineStipple; 198 exec->LineWidth = _mesa_LineWidth; 199 exec->ListBase = _mesa_ListBase; 200 exec->LoadIdentity = _mesa_LoadIdentity; 201 exec->LoadMatrixd = _mesa_LoadMatrixd; 202 exec->LoadMatrixf = _mesa_LoadMatrixf; 203 exec->LoadName = _mesa_LoadName; 204 exec->LogicOp = _mesa_LogicOp; 205 exec->Map1d = _mesa_Map1d; 206 exec->Map1f = _mesa_Map1f; 207 exec->Map2d = _mesa_Map2d; 208 exec->Map2f = _mesa_Map2f; 209 exec->MapGrid1d = _mesa_MapGrid1d; 210 exec->MapGrid1f = _mesa_MapGrid1f; 211 exec->MapGrid2d = _mesa_MapGrid2d; 212 exec->MapGrid2f = _mesa_MapGrid2f; 213 exec->MatrixMode = _mesa_MatrixMode; 214 exec->MultMatrixd = _mesa_MultMatrixd; 215 exec->MultMatrixf = _mesa_MultMatrixf; 216 exec->NewList = _mesa_NewList; 217 exec->Ortho = _mesa_Ortho; 218 exec->PassThrough = _mesa_PassThrough; 219 exec->PixelMapfv = _mesa_PixelMapfv; 220 exec->PixelMapuiv = _mesa_PixelMapuiv; 221 exec->PixelMapusv = _mesa_PixelMapusv; 222 exec->PixelStoref = _mesa_PixelStoref; 223 exec->PixelStorei = _mesa_PixelStorei; 224 exec->PixelTransferf = _mesa_PixelTransferf; 225 exec->PixelTransferi = _mesa_PixelTransferi; 226 exec->PixelZoom = _mesa_PixelZoom; 227 exec->PointSize = _mesa_PointSize; 228 exec->PolygonMode = _mesa_PolygonMode; 229 exec->PolygonOffset = _mesa_PolygonOffset; 230 exec->PolygonStipple = _mesa_PolygonStipple; 231 exec->PopAttrib = _mesa_PopAttrib; 232 exec->PopMatrix = _mesa_PopMatrix; 233 exec->PopName = _mesa_PopName; 234 exec->PushAttrib = _mesa_PushAttrib; 235 exec->PushMatrix = _mesa_PushMatrix; 236 exec->PushName = _mesa_PushName; 237 exec->RasterPos2d = _mesa_RasterPos2d; 238 exec->RasterPos2dv = _mesa_RasterPos2dv; 239 exec->RasterPos2f = _mesa_RasterPos2f; 240 exec->RasterPos2fv = _mesa_RasterPos2fv; 241 exec->RasterPos2i = _mesa_RasterPos2i; 242 exec->RasterPos2iv = _mesa_RasterPos2iv; 243 exec->RasterPos2s = _mesa_RasterPos2s; 244 exec->RasterPos2sv = _mesa_RasterPos2sv; 245 exec->RasterPos3d = _mesa_RasterPos3d; 246 exec->RasterPos3dv = _mesa_RasterPos3dv; 247 exec->RasterPos3f = _mesa_RasterPos3f; 248 exec->RasterPos3fv = _mesa_RasterPos3fv; 249 exec->RasterPos3i = _mesa_RasterPos3i; 250 exec->RasterPos3iv = _mesa_RasterPos3iv; 251 exec->RasterPos3s = _mesa_RasterPos3s; 252 exec->RasterPos3sv = _mesa_RasterPos3sv; 253 exec->RasterPos4d = _mesa_RasterPos4d; 254 exec->RasterPos4dv = _mesa_RasterPos4dv; 255 exec->RasterPos4f = _mesa_RasterPos4f; 256 exec->RasterPos4fv = _mesa_RasterPos4fv; 257 exec->RasterPos4i = _mesa_RasterPos4i; 258 exec->RasterPos4iv = _mesa_RasterPos4iv; 259 exec->RasterPos4s = _mesa_RasterPos4s; 260 exec->RasterPos4sv = _mesa_RasterPos4sv; 261 exec->ReadBuffer = _mesa_ReadBuffer; 262 exec->ReadPixels = _mesa_ReadPixels; 263 exec->RenderMode = _mesa_RenderMode; 264 exec->Rotated = _mesa_Rotated; 265 exec->Rotatef = _mesa_Rotatef; 266 exec->Scaled = _mesa_Scaled; 267 exec->Scalef = _mesa_Scalef; 268 exec->Scissor = _mesa_Scissor; 269 exec->SecondaryColorPointerEXT = _mesa_SecondaryColorPointerEXT; 270 exec->SelectBuffer = _mesa_SelectBuffer; 271 exec->ShadeModel = _mesa_ShadeModel; 272 exec->StencilFunc = _mesa_StencilFunc; 273 exec->StencilMask = _mesa_StencilMask; 274 exec->StencilOp = _mesa_StencilOp; 275 exec->TexEnvf = _mesa_TexEnvf; 276 exec->TexEnvfv = _mesa_TexEnvfv; 277 exec->TexEnvi = _mesa_TexEnvi; 278 exec->TexEnviv = _mesa_TexEnviv; 279 exec->TexGend = _mesa_TexGend; 280 exec->TexGendv = _mesa_TexGendv; 281 exec->TexGenf = _mesa_TexGenf; 282 exec->TexGenfv = _mesa_TexGenfv; 283 exec->TexGeni = _mesa_TexGeni; 284 exec->TexGeniv = _mesa_TexGeniv; 285 exec->TexImage1D = _mesa_TexImage1D; 286 exec->TexImage2D = _mesa_TexImage2D; 287 exec->TexParameterf = _mesa_TexParameterf; 288 exec->TexParameterfv = _mesa_TexParameterfv; 289 exec->TexParameteri = _mesa_TexParameteri; 290 exec->TexParameteriv = _mesa_TexParameteriv; 291 exec->Translated = _mesa_Translated; 292 exec->Translatef = _mesa_Translatef; 293 exec->Viewport = _mesa_Viewport; 294 295 /* 1.1 */ 296 exec->AreTexturesResident = _mesa_AreTexturesResident; 297 exec->AreTexturesResidentEXT = _mesa_AreTexturesResident; 298 exec->BindTexture = _mesa_BindTexture; 299 exec->ColorPointer = _mesa_ColorPointer; 300 exec->CopyTexImage1D = _mesa_CopyTexImage1D; 301 exec->CopyTexImage2D = _mesa_CopyTexImage2D; 302 exec->CopyTexSubImage1D = _mesa_CopyTexSubImage1D; 303 exec->CopyTexSubImage2D = _mesa_CopyTexSubImage2D; 304 exec->DeleteTextures = _mesa_DeleteTextures; 305 exec->DisableClientState = _mesa_DisableClientState; 306 exec->EdgeFlagPointer = _mesa_EdgeFlagPointer; 307 exec->EnableClientState = _mesa_EnableClientState; 308 exec->GenTextures = _mesa_GenTextures; 309 exec->GenTexturesEXT = _mesa_GenTextures; 310 exec->GetPointerv = _mesa_GetPointerv; 311 exec->IndexPointer = _mesa_IndexPointer; 312 exec->InterleavedArrays = _mesa_InterleavedArrays; 313 exec->IsTexture = _mesa_IsTexture; 314 exec->IsTextureEXT = _mesa_IsTexture; 315 exec->NormalPointer = _mesa_NormalPointer; 316 exec->PopClientAttrib = _mesa_PopClientAttrib; 317 exec->PrioritizeTextures = _mesa_PrioritizeTextures; 318 exec->PushClientAttrib = _mesa_PushClientAttrib; 319 exec->TexCoordPointer = _mesa_TexCoordPointer; 320 exec->TexSubImage1D = _mesa_TexSubImage1D; 321 exec->TexSubImage2D = _mesa_TexSubImage2D; 322 exec->VertexPointer = _mesa_VertexPointer; 323 324 /* 1.2 */ 325 exec->CopyTexSubImage3D = _mesa_CopyTexSubImage3D; 326 exec->TexImage3D = _mesa_TexImage3D; 327 exec->TexSubImage3D = _mesa_TexSubImage3D; 328 329 /* OpenGL 1.2 GL_ARB_imaging */ 330 exec->BlendColor = _mesa_BlendColor; 331 exec->BlendEquation = _mesa_BlendEquation; 332 exec->ColorSubTable = _mesa_ColorSubTable; 333 exec->ColorTable = _mesa_ColorTable; 334 exec->ColorTableParameterfv = _mesa_ColorTableParameterfv; 335 exec->ColorTableParameteriv = _mesa_ColorTableParameteriv; 336 exec->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; 337 exec->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; 338 exec->ConvolutionParameterf = _mesa_ConvolutionParameterf; 339 exec->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; 340 exec->ConvolutionParameteri = _mesa_ConvolutionParameteri; 341 exec->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; 342 exec->CopyColorSubTable = _mesa_CopyColorSubTable; 343 exec->CopyColorTable = _mesa_CopyColorTable; 344 exec->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; 345 exec->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; 346 exec->GetColorTable = _mesa_GetColorTable; 347 exec->GetColorTableEXT = _mesa_GetColorTable; 348 exec->GetColorTableParameterfv = _mesa_GetColorTableParameterfv; 349 exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; 350 exec->GetColorTableParameteriv = _mesa_GetColorTableParameteriv; 351 exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; 352 exec->GetConvolutionFilter = _mesa_GetConvolutionFilter; 353 exec->GetConvolutionFilterEXT = _mesa_GetConvolutionFilter; 354 exec->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv; 355 exec->GetConvolutionParameterfvEXT = _mesa_GetConvolutionParameterfv; 356 exec->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv; 357 exec->GetConvolutionParameterivEXT = _mesa_GetConvolutionParameteriv; 358 exec->GetHistogram = _mesa_GetHistogram; 359 exec->GetHistogramEXT = _mesa_GetHistogram; 360 exec->GetHistogramParameterfv = _mesa_GetHistogramParameterfv; 361 exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv; 362 exec->GetHistogramParameteriv = _mesa_GetHistogramParameteriv; 363 exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv; 364 exec->GetMinmax = _mesa_GetMinmax; 365 exec->GetMinmaxEXT = _mesa_GetMinmax; 366 exec->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; 367 exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv; 368 exec->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; 369 exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv; 370 exec->GetSeparableFilter = _mesa_GetSeparableFilter; 371 exec->GetSeparableFilterEXT = _mesa_GetSeparableFilter; 372 exec->Histogram = _mesa_Histogram; 373 exec->Minmax = _mesa_Minmax; 374 exec->ResetHistogram = _mesa_ResetHistogram; 375 exec->ResetMinmax = _mesa_ResetMinmax; 376 exec->SeparableFilter2D = _mesa_SeparableFilter2D; 377 378 /* 2. GL_EXT_blend_color */ 379#if 0 380 exec->BlendColorEXT = _mesa_BlendColorEXT; 381#endif 382 383 /* 3. GL_EXT_polygon_offset */ 384 exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; 385 386 /* 6. GL_EXT_texture3d */ 387#if 0 388 exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; 389 exec->TexImage3DEXT = _mesa_TexImage3DEXT; 390 exec->TexSubImage3DEXT = _mesa_TexSubImage3D; 391#endif 392 393 /* 11. GL_EXT_histogram */ 394 exec->GetHistogramEXT = _mesa_GetHistogram; 395 exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv; 396 exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv; 397 exec->GetMinmaxEXT = _mesa_GetMinmax; 398 exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv; 399 exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv; 400 401 /* ?. GL_SGIX_pixel_texture */ 402 exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX; 403 404 /* 15. GL_SGIS_pixel_texture */ 405 exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS; 406 exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS; 407 exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS; 408 exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS; 409 exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; 410 exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; 411 412 /* 30. GL_EXT_vertex_array */ 413 exec->ColorPointerEXT = _mesa_ColorPointerEXT; 414 exec->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT; 415 exec->IndexPointerEXT = _mesa_IndexPointerEXT; 416 exec->NormalPointerEXT = _mesa_NormalPointerEXT; 417 exec->TexCoordPointerEXT = _mesa_TexCoordPointerEXT; 418 exec->VertexPointerEXT = _mesa_VertexPointerEXT; 419 420 /* 37. GL_EXT_blend_minmax */ 421#if 0 422 exec->BlendEquationEXT = _mesa_BlendEquationEXT; 423#endif 424 425 /* 54. GL_EXT_point_parameters */ 426 exec->PointParameterfEXT = _mesa_PointParameterfEXT; 427 exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; 428 429 /* 78. GL_EXT_paletted_texture */ 430#if 0 431 exec->ColorTableEXT = _mesa_ColorTableEXT; 432 exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; 433#endif 434 exec->GetColorTableEXT = _mesa_GetColorTable; 435 exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; 436 exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; 437 438 /* 97. GL_EXT_compiled_vertex_array */ 439 exec->LockArraysEXT = _mesa_LockArraysEXT; 440 exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; 441 442 /* 148. GL_EXT_multi_draw_arrays */ 443 exec->MultiDrawArraysEXT = _mesa_MultiDrawArraysEXT; 444 exec->MultiDrawElementsEXT = _mesa_MultiDrawElementsEXT; 445 446 /* 173. GL_INGR_blend_func_separate */ 447 exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; 448 449 /* 196. GL_MESA_resize_buffers */ 450 exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; 451 452 /* 197. GL_MESA_window_pos */ 453 exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; 454 exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; 455 exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; 456 exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA; 457 exec->WindowPos2iMESA = _mesa_WindowPos2iMESA; 458 exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA; 459 exec->WindowPos2sMESA = _mesa_WindowPos2sMESA; 460 exec->WindowPos2svMESA = _mesa_WindowPos2svMESA; 461 exec->WindowPos3dMESA = _mesa_WindowPos3dMESA; 462 exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA; 463 exec->WindowPos3fMESA = _mesa_WindowPos3fMESA; 464 exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA; 465 exec->WindowPos3iMESA = _mesa_WindowPos3iMESA; 466 exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA; 467 exec->WindowPos3sMESA = _mesa_WindowPos3sMESA; 468 exec->WindowPos3svMESA = _mesa_WindowPos3svMESA; 469 exec->WindowPos4dMESA = _mesa_WindowPos4dMESA; 470 exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA; 471 exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; 472 exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA; 473 exec->WindowPos4iMESA = _mesa_WindowPos4iMESA; 474 exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; 475 exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; 476 exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; 477 478 /* 233. GL_NV_vertex_program */ 479#if FEATURE_NV_vertex_program 480 exec->BindProgramNV = _mesa_BindProgramNV; 481 exec->DeleteProgramsNV = _mesa_DeleteProgramsNV; 482 exec->ExecuteProgramNV = _mesa_ExecuteProgramNV; 483 exec->GenProgramsNV = _mesa_GenProgramsNV; 484 exec->AreProgramsResidentNV = _mesa_AreProgramsResidentNV; 485 exec->RequestResidentProgramsNV = _mesa_RequestResidentProgramsNV; 486 exec->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV; 487 exec->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV; 488 exec->GetProgramivNV = _mesa_GetProgramivNV; 489 exec->GetProgramStringNV = _mesa_GetProgramStringNV; 490 exec->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV; 491 exec->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV; 492 exec->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV; 493 exec->GetVertexAttribivNV = _mesa_GetVertexAttribivNV; 494 exec->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV; 495 exec->IsProgramNV = _mesa_IsProgramNV; 496 exec->LoadProgramNV = _mesa_LoadProgramNV; 497 exec->ProgramParameter4dNV = _mesa_ProgramParameter4dNV; 498 exec->ProgramParameter4dvNV = _mesa_ProgramParameter4dvNV; 499 exec->ProgramParameter4fNV = _mesa_ProgramParameter4fNV; 500 exec->ProgramParameter4fvNV = _mesa_ProgramParameter4fvNV; 501 exec->ProgramParameters4dvNV = _mesa_ProgramParameters4dvNV; 502 exec->ProgramParameters4fvNV = _mesa_ProgramParameters4fvNV; 503 exec->TrackMatrixNV = _mesa_TrackMatrixNV; 504 exec->VertexAttribPointerNV = _mesa_VertexAttribPointerNV; 505#endif 506 507#if 0 && FEATURE_NV_fragment_program 508 exec->ProgramNamedParameter4fNV = _mesa_ProgramNamedParameter4fNV; 509 exec->ProgramNamedParameter4dNV = _mesa_ProgramNamedParameter4dNV; 510 exec->ProgramNamedParameter4fvNV = _mesa_ProgramNamedParameter4fvNV; 511 exec->ProgramNamedParameter4dvNV = _mesa_ProgramNamedParameter4dvNV; 512 exec->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV; 513 exec->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV; 514 exec->ProgramLocalParameter4dARB = _mesa_ProgramLocalParameter4dARB; 515 exec->ProgramLocalParameter4dvARB = _mesa_ProgramLocalParameter4dvARB; 516 exec->ProgramLocalParameter4fARB = _mesa_ProgramLocalParameter4fARB; 517 exec->ProgramLocalParameter4fvARB = _mesa_ProgramLocalParameter4fvARB; 518 exec->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB; 519 exec->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB; 520#endif 521 522 /* 262. GL_NV_point_sprite */ 523 exec->PointParameteriNV = _mesa_PointParameteriNV; 524 exec->PointParameterivNV = _mesa_PointParameterivNV; 525 526 /* 268. GL_EXT_stencil_two_side */ 527 exec->ActiveStencilFaceEXT = _mesa_ActiveStencilFaceEXT; 528 529 /* ARB 1. GL_ARB_multitexture */ 530 exec->ActiveTextureARB = _mesa_ActiveTextureARB; 531 exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; 532 533 /* ARB 3. GL_ARB_transpose_matrix */ 534 exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB; 535 exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB; 536 exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB; 537 exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB; 538 539 /* ARB 5. GL_ARB_multisample */ 540 exec->SampleCoverageARB = _mesa_SampleCoverageARB; 541 542 /* ARB 12. GL_ARB_texture_compression */ 543 exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB; 544 exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB; 545 exec->CompressedTexImage1DARB = _mesa_CompressedTexImage1DARB; 546 exec->CompressedTexSubImage3DARB = _mesa_CompressedTexSubImage3DARB; 547 exec->CompressedTexSubImage2DARB = _mesa_CompressedTexSubImage2DARB; 548 exec->CompressedTexSubImage1DARB = _mesa_CompressedTexSubImage1DARB; 549 exec->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB; 550 551 /* ARB 14. GL_ARB_point_parameters */ 552 /* reuse EXT_point_parameters functions */ 553} 554 555 556 557/**********************************************************************/ 558/***** State update logic *****/ 559/**********************************************************************/ 560 561 562/* 563 * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET 564 * in ctx->_TriangleCaps if needed. 565 */ 566static void 567update_polygon( GLcontext *ctx ) 568{ 569 ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); 570 571 if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) 572 ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; 573 574 /* Any Polygon offsets enabled? */ 575 if (ctx->Polygon.OffsetPoint || 576 ctx->Polygon.OffsetLine || 577 ctx->Polygon.OffsetFill) { 578 ctx->_TriangleCaps |= DD_TRI_OFFSET; 579 } 580} 581 582static void 583calculate_model_project_matrix( GLcontext *ctx ) 584{ 585 _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, 586 ctx->ProjectionMatrixStack.Top, 587 ctx->ModelviewMatrixStack.Top ); 588 589 _math_matrix_analyse( &ctx->_ModelProjectMatrix ); 590} 591 592static void 593update_modelview_scale( GLcontext *ctx ) 594{ 595 ctx->_ModelViewInvScale = 1.0F; 596 if (ctx->ModelviewMatrixStack.Top->flags & (MAT_FLAG_UNIFORM_SCALE | 597 MAT_FLAG_GENERAL_SCALE | 598 MAT_FLAG_GENERAL_3D | 599 MAT_FLAG_GENERAL) ) { 600 const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv; 601 GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; 602 if (f < 1e-12) f = 1.0; 603 if (ctx->_NeedEyeCoords) 604 ctx->_ModelViewInvScale = 1.0F / SQRTF(f); 605 else 606 ctx->_ModelViewInvScale = SQRTF(f); 607 } 608} 609 610 611/* Bring uptodate any state that relies on _NeedEyeCoords. 612 */ 613static void 614update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords ) 615{ 616 /* Check if the truth-value interpretations of the bitfields have 617 * changed: 618 */ 619 if ((oldneedeyecoords == 0) != (ctx->_NeedEyeCoords == 0)) { 620 /* Recalculate all state that depends on _NeedEyeCoords. 621 */ 622 update_modelview_scale(ctx); 623 _mesa_compute_light_positions( ctx ); 624 625 if (ctx->Driver.LightingSpaceChange) 626 ctx->Driver.LightingSpaceChange( ctx ); 627 } 628 else { 629 GLuint new_state = ctx->NewState; 630 631 /* Recalculate that same state only if it has been invalidated 632 * by other statechanges. 633 */ 634 if (new_state & _NEW_MODELVIEW) 635 update_modelview_scale(ctx); 636 637 if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW)) 638 _mesa_compute_light_positions( ctx ); 639 } 640} 641 642 643static void 644update_drawbuffer( GLcontext *ctx ) 645{ 646 ctx->DrawBuffer->_Xmin = 0; 647 ctx->DrawBuffer->_Ymin = 0; 648 ctx->DrawBuffer->_Xmax = ctx->DrawBuffer->Width; 649 ctx->DrawBuffer->_Ymax = ctx->DrawBuffer->Height; 650 if (ctx->Scissor.Enabled) { 651 if (ctx->Scissor.X > ctx->DrawBuffer->_Xmin) { 652 ctx->DrawBuffer->_Xmin = ctx->Scissor.X; 653 } 654 if (ctx->Scissor.Y > ctx->DrawBuffer->_Ymin) { 655 ctx->DrawBuffer->_Ymin = ctx->Scissor.Y; 656 } 657 if (ctx->Scissor.X + ctx->Scissor.Width < ctx->DrawBuffer->_Xmax) { 658 ctx->DrawBuffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; 659 } 660 if (ctx->Scissor.Y + ctx->Scissor.Height < ctx->DrawBuffer->_Ymax) { 661 ctx->DrawBuffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; 662 } 663 } 664} 665 666 667/* NOTE: This routine references Tranform attribute values to compute 668 * userclip positions in clip space, but is only called on 669 * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values 670 * up to date across changes to the Transform attributes. 671 */ 672static void 673update_projection( GLcontext *ctx ) 674{ 675 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); 676 677 /* Recompute clip plane positions in clipspace. This is also done 678 * in _mesa_ClipPlane(). 679 */ 680 if (ctx->Transform.ClipPlanesEnabled) { 681 GLuint p; 682 for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { 683 if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { 684 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], 685 ctx->Transform.EyeUserPlane[p], 686 ctx->ProjectionMatrixStack.Top->inv ); 687 } 688 } 689 } 690} 691 692 693/* 694 * Return a bitmask of IMAGE_*_BIT flags which to indicate which 695 * pixel transfer operations are enabled. 696 */ 697static void 698update_image_transfer_state(GLcontext *ctx) 699{ 700 GLuint mask = 0; 701 702 if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || 703 ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || 704 ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || 705 ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) 706 mask |= IMAGE_SCALE_BIAS_BIT; 707 708 if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) 709 mask |= IMAGE_SHIFT_OFFSET_BIT; 710 711 if (ctx->Pixel.MapColorFlag) 712 mask |= IMAGE_MAP_COLOR_BIT; 713 714 if (ctx->Pixel.ColorTableEnabled) 715 mask |= IMAGE_COLOR_TABLE_BIT; 716 717 if (ctx->Pixel.Convolution1DEnabled || 718 ctx->Pixel.Convolution2DEnabled || 719 ctx->Pixel.Separable2DEnabled) { 720 mask |= IMAGE_CONVOLUTION_BIT; 721 if (ctx->Pixel.PostConvolutionScale[0] != 1.0F || 722 ctx->Pixel.PostConvolutionScale[1] != 1.0F || 723 ctx->Pixel.PostConvolutionScale[2] != 1.0F || 724 ctx->Pixel.PostConvolutionScale[3] != 1.0F || 725 ctx->Pixel.PostConvolutionBias[0] != 0.0F || 726 ctx->Pixel.PostConvolutionBias[1] != 0.0F || 727 ctx->Pixel.PostConvolutionBias[2] != 0.0F || 728 ctx->Pixel.PostConvolutionBias[3] != 0.0F) { 729 mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS; 730 } 731 } 732 733 if (ctx->Pixel.PostConvolutionColorTableEnabled) 734 mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; 735 736 if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY || 737 ctx->Pixel.PostColorMatrixScale[0] != 1.0F || 738 ctx->Pixel.PostColorMatrixBias[0] != 0.0F || 739 ctx->Pixel.PostColorMatrixScale[1] != 1.0F || 740 ctx->Pixel.PostColorMatrixBias[1] != 0.0F || 741 ctx->Pixel.PostColorMatrixScale[2] != 1.0F || 742 ctx->Pixel.PostColorMatrixBias[2] != 0.0F || 743 ctx->Pixel.PostColorMatrixScale[3] != 1.0F || 744 ctx->Pixel.PostColorMatrixBias[3] != 0.0F) 745 mask |= IMAGE_COLOR_MATRIX_BIT; 746 747 if (ctx->Pixel.PostColorMatrixColorTableEnabled) 748 mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; 749 750 if (ctx->Pixel.HistogramEnabled) 751 mask |= IMAGE_HISTOGRAM_BIT; 752 753 if (ctx->Pixel.MinMaxEnabled) 754 mask |= IMAGE_MIN_MAX_BIT; 755 756 ctx->_ImageTransferState = mask; 757} 758 759 760 761 762/* Note: This routine refers to derived texture attribute values to 763 * compute the ENABLE_TEXMAT flags, but is only called on 764 * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT 765 * flags are updated by _mesa_update_textures(), below. 766 * 767 * If both TEXTURE and TEXTURE_MATRIX change at once, these values 768 * will be computed twice. 769 */ 770static void 771update_texture_matrices( GLcontext *ctx ) 772{ 773 GLuint i; 774 775 ctx->Texture._TexMatEnabled = 0; 776 777 for (i=0; i < ctx->Const.MaxTextureUnits; i++) { 778 if (ctx->TextureMatrixStack[i].Top->flags & MAT_DIRTY) { 779 _math_matrix_analyse( ctx->TextureMatrixStack[i].Top ); 780 781 if (ctx->Texture.Unit[i]._ReallyEnabled && 782 ctx->TextureMatrixStack[i].Top->type != MATRIX_IDENTITY) 783 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i); 784 785 if (ctx->Driver.TextureMatrix) 786 ctx->Driver.TextureMatrix( ctx, i, ctx->TextureMatrixStack[i].Top); 787 } 788 } 789} 790 791 792/* Note: This routine refers to derived texture matrix values to 793 * compute the ENABLE_TEXMAT flags, but is only called on 794 * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT 795 * flags are updated by _mesa_update_texture_matrices, above. 796 * 797 * If both TEXTURE and TEXTURE_MATRIX change at once, these values 798 * will be computed twice. 799 */ 800static void 801update_texture_state( GLcontext *ctx ) 802{ 803 GLuint unit; 804 805 ctx->Texture._EnabledUnits = 0; 806 ctx->Texture._GenFlags = 0; 807 ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN; 808 ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN; 809 ctx->Texture._TexMatEnabled = 0; 810 ctx->Texture._TexGenEnabled = 0; 811 812 /* Update texture unit state. 813 */ 814 for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { 815 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; 816 GLuint enableBits; 817 818 texUnit->_ReallyEnabled = 0; 819 texUnit->_GenFlags = 0; 820 821 /* Get the bitmask of texture enables */ 822 if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) { 823 enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit]; 824 } 825 else { 826 if (!texUnit->Enabled) 827 continue; 828 enableBits = texUnit->Enabled; 829 } 830 831 /* Look for the highest-priority texture target that's enabled and 832 * complete. That's the one we'll use for texturing. If we're using 833 * a fragment program we're guaranteed that bitcount(enabledBits) <= 1. 834 */ 835 if (enableBits & TEXTURE_CUBE_BIT) { 836 struct gl_texture_object *texObj = texUnit->CurrentCubeMap; 837 if (!texObj->Complete) { 838 _mesa_test_texobj_completeness(ctx, texObj); 839 } 840 if (texObj->Complete) { 841 texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT; 842 texUnit->_Current = texObj; 843 } 844 } 845 846 if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_3D_BIT)) { 847 struct gl_texture_object *texObj = texUnit->Current3D; 848 if (!texObj->Complete) { 849 _mesa_test_texobj_completeness(ctx, texObj); 850 } 851 if (texObj->Complete) { 852 texUnit->_ReallyEnabled = TEXTURE_3D_BIT; 853 texUnit->_Current = texObj; 854 } 855 } 856 857 if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_RECT_BIT)) { 858 struct gl_texture_object *texObj = texUnit->CurrentRect; 859 if (!texObj->Complete) { 860 _mesa_test_texobj_completeness(ctx, texObj); 861 } 862 if (texObj->Complete) { 863 texUnit->_ReallyEnabled = TEXTURE_RECT_BIT; 864 texUnit->_Current = texObj; 865 } 866 } 867 868 if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_2D_BIT)) { 869 struct gl_texture_object *texObj = texUnit->Current2D; 870 if (!texObj->Complete) { 871 _mesa_test_texobj_completeness(ctx, texObj); 872 } 873 if (texObj->Complete) { 874 texUnit->_ReallyEnabled = TEXTURE_2D_BIT; 875 texUnit->_Current = texObj; 876 } 877 } 878 879 if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_1D_BIT)) { 880 struct gl_texture_object *texObj = texUnit->Current1D; 881 if (!texObj->Complete) { 882 _mesa_test_texobj_completeness(ctx, texObj); 883 } 884 if (texObj->Complete) { 885 texUnit->_ReallyEnabled = TEXTURE_1D_BIT; 886 texUnit->_Current = texObj; 887 } 888 } 889 890 if (!texUnit->_ReallyEnabled) { 891 texUnit->_Current = NULL; 892 continue; 893 } 894 895 if (texUnit->_ReallyEnabled) 896 ctx->Texture._EnabledUnits |= (1 << unit); 897 898 if (texUnit->TexGenEnabled) { 899 if (texUnit->TexGenEnabled & S_BIT) { 900 texUnit->_GenFlags |= texUnit->_GenBitS; 901 } 902 if (texUnit->TexGenEnabled & T_BIT) { 903 texUnit->_GenFlags |= texUnit->_GenBitT; 904 } 905 if (texUnit->TexGenEnabled & Q_BIT) { 906 texUnit->_GenFlags |= texUnit->_GenBitQ; 907 } 908 if (texUnit->TexGenEnabled & R_BIT) { 909 texUnit->_GenFlags |= texUnit->_GenBitR; 910 } 911 912 ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); 913 ctx->Texture._GenFlags |= texUnit->_GenFlags; 914 } 915 916 if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) 917 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); 918 } 919 920 if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) { 921 ctx->_NeedNormals |= NEED_NORMALS_TEXGEN; 922 ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; 923 } 924 925 if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) { 926 ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN; 927 } 928} 929 930 931 932/* 933 * If ctx->NewState is non-zero then this function MUST be called before 934 * rendering any primitive. Basically, function pointers and miscellaneous 935 * flags are updated to reflect the current state of the state machine. 936 * 937 * The above constraint is now maintained largely by the two Exec 938 * dispatch tables, which trigger the appropriate flush on transition 939 * between State and Geometry modes. 940 * 941 * Special care is taken with the derived value _NeedEyeCoords. This 942 * is a bitflag which is updated with information from a number of 943 * attribute groups (MODELVIEW, LIGHT, TEXTURE). A lot of derived 944 * state references this value, and must be treated with care to 945 * ensure that updates are done correctly. All state dependent on 946 * _NeedEyeCoords is calculated from within _mesa_update_tnl_spaces(), 947 * and from nowhere else. 948 */ 949void _mesa_update_state( GLcontext *ctx ) 950{ 951 const GLuint new_state = ctx->NewState; 952 const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; 953 954 if (MESA_VERBOSE & VERBOSE_STATE) 955 _mesa_print_state("_mesa_update_state", new_state); 956 957 if (new_state & _NEW_MODELVIEW) 958 _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); 959 960 if (new_state & _NEW_PROJECTION) 961 update_projection( ctx ); 962 963 if (new_state & _NEW_TEXTURE_MATRIX) 964 update_texture_matrices( ctx ); 965 966 if (new_state & _NEW_COLOR_MATRIX) 967 _math_matrix_analyse( ctx->ColorMatrixStack.Top ); 968 969 /* References ColorMatrix.type (derived above). 970 */ 971 if (new_state & _IMAGE_NEW_TRANSFER_STATE) 972 update_image_transfer_state(ctx); 973 974 /* Contributes to NeedEyeCoords, NeedNormals. 975 */ 976 if (new_state & _NEW_TEXTURE) 977 update_texture_state( ctx ); 978 979 if (new_state & (_NEW_BUFFERS|_NEW_SCISSOR)) 980 update_drawbuffer( ctx ); 981 982 if (new_state & _NEW_POLYGON) 983 update_polygon( ctx ); 984 985 /* Contributes to NeedEyeCoords, NeedNormals. 986 */ 987 if (new_state & _NEW_LIGHT) 988 _mesa_update_lighting( ctx ); 989 990 /* We can light in object space if the modelview matrix preserves 991 * lengths and relative angles. 992 */ 993 if (new_state & (_NEW_MODELVIEW|_NEW_LIGHT)) { 994 ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT_MODELVIEW; 995 if (ctx->Light.Enabled && 996 !TEST_MAT_FLAGS( ctx->ModelviewMatrixStack.Top, MAT_FLAGS_LENGTH_PRESERVING)) 997 ctx->_NeedEyeCoords |= NEED_EYE_LIGHT_MODELVIEW; 998 } 999 1000 1001#if 0 1002 /* XXX this is a bit of a hack. We should be checking elsewhere if 1003 * vertex program mode is enabled. We set _NeedEyeCoords to zero to 1004 * ensure that the combined modelview/projection matrix is computed 1005 * in calculate_model_project_matrix(). 1006 */ 1007 if (ctx->VertexProgram.Enabled) 1008 ctx->_NeedEyeCoords = 0; 1009 /* KW: it's now always computed. 1010 */ 1011#endif 1012 1013 /* Keep ModelviewProject uptodate always to allow tnl 1014 * implementations that go model->clip even when eye is required. 1015 */ 1016 if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) 1017 calculate_model_project_matrix(ctx); 1018 1019 /* ctx->_NeedEyeCoords is now uptodate. 1020 * 1021 * If the truth value of this variable has changed, update for the 1022 * new lighting space and recompute the positions of lights and the 1023 * normal transform. 1024 * 1025 * If the lighting space hasn't changed, may still need to recompute 1026 * light positions & normal transforms for other reasons. 1027 */ 1028 if (new_state & (_NEW_MODELVIEW | 1029 _NEW_LIGHT | 1030 _MESA_NEW_NEED_EYE_COORDS)) 1031 update_tnl_spaces( ctx, oldneedeyecoords ); 1032 1033 /* 1034 * Here the driver sets up all the ctx->Driver function pointers 1035 * to it's specific, private functions, and performs any 1036 * internal state management necessary, including invalidating 1037 * state of active modules. 1038 * 1039 * Set ctx->NewState to zero to avoid recursion if 1040 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) 1041 */ 1042 ctx->NewState = 0; 1043 ctx->Driver.UpdateState(ctx, new_state); 1044 ctx->Array.NewState = 0; 1045 1046 /* At this point we can do some assertions to be sure the required 1047 * device driver function pointers are all initialized. 1048 */ 1049 ASSERT(ctx->Driver.GetString); 1050 ASSERT(ctx->Driver.UpdateState); 1051 ASSERT(ctx->Driver.Clear); 1052 ASSERT(ctx->Driver.GetBufferSize); 1053 if (ctx->Visual.accumRedBits > 0) { 1054 ASSERT(ctx->Driver.Accum); 1055 } 1056 ASSERT(ctx->Driver.DrawPixels); 1057 ASSERT(ctx->Driver.ReadPixels); 1058 ASSERT(ctx->Driver.CopyPixels); 1059 ASSERT(ctx->Driver.Bitmap); 1060 ASSERT(ctx->Driver.ResizeBuffers); 1061 ASSERT(ctx->Driver.TexImage1D); 1062 ASSERT(ctx->Driver.TexImage2D); 1063 ASSERT(ctx->Driver.TexImage3D); 1064 ASSERT(ctx->Driver.TexSubImage1D); 1065 ASSERT(ctx->Driver.TexSubImage2D); 1066 ASSERT(ctx->Driver.TexSubImage3D); 1067 ASSERT(ctx->Driver.CopyTexImage1D); 1068 ASSERT(ctx->Driver.CopyTexImage2D); 1069 ASSERT(ctx->Driver.CopyTexSubImage1D); 1070 ASSERT(ctx->Driver.CopyTexSubImage2D); 1071 ASSERT(ctx->Driver.CopyTexSubImage3D); 1072 if (ctx->Extensions.ARB_texture_compression) { 1073#if 0 /* HW drivers need these, but not SW rasterizers */ 1074 ASSERT(ctx->Driver.CompressedTexImage1D); 1075 ASSERT(ctx->Driver.CompressedTexImage2D); 1076 ASSERT(ctx->Driver.CompressedTexImage3D); 1077 ASSERT(ctx->Driver.CompressedTexSubImage1D); 1078 ASSERT(ctx->Driver.CompressedTexSubImage2D); 1079 ASSERT(ctx->Driver.CompressedTexSubImage3D); 1080#endif 1081 } 1082} 1083 1084/* Is this helpful? 1085 */ 1086void 1087_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag ) 1088{ 1089 if (flag) 1090 ctx->_NeedEyeCoords &= ~NEED_EYE_DRIVER; 1091 else 1092 ctx->_NeedEyeCoords |= NEED_EYE_DRIVER; 1093 1094 ctx->NewState |= _NEW_POINT; /* one of the bits from 1095 * _MESA_NEW_NEED_EYE_COORDS. 1096 */ 1097} 1098