state.c revision 1b2ff69f468d609a88b1cd31041df2b81931816b
1/* $Id: state.c,v 1.5 2000/03/11 23:23:26 brianp Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 3.3 6 * 7 * Copyright (C) 1999-2000 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 initializes the immediate-mode dispatch table (which may 30 * be state-dependant) and manages internal Mesa state update. 31 */ 32 33 34#ifdef PC_HEADER 35#include "all.h" 36#else 37#include "glheader.h" 38#include "accum.h" 39#include "alpha.h" 40#include "attrib.h" 41#include "bitmap.h" 42#include "blend.h" 43#include "buffers.h" 44#include "clip.h" 45#include "colortab.h" 46#include "context.h" 47#include "copypix.h" 48#include "cva.h" 49#include "depth.h" 50#include "dlist.h" 51#include "drawpix.h" 52#include "enable.h" 53#include "eval.h" 54#include "get.h" 55#include "feedback.h" 56#include "fog.h" 57#include "hint.h" 58#include "imaging.h" 59#include "light.h" 60#include "lines.h" 61#include "logic.h" 62#include "masking.h" 63#include "matrix.h" 64#include "mmath.h" 65#include "pipeline.h" 66#include "pixel.h" 67#include "points.h" 68#include "polygon.h" 69#include "quads.h" 70#include "rastpos.h" 71#include "readpix.h" 72#include "rect.h" 73#include "scissor.h" 74#include "shade.h" 75#include "state.h" 76#include "stencil.h" 77#include "teximage.h" 78#include "texobj.h" 79#include "texstate.h" 80#include "texture.h" 81#include "triangle.h" 82#include "types.h" 83#include "varray.h" 84#include "vbfill.h" 85#include "vbrender.h" 86#include "winpos.h" 87#endif 88 89 90 91static int 92generic_noop(void) 93{ 94#ifdef DEBUG 95 gl_problem(NULL, "undefined function dispatch"); 96#endif 97 return 0; 98} 99 100 101void 102_mesa_init_no_op_table(struct _glapi_table *table) 103{ 104 /* Check to be sure the dispatcher's table is at least as big as Mesa's. */ 105 const GLuint size = sizeof(struct _glapi_table) / sizeof(void *); 106 assert(_glapi_get_dispatch_table_size() >= size); 107 108 { 109 const GLuint n = _glapi_get_dispatch_table_size(); 110 GLuint i; 111 void **dispatch = (void **) table; 112 for (i = 0; i < n; i++) { 113 dispatch[i] = (void *) generic_noop; 114 } 115 } 116} 117 118 119/* 120 * Initialize the given dispatch table with pointers to Mesa's 121 * immediate-mode commands. 122 */ 123void 124_mesa_init_exec_table(struct _glapi_table *exec) 125{ 126 /* first initialize all dispatch slots to no-op */ 127 _mesa_init_no_op_table(exec); 128 129 /* load the dispatch slots we understand */ 130 exec->Accum = _mesa_Accum; 131 exec->AlphaFunc = _mesa_AlphaFunc; 132 exec->Begin = _mesa_Begin; 133 exec->Bitmap = _mesa_Bitmap; 134 exec->BlendFunc = _mesa_BlendFunc; 135 exec->CallList = _mesa_CallList; 136 exec->CallLists = _mesa_CallLists; 137 exec->Clear = _mesa_Clear; 138 exec->ClearAccum = _mesa_ClearAccum; 139 exec->ClearColor = _mesa_ClearColor; 140 exec->ClearDepth = _mesa_ClearDepth; 141 exec->ClearIndex = _mesa_ClearIndex; 142 exec->ClearStencil = _mesa_ClearStencil; 143 exec->ClipPlane = _mesa_ClipPlane; 144 exec->Color3b = _mesa_Color3b; 145 exec->Color3bv = _mesa_Color3bv; 146 exec->Color3d = _mesa_Color3d; 147 exec->Color3dv = _mesa_Color3dv; 148 exec->Color3f = _mesa_Color3f; 149 exec->Color3fv = _mesa_Color3fv; 150 exec->Color3i = _mesa_Color3i; 151 exec->Color3iv = _mesa_Color3iv; 152 exec->Color3s = _mesa_Color3s; 153 exec->Color3sv = _mesa_Color3sv; 154 exec->Color3ub = _mesa_Color3ub; 155 exec->Color3ubv = _mesa_Color3ubv; 156 exec->Color3ui = _mesa_Color3ui; 157 exec->Color3uiv = _mesa_Color3uiv; 158 exec->Color3us = _mesa_Color3us; 159 exec->Color3usv = _mesa_Color3usv; 160 exec->Color4b = _mesa_Color4b; 161 exec->Color4bv = _mesa_Color4bv; 162 exec->Color4d = _mesa_Color4d; 163 exec->Color4dv = _mesa_Color4dv; 164 exec->Color4f = _mesa_Color4f; 165 exec->Color4fv = _mesa_Color4fv; 166 exec->Color4i = _mesa_Color4i; 167 exec->Color4iv = _mesa_Color4iv; 168 exec->Color4s = _mesa_Color4s; 169 exec->Color4sv = _mesa_Color4sv; 170 exec->Color4ub = _mesa_Color4ub; 171 exec->Color4ubv = _mesa_Color4ubv; 172 exec->Color4ui = _mesa_Color4ui; 173 exec->Color4uiv = _mesa_Color4uiv; 174 exec->Color4us = _mesa_Color4us; 175 exec->Color4usv = _mesa_Color4usv; 176 exec->ColorMask = _mesa_ColorMask; 177 exec->ColorMaterial = _mesa_ColorMaterial; 178 exec->CopyPixels = _mesa_CopyPixels; 179 exec->CullFace = _mesa_CullFace; 180 exec->DeleteLists = _mesa_DeleteLists; 181 exec->DepthFunc = _mesa_DepthFunc; 182 exec->DepthMask = _mesa_DepthMask; 183 exec->DepthRange = _mesa_DepthRange; 184 exec->Disable = _mesa_Disable; 185 exec->DrawBuffer = _mesa_DrawBuffer; 186 exec->DrawPixels = _mesa_DrawPixels; 187 exec->EdgeFlag = _mesa_EdgeFlag; 188 exec->EdgeFlagv = _mesa_EdgeFlagv; 189 exec->Enable = _mesa_Enable; 190 exec->End = _mesa_End; 191 exec->EndList = _mesa_EndList; 192 exec->EvalCoord1d = _mesa_EvalCoord1d; 193 exec->EvalCoord1dv = _mesa_EvalCoord1dv; 194 exec->EvalCoord1f = _mesa_EvalCoord1f; 195 exec->EvalCoord1fv = _mesa_EvalCoord1fv; 196 exec->EvalCoord2d = _mesa_EvalCoord2d; 197 exec->EvalCoord2dv = _mesa_EvalCoord2dv; 198 exec->EvalCoord2f = _mesa_EvalCoord2f; 199 exec->EvalCoord2fv = _mesa_EvalCoord2fv; 200 exec->EvalMesh1 = _mesa_EvalMesh1; 201 exec->EvalMesh2 = _mesa_EvalMesh2; 202 exec->EvalPoint1 = _mesa_EvalPoint1; 203 exec->EvalPoint2 = _mesa_EvalPoint2; 204 exec->FeedbackBuffer = _mesa_FeedbackBuffer; 205 exec->Finish = _mesa_Finish; 206 exec->Flush = _mesa_Flush; 207 exec->Fogf = _mesa_Fogf; 208 exec->Fogfv = _mesa_Fogfv; 209 exec->Fogi = _mesa_Fogi; 210 exec->Fogiv = _mesa_Fogiv; 211 exec->FrontFace = _mesa_FrontFace; 212 exec->Frustum = _mesa_Frustum; 213 exec->GenLists = _mesa_GenLists; 214 exec->GetBooleanv = _mesa_GetBooleanv; 215 exec->GetClipPlane = _mesa_GetClipPlane; 216 exec->GetDoublev = _mesa_GetDoublev; 217 exec->GetError = _mesa_GetError; 218 exec->GetFloatv = _mesa_GetFloatv; 219 exec->GetIntegerv = _mesa_GetIntegerv; 220 exec->GetLightfv = _mesa_GetLightfv; 221 exec->GetLightiv = _mesa_GetLightiv; 222 exec->GetMapdv = _mesa_GetMapdv; 223 exec->GetMapfv = _mesa_GetMapfv; 224 exec->GetMapiv = _mesa_GetMapiv; 225 exec->GetMaterialfv = _mesa_GetMaterialfv; 226 exec->GetMaterialiv = _mesa_GetMaterialiv; 227 exec->GetPixelMapfv = _mesa_GetPixelMapfv; 228 exec->GetPixelMapuiv = _mesa_GetPixelMapuiv; 229 exec->GetPixelMapusv = _mesa_GetPixelMapusv; 230 exec->GetPolygonStipple = _mesa_GetPolygonStipple; 231 exec->GetString = _mesa_GetString; 232 exec->GetTexEnvfv = _mesa_GetTexEnvfv; 233 exec->GetTexEnviv = _mesa_GetTexEnviv; 234 exec->GetTexGendv = _mesa_GetTexGendv; 235 exec->GetTexGenfv = _mesa_GetTexGenfv; 236 exec->GetTexGeniv = _mesa_GetTexGeniv; 237 exec->GetTexImage = _mesa_GetTexImage; 238 exec->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; 239 exec->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; 240 exec->GetTexParameterfv = _mesa_GetTexParameterfv; 241 exec->GetTexParameteriv = _mesa_GetTexParameteriv; 242 exec->Hint = _mesa_Hint; 243 exec->IndexMask = _mesa_IndexMask; 244 exec->Indexd = _mesa_Indexd; 245 exec->Indexdv = _mesa_Indexdv; 246 exec->Indexf = _mesa_Indexf; 247 exec->Indexfv = _mesa_Indexfv; 248 exec->Indexi = _mesa_Indexi; 249 exec->Indexiv = _mesa_Indexiv; 250 exec->Indexs = _mesa_Indexs; 251 exec->Indexsv = _mesa_Indexsv; 252 exec->InitNames = _mesa_InitNames; 253 exec->IsEnabled = _mesa_IsEnabled; 254 exec->IsList = _mesa_IsList; 255 exec->LightModelf = _mesa_LightModelf; 256 exec->LightModelfv = _mesa_LightModelfv; 257 exec->LightModeli = _mesa_LightModeli; 258 exec->LightModeliv = _mesa_LightModeliv; 259 exec->Lightf = _mesa_Lightf; 260 exec->Lightfv = _mesa_Lightfv; 261 exec->Lighti = _mesa_Lighti; 262 exec->Lightiv = _mesa_Lightiv; 263 exec->LineStipple = _mesa_LineStipple; 264 exec->LineWidth = _mesa_LineWidth; 265 exec->ListBase = _mesa_ListBase; 266 exec->LoadIdentity = _mesa_LoadIdentity; 267 exec->LoadMatrixd = _mesa_LoadMatrixd; 268 exec->LoadMatrixf = _mesa_LoadMatrixf; 269 exec->LoadName = _mesa_LoadName; 270 exec->LogicOp = _mesa_LogicOp; 271 exec->Map1d = _mesa_Map1d; 272 exec->Map1f = _mesa_Map1f; 273 exec->Map2d = _mesa_Map2d; 274 exec->Map2f = _mesa_Map2f; 275 exec->MapGrid1d = _mesa_MapGrid1d; 276 exec->MapGrid1f = _mesa_MapGrid1f; 277 exec->MapGrid2d = _mesa_MapGrid2d; 278 exec->MapGrid2f = _mesa_MapGrid2f; 279 exec->Materialf = _mesa_Materialf; 280 exec->Materialfv = _mesa_Materialfv; 281 exec->Materiali = _mesa_Materiali; 282 exec->Materialiv = _mesa_Materialiv; 283 exec->MatrixMode = _mesa_MatrixMode; 284 exec->MultMatrixd = _mesa_MultMatrixd; 285 exec->MultMatrixf = _mesa_MultMatrixf; 286 exec->NewList = _mesa_NewList; 287 exec->Normal3b = _mesa_Normal3b; 288 exec->Normal3bv = _mesa_Normal3bv; 289 exec->Normal3d = _mesa_Normal3d; 290 exec->Normal3dv = _mesa_Normal3dv; 291 exec->Normal3f = _mesa_Normal3f; 292 exec->Normal3fv = _mesa_Normal3fv; 293 exec->Normal3i = _mesa_Normal3i; 294 exec->Normal3iv = _mesa_Normal3iv; 295 exec->Normal3s = _mesa_Normal3s; 296 exec->Normal3sv = _mesa_Normal3sv; 297 exec->Ortho = _mesa_Ortho; 298 exec->PassThrough = _mesa_PassThrough; 299 exec->PixelMapfv = _mesa_PixelMapfv; 300 exec->PixelMapuiv = _mesa_PixelMapuiv; 301 exec->PixelMapusv = _mesa_PixelMapusv; 302 exec->PixelStoref = _mesa_PixelStoref; 303 exec->PixelStorei = _mesa_PixelStorei; 304 exec->PixelTransferf = _mesa_PixelTransferf; 305 exec->PixelTransferi = _mesa_PixelTransferi; 306 exec->PixelZoom = _mesa_PixelZoom; 307 exec->PointSize = _mesa_PointSize; 308 exec->PolygonMode = _mesa_PolygonMode; 309 exec->PolygonOffset = _mesa_PolygonOffset; 310 exec->PolygonStipple = _mesa_PolygonStipple; 311 exec->PopAttrib = _mesa_PopAttrib; 312 exec->PopMatrix = _mesa_PopMatrix; 313 exec->PopName = _mesa_PopName; 314 exec->PushAttrib = _mesa_PushAttrib; 315 exec->PushMatrix = _mesa_PushMatrix; 316 exec->PushName = _mesa_PushName; 317 exec->RasterPos2d = _mesa_RasterPos2d; 318 exec->RasterPos2dv = _mesa_RasterPos2dv; 319 exec->RasterPos2f = _mesa_RasterPos2f; 320 exec->RasterPos2fv = _mesa_RasterPos2fv; 321 exec->RasterPos2i = _mesa_RasterPos2i; 322 exec->RasterPos2iv = _mesa_RasterPos2iv; 323 exec->RasterPos2s = _mesa_RasterPos2s; 324 exec->RasterPos2sv = _mesa_RasterPos2sv; 325 exec->RasterPos3d = _mesa_RasterPos3d; 326 exec->RasterPos3dv = _mesa_RasterPos3dv; 327 exec->RasterPos3f = _mesa_RasterPos3f; 328 exec->RasterPos3fv = _mesa_RasterPos3fv; 329 exec->RasterPos3i = _mesa_RasterPos3i; 330 exec->RasterPos3iv = _mesa_RasterPos3iv; 331 exec->RasterPos3s = _mesa_RasterPos3s; 332 exec->RasterPos3sv = _mesa_RasterPos3sv; 333 exec->RasterPos4d = _mesa_RasterPos4d; 334 exec->RasterPos4dv = _mesa_RasterPos4dv; 335 exec->RasterPos4f = _mesa_RasterPos4f; 336 exec->RasterPos4fv = _mesa_RasterPos4fv; 337 exec->RasterPos4i = _mesa_RasterPos4i; 338 exec->RasterPos4iv = _mesa_RasterPos4iv; 339 exec->RasterPos4s = _mesa_RasterPos4s; 340 exec->RasterPos4sv = _mesa_RasterPos4sv; 341 exec->ReadBuffer = _mesa_ReadBuffer; 342 exec->ReadPixels = _mesa_ReadPixels; 343 exec->Rectd = _mesa_Rectd; 344 exec->Rectdv = _mesa_Rectdv; 345 exec->Rectf = _mesa_Rectf; 346 exec->Rectfv = _mesa_Rectfv; 347 exec->Recti = _mesa_Recti; 348 exec->Rectiv = _mesa_Rectiv; 349 exec->Rects = _mesa_Rects; 350 exec->Rectsv = _mesa_Rectsv; 351 exec->RenderMode = _mesa_RenderMode; 352 exec->Rotated = _mesa_Rotated; 353 exec->Rotatef = _mesa_Rotatef; 354 exec->Scaled = _mesa_Scaled; 355 exec->Scalef = _mesa_Scalef; 356 exec->Scissor = _mesa_Scissor; 357 exec->SelectBuffer = _mesa_SelectBuffer; 358 exec->ShadeModel = _mesa_ShadeModel; 359 exec->StencilFunc = _mesa_StencilFunc; 360 exec->StencilMask = _mesa_StencilMask; 361 exec->StencilOp = _mesa_StencilOp; 362 exec->TexCoord1d = _mesa_TexCoord1d; 363 exec->TexCoord1dv = _mesa_TexCoord1dv; 364 exec->TexCoord1f = _mesa_TexCoord1f; 365 exec->TexCoord1fv = _mesa_TexCoord1fv; 366 exec->TexCoord1i = _mesa_TexCoord1i; 367 exec->TexCoord1iv = _mesa_TexCoord1iv; 368 exec->TexCoord1s = _mesa_TexCoord1s; 369 exec->TexCoord1sv = _mesa_TexCoord1sv; 370 exec->TexCoord2d = _mesa_TexCoord2d; 371 exec->TexCoord2dv = _mesa_TexCoord2dv; 372 exec->TexCoord2f = _mesa_TexCoord2f; 373 exec->TexCoord2fv = _mesa_TexCoord2fv; 374 exec->TexCoord2i = _mesa_TexCoord2i; 375 exec->TexCoord2iv = _mesa_TexCoord2iv; 376 exec->TexCoord2s = _mesa_TexCoord2s; 377 exec->TexCoord2sv = _mesa_TexCoord2sv; 378 exec->TexCoord3d = _mesa_TexCoord3d; 379 exec->TexCoord3dv = _mesa_TexCoord3dv; 380 exec->TexCoord3f = _mesa_TexCoord3f; 381 exec->TexCoord3fv = _mesa_TexCoord3fv; 382 exec->TexCoord3i = _mesa_TexCoord3i; 383 exec->TexCoord3iv = _mesa_TexCoord3iv; 384 exec->TexCoord3s = _mesa_TexCoord3s; 385 exec->TexCoord3sv = _mesa_TexCoord3sv; 386 exec->TexCoord4d = _mesa_TexCoord4d; 387 exec->TexCoord4dv = _mesa_TexCoord4dv; 388 exec->TexCoord4f = _mesa_TexCoord4f; 389 exec->TexCoord4fv = _mesa_TexCoord4fv; 390 exec->TexCoord4i = _mesa_TexCoord4i; 391 exec->TexCoord4iv = _mesa_TexCoord4iv; 392 exec->TexCoord4s = _mesa_TexCoord4s; 393 exec->TexCoord4sv = _mesa_TexCoord4sv; 394 exec->TexEnvf = _mesa_TexEnvf; 395 exec->TexEnvfv = _mesa_TexEnvfv; 396 exec->TexEnvi = _mesa_TexEnvi; 397 exec->TexEnviv = _mesa_TexEnviv; 398 exec->TexGend = _mesa_TexGend; 399 exec->TexGendv = _mesa_TexGendv; 400 exec->TexGenf = _mesa_TexGenf; 401 exec->TexGenfv = _mesa_TexGenfv; 402 exec->TexGeni = _mesa_TexGeni; 403 exec->TexGeniv = _mesa_TexGeniv; 404 exec->TexImage1D = _mesa_TexImage1D; 405 exec->TexImage2D = _mesa_TexImage2D; 406 exec->TexParameterf = _mesa_TexParameterf; 407 exec->TexParameterfv = _mesa_TexParameterfv; 408 exec->TexParameteri = _mesa_TexParameteri; 409 exec->TexParameteriv = _mesa_TexParameteriv; 410 exec->Translated = _mesa_Translated; 411 exec->Translatef = _mesa_Translatef; 412 exec->Vertex2d = _mesa_Vertex2d; 413 exec->Vertex2dv = _mesa_Vertex2dv; 414 exec->Vertex2f = _mesa_Vertex2f; 415 exec->Vertex2fv = _mesa_Vertex2fv; 416 exec->Vertex2i = _mesa_Vertex2i; 417 exec->Vertex2iv = _mesa_Vertex2iv; 418 exec->Vertex2s = _mesa_Vertex2s; 419 exec->Vertex2sv = _mesa_Vertex2sv; 420 exec->Vertex3d = _mesa_Vertex3d; 421 exec->Vertex3dv = _mesa_Vertex3dv; 422 exec->Vertex3f = _mesa_Vertex3f; 423 exec->Vertex3fv = _mesa_Vertex3fv; 424 exec->Vertex3i = _mesa_Vertex3i; 425 exec->Vertex3iv = _mesa_Vertex3iv; 426 exec->Vertex3s = _mesa_Vertex3s; 427 exec->Vertex3sv = _mesa_Vertex3sv; 428 exec->Vertex4d = _mesa_Vertex4d; 429 exec->Vertex4dv = _mesa_Vertex4dv; 430 exec->Vertex4f = _mesa_Vertex4f; 431 exec->Vertex4fv = _mesa_Vertex4fv; 432 exec->Vertex4i = _mesa_Vertex4i; 433 exec->Vertex4iv = _mesa_Vertex4iv; 434 exec->Vertex4s = _mesa_Vertex4s; 435 exec->Vertex4sv = _mesa_Vertex4sv; 436 exec->Viewport = _mesa_Viewport; 437 438 /* 1.1 */ 439 exec->AreTexturesResident = _mesa_AreTexturesResident; 440 exec->ArrayElement = _mesa_ArrayElement; 441 exec->BindTexture = _mesa_BindTexture; 442 exec->ColorPointer = _mesa_ColorPointer; 443 exec->CopyTexImage1D = _mesa_CopyTexImage1D; 444 exec->CopyTexImage2D = _mesa_CopyTexImage2D; 445 exec->CopyTexSubImage1D = _mesa_CopyTexSubImage1D; 446 exec->CopyTexSubImage2D = _mesa_CopyTexSubImage2D; 447 exec->DeleteTextures = _mesa_DeleteTextures; 448 exec->DisableClientState = _mesa_DisableClientState; 449 exec->DrawArrays = _mesa_DrawArrays; 450 exec->DrawElements = _mesa_DrawElements; 451 exec->EdgeFlagPointer = _mesa_EdgeFlagPointer; 452 exec->EnableClientState = _mesa_EnableClientState; 453 exec->GenTextures = _mesa_GenTextures; 454 exec->GetPointerv = _mesa_GetPointerv; 455 exec->IndexPointer = _mesa_IndexPointer; 456 exec->Indexub = _mesa_Indexub; 457 exec->Indexubv = _mesa_Indexubv; 458 exec->InterleavedArrays = _mesa_InterleavedArrays; 459 exec->IsTexture = _mesa_IsTexture; 460 exec->NormalPointer = _mesa_NormalPointer; 461 exec->PopClientAttrib = _mesa_PopClientAttrib; 462 exec->PrioritizeTextures = _mesa_PrioritizeTextures; 463 exec->PushClientAttrib = _mesa_PushClientAttrib; 464 exec->TexCoordPointer = _mesa_TexCoordPointer; 465 exec->TexSubImage1D = _mesa_TexSubImage1D; 466 exec->TexSubImage2D = _mesa_TexSubImage2D; 467 exec->VertexPointer = _mesa_VertexPointer; 468 469 /* 1.2 */ 470 exec->CopyTexSubImage3D = _mesa_CopyTexSubImage3D; 471 exec->DrawRangeElements = _mesa_DrawRangeElements; 472 exec->TexImage3D = _mesa_TexImage3D; 473 exec->TexSubImage3D = _mesa_TexSubImage3D; 474 475 476 /* OpenGL 1.2 GL_ARB_imaging */ 477 exec->BlendColor = _mesa_BlendColor; 478 exec->BlendEquation = _mesa_BlendEquation; 479 exec->ColorSubTable = _mesa_ColorSubTable; 480 exec->ColorTable = _mesa_ColorTable; 481 exec->ColorTableParameterfv = _mesa_ColorTableParameterfv; 482 exec->ColorTableParameteriv = _mesa_ColorTableParameteriv; 483 exec->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; 484 exec->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; 485 exec->ConvolutionParameterf = _mesa_ConvolutionParameterf; 486 exec->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; 487 exec->ConvolutionParameteri = _mesa_ConvolutionParameteri; 488 exec->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; 489 exec->CopyColorSubTable = _mesa_CopyColorSubTable; 490 exec->CopyColorTable = _mesa_CopyColorTable; 491 exec->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; 492 exec->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; 493 exec->GetColorTable = _mesa_GetColorTable; 494 exec->GetColorTableParameterfv = _mesa_GetColorTableParameterfv; 495 exec->GetColorTableParameteriv = _mesa_GetColorTableParameteriv; 496 exec->GetConvolutionFilter = _mesa_GetConvolutionFilter; 497 exec->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv; 498 exec->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv; 499 exec->GetHistogram = _mesa_GetHistogram; 500 exec->GetHistogramParameterfv = _mesa_GetHistogramParameterfv; 501 exec->GetHistogramParameteriv = _mesa_GetHistogramParameteriv; 502 exec->GetMinmax = _mesa_GetMinmax; 503 exec->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; 504 exec->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; 505 exec->GetSeparableFilter = _mesa_GetSeparableFilter; 506 exec->Histogram = _mesa_Histogram; 507 exec->Minmax = _mesa_Minmax; 508 exec->ResetHistogram = _mesa_ResetHistogram; 509 exec->ResetMinmax = _mesa_ResetMinmax; 510 exec->SeparableFilter2D = _mesa_SeparableFilter2D; 511 512 /* GL_EXT_texture3d */ 513#if 0 514 exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; 515 exec->TexImage3DEXT = _mesa_TexImage3DEXT; 516 exec->TexSubImage3DEXT = _mesa_TexSubImage3D; 517#endif 518 519 /* GL_EXT_paletted_texture */ 520#if 0 521 exec->ColorTableEXT = _mesa_ColorTableEXT; 522 exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; 523#endif 524 exec->GetColorTableEXT = _mesa_GetColorTable; 525 exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; 526 exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; 527 528 /* GL_EXT_compiled_vertex_array */ 529 exec->LockArraysEXT = _mesa_LockArraysEXT; 530 exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; 531 532 /* GL_EXT_point_parameters */ 533 exec->PointParameterfEXT = _mesa_PointParameterfEXT; 534 exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; 535 536 /* GL_PGI_misc_hints */ 537 exec->HintPGI = _mesa_HintPGI; 538 539 /* GL_EXT_polygon_offset */ 540 exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; 541 542 /* GL_EXT_blend_minmax */ 543#if 0 544 exec->BlendEquationEXT = _mesa_BlendEquationEXT; 545#endif 546 547 /* GL_EXT_blend_color */ 548#if 0 549 exec->BlendColorEXT = _mesa_BlendColorEXT; 550#endif 551 552 /* GL_ARB_multitexture */ 553 exec->ActiveTextureARB = _mesa_ActiveTextureARB; 554 exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; 555 exec->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; 556 exec->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB; 557 exec->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB; 558 exec->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB; 559 exec->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB; 560 exec->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB; 561 exec->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB; 562 exec->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB; 563 exec->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB; 564 exec->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB; 565 exec->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB; 566 exec->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB; 567 exec->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB; 568 exec->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB; 569 exec->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB; 570 exec->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB; 571 exec->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB; 572 exec->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB; 573 exec->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB; 574 exec->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB; 575 exec->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB; 576 exec->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB; 577 exec->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB; 578 exec->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB; 579 exec->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB; 580 exec->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB; 581 exec->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB; 582 exec->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB; 583 exec->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB; 584 exec->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB; 585 exec->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; 586 exec->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; 587 588 /* GL_INGR_blend_func_separate */ 589 exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; 590 591 /* GL_MESA_window_pos */ 592 exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; 593 exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; 594 exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; 595 exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA; 596 exec->WindowPos2iMESA = _mesa_WindowPos2iMESA; 597 exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA; 598 exec->WindowPos2sMESA = _mesa_WindowPos2sMESA; 599 exec->WindowPos2svMESA = _mesa_WindowPos2svMESA; 600 exec->WindowPos3dMESA = _mesa_WindowPos3dMESA; 601 exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA; 602 exec->WindowPos3fMESA = _mesa_WindowPos3fMESA; 603 exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA; 604 exec->WindowPos3iMESA = _mesa_WindowPos3iMESA; 605 exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA; 606 exec->WindowPos3sMESA = _mesa_WindowPos3sMESA; 607 exec->WindowPos3svMESA = _mesa_WindowPos3svMESA; 608 exec->WindowPos4dMESA = _mesa_WindowPos4dMESA; 609 exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA; 610 exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; 611 exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA; 612 exec->WindowPos4iMESA = _mesa_WindowPos4iMESA; 613 exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; 614 exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; 615 exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; 616 617 /* GL_MESA_resize_buffers */ 618 exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; 619 620 /* GL_ARB_transpose_matrix */ 621 exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB; 622 exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB; 623 exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB; 624 exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB; 625} 626 627 628/**********************************************************************/ 629/***** State update logic *****/ 630/**********************************************************************/ 631 632 633/* 634 * Since the device driver may or may not support pixel logic ops we 635 * have to make some extensive tests to determine whether or not 636 * software-implemented logic operations have to be used. 637 */ 638static void update_pixel_logic( GLcontext *ctx ) 639{ 640 if (ctx->Visual->RGBAflag) { 641 /* RGBA mode blending w/ Logic Op */ 642 if (ctx->Color.ColorLogicOpEnabled) { 643 if (ctx->Driver.LogicOp 644 && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { 645 /* Device driver can do logic, don't have to do it in software */ 646 ctx->Color.SWLogicOpEnabled = GL_FALSE; 647 } 648 else { 649 /* Device driver can't do logic op so we do it in software */ 650 ctx->Color.SWLogicOpEnabled = GL_TRUE; 651 } 652 } 653 else { 654 /* no logic op */ 655 if (ctx->Driver.LogicOp) { 656 (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); 657 } 658 ctx->Color.SWLogicOpEnabled = GL_FALSE; 659 } 660 } 661 else { 662 /* CI mode Logic Op */ 663 if (ctx->Color.IndexLogicOpEnabled) { 664 if (ctx->Driver.LogicOp 665 && (*ctx->Driver.LogicOp)( ctx, ctx->Color.LogicOp )) { 666 /* Device driver can do logic, don't have to do it in software */ 667 ctx->Color.SWLogicOpEnabled = GL_FALSE; 668 } 669 else { 670 /* Device driver can't do logic op so we do it in software */ 671 ctx->Color.SWLogicOpEnabled = GL_TRUE; 672 } 673 } 674 else { 675 /* no logic op */ 676 if (ctx->Driver.LogicOp) { 677 (void) (*ctx->Driver.LogicOp)( ctx, GL_COPY ); 678 } 679 ctx->Color.SWLogicOpEnabled = GL_FALSE; 680 } 681 } 682} 683 684 685 686/* 687 * Check if software implemented RGBA or Color Index masking is needed. 688 */ 689static void update_pixel_masking( GLcontext *ctx ) 690{ 691 if (ctx->Visual->RGBAflag) { 692 GLuint *colorMask = (GLuint *) ctx->Color.ColorMask; 693 if (*colorMask == 0xffffffff) { 694 /* disable masking */ 695 if (ctx->Driver.ColorMask) { 696 (void) (*ctx->Driver.ColorMask)( ctx, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); 697 } 698 ctx->Color.SWmasking = GL_FALSE; 699 } 700 else { 701 /* Ask driver to do color masking, if it can't then 702 * do it in software 703 */ 704 GLboolean red = ctx->Color.ColorMask[RCOMP] ? GL_TRUE : GL_FALSE; 705 GLboolean green = ctx->Color.ColorMask[GCOMP] ? GL_TRUE : GL_FALSE; 706 GLboolean blue = ctx->Color.ColorMask[BCOMP] ? GL_TRUE : GL_FALSE; 707 GLboolean alpha = ctx->Color.ColorMask[ACOMP] ? GL_TRUE : GL_FALSE; 708 if (ctx->Driver.ColorMask 709 && (*ctx->Driver.ColorMask)( ctx, red, green, blue, alpha )) { 710 ctx->Color.SWmasking = GL_FALSE; 711 } 712 else { 713 ctx->Color.SWmasking = GL_TRUE; 714 } 715 } 716 } 717 else { 718 if (ctx->Color.IndexMask==0xffffffff) { 719 /* disable masking */ 720 if (ctx->Driver.IndexMask) { 721 (void) (*ctx->Driver.IndexMask)( ctx, 0xffffffff ); 722 } 723 ctx->Color.SWmasking = GL_FALSE; 724 } 725 else { 726 /* Ask driver to do index masking, if it can't then 727 * do it in software 728 */ 729 if (ctx->Driver.IndexMask 730 && (*ctx->Driver.IndexMask)( ctx, ctx->Color.IndexMask )) { 731 ctx->Color.SWmasking = GL_FALSE; 732 } 733 else { 734 ctx->Color.SWmasking = GL_TRUE; 735 } 736 } 737 } 738} 739 740 741static void update_fog_mode( GLcontext *ctx ) 742{ 743 int old_mode = ctx->FogMode; 744 745 if (ctx->Fog.Enabled) { 746 if (ctx->Texture.Enabled) 747 ctx->FogMode = FOG_FRAGMENT; 748 else if (ctx->Hint.Fog == GL_NICEST) 749 ctx->FogMode = FOG_FRAGMENT; 750 else 751 ctx->FogMode = FOG_VERTEX; 752 753 if (ctx->Driver.GetParameteri) 754 if ((ctx->Driver.GetParameteri)( ctx, DD_HAVE_HARDWARE_FOG )) 755 ctx->FogMode = FOG_FRAGMENT; 756 } 757 else { 758 ctx->FogMode = FOG_NONE; 759 } 760 761 if (old_mode != ctx->FogMode) 762 ctx->NewState |= NEW_FOG; 763} 764 765 766/* 767 * Recompute the value of ctx->RasterMask, etc. according to 768 * the current context. 769 */ 770static void update_rasterflags( GLcontext *ctx ) 771{ 772 ctx->RasterMask = 0; 773 774 if (ctx->Color.AlphaEnabled) ctx->RasterMask |= ALPHATEST_BIT; 775 if (ctx->Color.BlendEnabled) ctx->RasterMask |= BLEND_BIT; 776 if (ctx->Depth.Test) ctx->RasterMask |= DEPTH_BIT; 777 if (ctx->FogMode==FOG_FRAGMENT) ctx->RasterMask |= FOG_BIT; 778 if (ctx->Color.SWLogicOpEnabled) ctx->RasterMask |= LOGIC_OP_BIT; 779 if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT; 780 if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT; 781 if (ctx->Color.SWmasking) ctx->RasterMask |= MASKING_BIT; 782 783 if (ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[ACOMP] 784 && ctx->Color.DrawBuffer != GL_NONE) 785 ctx->RasterMask |= ALPHABUF_BIT; 786 787 if ( ctx->Viewport.X<0 788 || ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width 789 || ctx->Viewport.Y<0 790 || ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) { 791 ctx->RasterMask |= WINCLIP_BIT; 792 } 793 794 if (ctx->Depth.OcclusionTest) { 795 if (ctx->Color.ColorMask[0] == 0 && 796 ctx->Color.ColorMask[1] == 0 && 797 ctx->Color.ColorMask[2] == 0 && 798 ctx->Color.ColorMask[3] == 0 && 799 ctx->Depth.Mask == GL_FALSE && 800 !ctx->Stencil.Enabled) { 801 ctx->RasterMask |= OCCLUSION_BIT; 802 } 803 } 804 805 /* If we're not drawing to exactly one color buffer set the 806 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no 807 * buffers or the RGBA or CI mask disables all writes. 808 */ 809 ctx->TriangleCaps &= ~DD_MULTIDRAW; 810 811 if (ctx->Color.MultiDrawBuffer) { 812 ctx->RasterMask |= MULTI_DRAW_BIT; 813 ctx->TriangleCaps |= DD_MULTIDRAW; 814 } 815 else if (ctx->Color.DrawBuffer==GL_NONE) { 816 ctx->RasterMask |= MULTI_DRAW_BIT; 817 ctx->TriangleCaps |= DD_MULTIDRAW; 818 } 819 else if (ctx->Visual->RGBAflag && ctx->Color.ColorMask==0) { 820 /* all RGBA channels disabled */ 821 ctx->RasterMask |= MULTI_DRAW_BIT; 822 ctx->TriangleCaps |= DD_MULTIDRAW; 823 ctx->Color.DrawDestMask = 0; 824 } 825 else if (!ctx->Visual->RGBAflag && ctx->Color.IndexMask==0) { 826 /* all color index bits disabled */ 827 ctx->RasterMask |= MULTI_DRAW_BIT; 828 ctx->TriangleCaps |= DD_MULTIDRAW; 829 ctx->Color.DrawDestMask = 0; 830 } 831} 832 833 834void gl_print_state( const char *msg, GLuint state ) 835{ 836 fprintf(stderr, 837 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", 838 msg, 839 state, 840 (state & NEW_LIGHTING) ? "lighting, " : "", 841 (state & NEW_RASTER_OPS) ? "raster-ops, " : "", 842 (state & NEW_TEXTURING) ? "texturing, " : "", 843 (state & NEW_POLYGON) ? "polygon, " : "", 844 (state & NEW_DRVSTATE0) ? "driver-0, " : "", 845 (state & NEW_DRVSTATE1) ? "driver-1, " : "", 846 (state & NEW_DRVSTATE2) ? "driver-2, " : "", 847 (state & NEW_DRVSTATE3) ? "driver-3, " : "", 848 (state & NEW_MODELVIEW) ? "modelview, " : "", 849 (state & NEW_PROJECTION) ? "projection, " : "", 850 (state & NEW_TEXTURE_MATRIX) ? "texture-matrix, " : "", 851 (state & NEW_USER_CLIP) ? "user-clip, " : "", 852 (state & NEW_TEXTURE_ENV) ? "texture-env, " : "", 853 (state & NEW_CLIENT_STATE) ? "client-state, " : "", 854 (state & NEW_FOG) ? "fog, " : "", 855 (state & NEW_NORMAL_TRANSFORM) ? "normal-transform, " : "", 856 (state & NEW_VIEWPORT) ? "viewport, " : "", 857 (state & NEW_TEXTURE_ENABLE) ? "texture-enable, " : ""); 858} 859 860 861void gl_print_enable_flags( const char *msg, GLuint flags ) 862{ 863 fprintf(stderr, 864 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n", 865 msg, 866 flags, 867 (flags & ENABLE_TEX0) ? "tex-0, " : "", 868 (flags & ENABLE_TEX1) ? "tex-1, " : "", 869 (flags & ENABLE_LIGHT) ? "light, " : "", 870 (flags & ENABLE_FOG) ? "fog, " : "", 871 (flags & ENABLE_USERCLIP) ? "userclip, " : "", 872 (flags & ENABLE_TEXGEN0) ? "tex-gen-0, " : "", 873 (flags & ENABLE_TEXGEN1) ? "tex-gen-1, " : "", 874 (flags & ENABLE_TEXMAT0) ? "tex-mat-0, " : "", 875 (flags & ENABLE_TEXMAT1) ? "tex-mat-1, " : "", 876 (flags & ENABLE_NORMALIZE) ? "normalize, " : "", 877 (flags & ENABLE_RESCALE) ? "rescale, " : ""); 878} 879 880 881/* 882 * If ctx->NewState is non-zero then this function MUST be called before 883 * rendering any primitive. Basically, function pointers and miscellaneous 884 * flags are updated to reflect the current state of the state machine. 885 */ 886void gl_update_state( GLcontext *ctx ) 887{ 888 GLuint i; 889 890 if (MESA_VERBOSE & VERBOSE_STATE) 891 gl_print_state("", ctx->NewState); 892 893 if (ctx->NewState & NEW_CLIENT_STATE) 894 gl_update_client_state( ctx ); 895 896 if ((ctx->NewState & NEW_TEXTURE_ENABLE) && 897 (ctx->Enabled & ENABLE_TEX_ANY) != ctx->Texture.Enabled) 898 ctx->NewState |= NEW_TEXTURING | NEW_RASTER_OPS; 899 900 if (ctx->NewState & NEW_TEXTURE_ENV) { 901 if (ctx->Texture.Unit[0].EnvMode == ctx->Texture.Unit[0].LastEnvMode && 902 ctx->Texture.Unit[1].EnvMode == ctx->Texture.Unit[1].LastEnvMode) 903 ctx->NewState &= ~NEW_TEXTURE_ENV; 904 ctx->Texture.Unit[0].LastEnvMode = ctx->Texture.Unit[0].EnvMode; 905 ctx->Texture.Unit[1].LastEnvMode = ctx->Texture.Unit[1].EnvMode; 906 } 907 908 if (ctx->NewState & NEW_TEXTURE_MATRIX) { 909 ctx->Enabled &= ~(ENABLE_TEXMAT0|ENABLE_TEXMAT1); 910 911 for (i=0; i < MAX_TEXTURE_UNITS; i++) { 912 if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) 913 { 914 gl_matrix_analyze( &ctx->TextureMatrix[i] ); 915 ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS; 916 917 if (ctx->Texture.Unit[i].Enabled && 918 ctx->TextureMatrix[i].type != MATRIX_IDENTITY) 919 ctx->Enabled |= ENABLE_TEXMAT0 << i; 920 } 921 } 922 } 923 924 if (ctx->NewState & (NEW_TEXTURING | NEW_TEXTURE_ENABLE)) { 925 ctx->Texture.NeedNormals = GL_FALSE; 926 gl_update_dirty_texobjs(ctx); 927 ctx->Enabled &= ~(ENABLE_TEXGEN0|ENABLE_TEXGEN1); 928 ctx->Texture.ReallyEnabled = 0; 929 930 for (i=0; i < MAX_TEXTURE_UNITS; i++) { 931 if (ctx->Texture.Unit[i].Enabled) { 932 gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] ); 933 934 ctx->Texture.ReallyEnabled |= 935 ctx->Texture.Unit[i].ReallyEnabled<<(i*4); 936 937 if (ctx->Texture.Unit[i].GenFlags != 0) { 938 ctx->Enabled |= ENABLE_TEXGEN0 << i; 939 940 if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) 941 { 942 ctx->Texture.NeedNormals = GL_TRUE; 943 ctx->Texture.NeedEyeCoords = GL_TRUE; 944 } 945 946 if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) 947 { 948 ctx->Texture.NeedEyeCoords = GL_TRUE; 949 } 950 } 951 } 952 } 953 954 ctx->Texture.Enabled = ctx->Enabled & ENABLE_TEX_ANY; 955 ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); 956 } 957 958 if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING | NEW_FOG)) { 959 960 961 if (ctx->NewState & NEW_RASTER_OPS) { 962 update_pixel_logic(ctx); 963 update_pixel_masking(ctx); 964 update_fog_mode(ctx); 965 update_rasterflags(ctx); 966 if (ctx->Driver.Dither) { 967 (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag ); 968 } 969 970 /* Check if incoming colors can be modified during rasterization */ 971 if (ctx->Fog.Enabled || 972 ctx->Texture.Enabled || 973 ctx->Color.BlendEnabled || 974 ctx->Color.SWmasking || 975 ctx->Color.SWLogicOpEnabled) { 976 ctx->MutablePixels = GL_TRUE; 977 } 978 else { 979 ctx->MutablePixels = GL_FALSE; 980 } 981 982 /* update scissor region */ 983 984 ctx->DrawBuffer->Xmin = 0; 985 ctx->DrawBuffer->Ymin = 0; 986 ctx->DrawBuffer->Xmax = ctx->DrawBuffer->Width-1; 987 ctx->DrawBuffer->Ymax = ctx->DrawBuffer->Height-1; 988 if (ctx->Scissor.Enabled) { 989 if (ctx->Scissor.X > ctx->DrawBuffer->Xmin) { 990 ctx->DrawBuffer->Xmin = ctx->Scissor.X; 991 } 992 if (ctx->Scissor.Y > ctx->DrawBuffer->Ymin) { 993 ctx->DrawBuffer->Ymin = ctx->Scissor.Y; 994 } 995 if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->DrawBuffer->Xmax) { 996 ctx->DrawBuffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1; 997 } 998 if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->DrawBuffer->Ymax) { 999 ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1; 1000 } 1001 } 1002 } 1003 1004 if (ctx->NewState & NEW_LIGHTING) { 1005 ctx->TriangleCaps &= ~(DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); 1006 if (ctx->Light.Enabled) { 1007 if (ctx->Light.Model.TwoSide) 1008 ctx->TriangleCaps |= (DD_TRI_LIGHT_TWOSIDE|DD_LIGHTING_CULL); 1009 gl_update_lighting(ctx); 1010 } 1011 } 1012 } 1013 1014 if (ctx->NewState & (NEW_POLYGON | NEW_LIGHTING)) { 1015 1016 ctx->TriangleCaps &= ~DD_TRI_CULL_FRONT_BACK; 1017 1018 if (ctx->NewState & NEW_POLYGON) { 1019 /* Setup CullBits bitmask */ 1020 if (ctx->Polygon.CullFlag) { 1021 ctx->backface_sign = 1; 1022 switch(ctx->Polygon.CullFaceMode) { 1023 case GL_BACK: 1024 if(ctx->Polygon.FrontFace==GL_CCW) 1025 ctx->backface_sign = -1; 1026 ctx->Polygon.CullBits = 1; 1027 break; 1028 case GL_FRONT: 1029 if(ctx->Polygon.FrontFace!=GL_CCW) 1030 ctx->backface_sign = -1; 1031 ctx->Polygon.CullBits = 2; 1032 break; 1033 default: 1034 case GL_FRONT_AND_BACK: 1035 ctx->backface_sign = 0; 1036 ctx->Polygon.CullBits = 0; 1037 ctx->TriangleCaps |= DD_TRI_CULL_FRONT_BACK; 1038 break; 1039 } 1040 } 1041 else { 1042 ctx->Polygon.CullBits = 3; 1043 ctx->backface_sign = 0; 1044 } 1045 1046 /* Any Polygon offsets enabled? */ 1047 ctx->TriangleCaps &= ~DD_TRI_OFFSET; 1048 1049 if (ctx->Polygon.OffsetPoint || 1050 ctx->Polygon.OffsetLine || 1051 ctx->Polygon.OffsetFill) 1052 ctx->TriangleCaps |= DD_TRI_OFFSET; 1053 1054 /* reset Z offsets now */ 1055 ctx->PointZoffset = 0.0; 1056 ctx->LineZoffset = 0.0; 1057 ctx->PolygonZoffset = 0.0; 1058 } 1059 } 1060 1061 if (ctx->NewState & ~(NEW_CLIENT_STATE| 1062 NEW_DRIVER_STATE|NEW_USER_CLIP| 1063 NEW_POLYGON)) 1064 gl_update_clipmask(ctx); 1065 1066 if (ctx->NewState & (NEW_LIGHTING| 1067 NEW_RASTER_OPS| 1068 NEW_TEXTURING| 1069 NEW_TEXTURE_ENABLE| 1070 NEW_TEXTURE_ENV| 1071 NEW_POLYGON| 1072 NEW_DRVSTATE0| 1073 NEW_DRVSTATE1| 1074 NEW_DRVSTATE2| 1075 NEW_DRVSTATE3| 1076 NEW_USER_CLIP)) 1077 { 1078 ctx->IndirectTriangles = ctx->TriangleCaps & ~ctx->Driver.TriangleCaps; 1079 ctx->IndirectTriangles |= DD_SW_RASTERIZE; 1080 1081 if (MESA_VERBOSE&VERBOSE_CULL) 1082 gl_print_tri_caps("initial indirect tris", ctx->IndirectTriangles); 1083 1084 ctx->Driver.PointsFunc = NULL; 1085 ctx->Driver.LineFunc = NULL; 1086 ctx->Driver.TriangleFunc = NULL; 1087 ctx->Driver.QuadFunc = NULL; 1088 ctx->Driver.RectFunc = NULL; 1089 ctx->Driver.RenderVBClippedTab = NULL; 1090 ctx->Driver.RenderVBCulledTab = NULL; 1091 ctx->Driver.RenderVBRawTab = NULL; 1092 1093 /* 1094 * Here the driver sets up all the ctx->Driver function pointers to 1095 * it's specific, private functions. 1096 */ 1097 ctx->Driver.UpdateState(ctx); 1098 1099 if (MESA_VERBOSE&VERBOSE_CULL) 1100 gl_print_tri_caps("indirect tris", ctx->IndirectTriangles); 1101 1102 /* 1103 * In case the driver didn't hook in an optimized point, line or 1104 * triangle function we'll now select "core/fallback" point, line 1105 * and triangle functions. 1106 */ 1107 if (ctx->IndirectTriangles & DD_SW_RASTERIZE) { 1108 gl_set_point_function(ctx); 1109 gl_set_line_function(ctx); 1110 gl_set_triangle_function(ctx); 1111 gl_set_quad_function(ctx); 1112 1113 if ((ctx->IndirectTriangles & 1114 (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL)) == 1115 (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE|DD_TRI_CULL)) 1116 ctx->IndirectTriangles &= ~DD_TRI_CULL; 1117 } 1118 1119 if (MESA_VERBOSE&VERBOSE_CULL) 1120 gl_print_tri_caps("indirect tris 2", ctx->IndirectTriangles); 1121 1122 gl_set_render_vb_function(ctx); 1123 } 1124 1125 /* Should only be calc'd when !need_eye_coords and not culling. 1126 */ 1127 if (ctx->NewState & (NEW_MODELVIEW|NEW_PROJECTION)) { 1128 if (ctx->NewState & NEW_MODELVIEW) { 1129 gl_matrix_analyze( &ctx->ModelView ); 1130 ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS; 1131 } 1132 1133 if (ctx->NewState & NEW_PROJECTION) { 1134 gl_matrix_analyze( &ctx->ProjectionMatrix ); 1135 ctx->ProjectionMatrix.flags &= ~MAT_DIRTY_DEPENDENTS; 1136 1137 if (ctx->Transform.AnyClip) { 1138 gl_update_userclip( ctx ); 1139 } 1140 } 1141 1142 gl_calculate_model_project_matrix( ctx ); 1143 ctx->ModelProjectWinMatrixUptodate = 0; 1144 } 1145 1146 /* Figure out whether we can light in object space or not. If we 1147 * can, find the current positions of the lights in object space 1148 */ 1149 if ((ctx->Enabled & (ENABLE_POINT_ATTEN | ENABLE_LIGHT | ENABLE_FOG | 1150 ENABLE_TEXGEN0 | ENABLE_TEXGEN1)) && 1151 (ctx->NewState & (NEW_LIGHTING | 1152 NEW_FOG | 1153 NEW_MODELVIEW | 1154 NEW_PROJECTION | 1155 NEW_TEXTURING | 1156 NEW_RASTER_OPS | 1157 NEW_USER_CLIP))) 1158 { 1159 GLboolean oldcoord, oldnorm; 1160 1161 oldcoord = ctx->NeedEyeCoords; 1162 oldnorm = ctx->NeedEyeNormals; 1163 1164 ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); 1165 ctx->NeedEyeCoords = ((ctx->Fog.Enabled && ctx->Hint.Fog != GL_NICEST) || 1166 ctx->Point.Attenuated); 1167 ctx->NeedEyeNormals = GL_FALSE; 1168 1169 if (ctx->Light.Enabled) { 1170 if (ctx->Light.Flags & LIGHT_POSITIONAL) { 1171 /* Need length for attenuation */ 1172 if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_LENGTH_PRESERVING)) 1173 ctx->NeedEyeCoords = GL_TRUE; 1174 } else if (ctx->Light.NeedVertices) { 1175 /* Need angle for spot calculations */ 1176 if (!TEST_MAT_FLAGS( &ctx->ModelView, MAT_FLAGS_ANGLE_PRESERVING)) 1177 ctx->NeedEyeCoords = GL_TRUE; 1178 } 1179 ctx->NeedEyeNormals = ctx->NeedEyeCoords; 1180 } 1181 if (ctx->Texture.Enabled || ctx->RenderMode==GL_FEEDBACK) { 1182 if (ctx->Texture.NeedEyeCoords) ctx->NeedEyeCoords = GL_TRUE; 1183 if (ctx->Texture.NeedNormals) 1184 ctx->NeedNormals = ctx->NeedEyeNormals = GL_TRUE; 1185 } 1186 1187 ctx->vb_proj_matrix = &ctx->ModelProjectMatrix; 1188 1189 if (ctx->NeedEyeCoords) 1190 ctx->vb_proj_matrix = &ctx->ProjectionMatrix; 1191 1192 if (ctx->Light.Enabled) { 1193 gl_update_lighting_function(ctx); 1194 1195 if ( (ctx->NewState & NEW_LIGHTING) || 1196 ((ctx->NewState & (NEW_MODELVIEW| NEW_PROJECTION)) && 1197 !ctx->NeedEyeCoords) || 1198 oldcoord != ctx->NeedEyeCoords || 1199 oldnorm != ctx->NeedEyeNormals) { 1200 gl_compute_light_positions(ctx); 1201 } 1202 1203 ctx->rescale_factor = 1.0F; 1204 1205 if (ctx->ModelView.flags & (MAT_FLAG_UNIFORM_SCALE | 1206 MAT_FLAG_GENERAL_SCALE | 1207 MAT_FLAG_GENERAL_3D | 1208 MAT_FLAG_GENERAL) ) 1209 1210 { 1211 GLfloat *m = ctx->ModelView.inv; 1212 GLfloat f = m[2]*m[2] + m[6]*m[6] + m[10]*m[10]; 1213 if (f > 1e-12 && (f-1)*(f-1) > 1e-12) 1214 ctx->rescale_factor = 1.0/GL_SQRT(f); 1215 } 1216 } 1217 1218 gl_update_normal_transform( ctx ); 1219 } 1220 1221 gl_update_pipelines(ctx); 1222 ctx->NewState = 0; 1223} 1224