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