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