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