Better driver notification on changes.
[mesa.git] / src / mesa / main / state.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file state.c
28 * State management.
29 *
30 * This file manages recalculation of derived values in the __GLcontextRec.
31 * Also, this is where we initialize the API dispatch table.
32 */
33
34 #include "glheader.h"
35 #include "accum.h"
36 #include "api_loopback.h"
37 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
38 #include "arbprogram.h"
39 #endif
40 #if FEATURE_ATI_fragment_shader
41 #include "atifragshader.h"
42 #endif
43 #include "attrib.h"
44 #include "blend.h"
45 #if FEATURE_ARB_vertex_buffer_object
46 #include "bufferobj.h"
47 #endif
48 #include "buffers.h"
49 #include "clip.h"
50 #include "colortab.h"
51 #include "context.h"
52 #include "convolve.h"
53 #include "depth.h"
54 #include "dlist.h"
55 #include "drawpix.h"
56 #include "enable.h"
57 #include "eval.h"
58 #include "get.h"
59 #include "feedback.h"
60 #include "fog.h"
61 #if FEATURE_EXT_framebuffer_object
62 #include "fbobject.h"
63 #endif
64 #include "framebuffer.h"
65 #include "hint.h"
66 #include "histogram.h"
67 #include "imports.h"
68 #include "light.h"
69 #include "lines.h"
70 #include "macros.h"
71 #include "matrix.h"
72 #if FEATURE_ARB_occlusion_query
73 #include "occlude.h"
74 #endif
75 #include "pixel.h"
76 #include "points.h"
77 #include "polygon.h"
78 #include "rastpos.h"
79 #include "state.h"
80 #include "stencil.h"
81 #include "teximage.h"
82 #include "texobj.h"
83 #include "texstate.h"
84 #include "mtypes.h"
85 #include "varray.h"
86 #if FEATURE_NV_vertex_program
87 #include "nvprogram.h"
88 #endif
89 #if FEATURE_NV_fragment_program
90 #include "nvfragprog.h"
91 #include "nvprogram.h"
92 #include "program.h"
93 #include "texenvprogram.h"
94 #endif
95 #if FEATURE_ARB_shader_objects
96 #include "shaderobjects.h"
97 #endif
98 #include "debug.h"
99
100
101
102 /**
103 * Initialize a dispatch table with pointers to Mesa's immediate-mode
104 * commands.
105 *
106 * Pointers to glBegin()/glEnd() object commands and a few others
107 * are provided via the GLvertexformat interface.
108 *
109 * \param exec dispatch table.
110 * \param tableSize dispatch table size.
111 */
112 void
113 _mesa_init_exec_table(struct _glapi_table *exec)
114 {
115 #if _HAVE_FULL_GL
116 _mesa_loopback_init_api_table( exec );
117 #endif
118
119 /* load the dispatch slots we understand */
120 exec->AlphaFunc = _mesa_AlphaFunc;
121 exec->BlendFunc = _mesa_BlendFunc;
122 exec->Clear = _mesa_Clear;
123 exec->ClearColor = _mesa_ClearColor;
124 exec->ClearStencil = _mesa_ClearStencil;
125 exec->ColorMask = _mesa_ColorMask;
126 exec->CullFace = _mesa_CullFace;
127 exec->Disable = _mesa_Disable;
128 exec->DrawBuffer = _mesa_DrawBuffer;
129 exec->Enable = _mesa_Enable;
130 exec->Finish = _mesa_Finish;
131 exec->Flush = _mesa_Flush;
132 exec->FrontFace = _mesa_FrontFace;
133 exec->Frustum = _mesa_Frustum;
134 exec->GetError = _mesa_GetError;
135 exec->GetFloatv = _mesa_GetFloatv;
136 exec->GetString = _mesa_GetString;
137 exec->InitNames = _mesa_InitNames;
138 exec->LineStipple = _mesa_LineStipple;
139 exec->LineWidth = _mesa_LineWidth;
140 exec->LoadIdentity = _mesa_LoadIdentity;
141 exec->LoadMatrixf = _mesa_LoadMatrixf;
142 exec->LoadName = _mesa_LoadName;
143 exec->LogicOp = _mesa_LogicOp;
144 exec->MatrixMode = _mesa_MatrixMode;
145 exec->MultMatrixf = _mesa_MultMatrixf;
146 exec->Ortho = _mesa_Ortho;
147 exec->PixelStorei = _mesa_PixelStorei;
148 exec->PopMatrix = _mesa_PopMatrix;
149 exec->PopName = _mesa_PopName;
150 exec->PushMatrix = _mesa_PushMatrix;
151 exec->PushName = _mesa_PushName;
152 exec->RasterPos2f = _mesa_RasterPos2f;
153 exec->RasterPos2fv = _mesa_RasterPos2fv;
154 exec->RasterPos2i = _mesa_RasterPos2i;
155 exec->RasterPos2iv = _mesa_RasterPos2iv;
156 exec->ReadBuffer = _mesa_ReadBuffer;
157 exec->RenderMode = _mesa_RenderMode;
158 exec->Rotatef = _mesa_Rotatef;
159 exec->Scalef = _mesa_Scalef;
160 exec->Scissor = _mesa_Scissor;
161 exec->SelectBuffer = _mesa_SelectBuffer;
162 exec->ShadeModel = _mesa_ShadeModel;
163 exec->StencilFunc = _mesa_StencilFunc;
164 exec->StencilMask = _mesa_StencilMask;
165 exec->StencilOp = _mesa_StencilOp;
166 exec->TexEnvfv = _mesa_TexEnvfv;
167 exec->TexEnvi = _mesa_TexEnvi;
168 exec->TexImage2D = _mesa_TexImage2D;
169 exec->TexParameteri = _mesa_TexParameteri;
170 exec->Translatef = _mesa_Translatef;
171 exec->Viewport = _mesa_Viewport;
172 #if _HAVE_FULL_GL
173 exec->Accum = _mesa_Accum;
174 exec->Bitmap = _mesa_Bitmap;
175 exec->CallList = _mesa_CallList;
176 exec->CallLists = _mesa_CallLists;
177 exec->ClearAccum = _mesa_ClearAccum;
178 exec->ClearDepth = _mesa_ClearDepth;
179 exec->ClearIndex = _mesa_ClearIndex;
180 exec->ClipPlane = _mesa_ClipPlane;
181 exec->ColorMaterial = _mesa_ColorMaterial;
182 exec->CopyPixels = _mesa_CopyPixels;
183 exec->CullParameterfvEXT = _mesa_CullParameterfvEXT;
184 exec->CullParameterdvEXT = _mesa_CullParameterdvEXT;
185 exec->DeleteLists = _mesa_DeleteLists;
186 exec->DepthFunc = _mesa_DepthFunc;
187 exec->DepthMask = _mesa_DepthMask;
188 exec->DepthRange = _mesa_DepthRange;
189 exec->DrawPixels = _mesa_DrawPixels;
190 exec->EndList = _mesa_EndList;
191 exec->FeedbackBuffer = _mesa_FeedbackBuffer;
192 exec->FogCoordPointerEXT = _mesa_FogCoordPointerEXT;
193 exec->Fogf = _mesa_Fogf;
194 exec->Fogfv = _mesa_Fogfv;
195 exec->Fogi = _mesa_Fogi;
196 exec->Fogiv = _mesa_Fogiv;
197 exec->GenLists = _mesa_GenLists;
198 exec->GetClipPlane = _mesa_GetClipPlane;
199 exec->GetBooleanv = _mesa_GetBooleanv;
200 exec->GetDoublev = _mesa_GetDoublev;
201 exec->GetIntegerv = _mesa_GetIntegerv;
202 exec->GetLightfv = _mesa_GetLightfv;
203 exec->GetLightiv = _mesa_GetLightiv;
204 exec->GetMapdv = _mesa_GetMapdv;
205 exec->GetMapfv = _mesa_GetMapfv;
206 exec->GetMapiv = _mesa_GetMapiv;
207 exec->GetMaterialfv = _mesa_GetMaterialfv;
208 exec->GetMaterialiv = _mesa_GetMaterialiv;
209 exec->GetPixelMapfv = _mesa_GetPixelMapfv;
210 exec->GetPixelMapuiv = _mesa_GetPixelMapuiv;
211 exec->GetPixelMapusv = _mesa_GetPixelMapusv;
212 exec->GetPolygonStipple = _mesa_GetPolygonStipple;
213 exec->GetTexEnvfv = _mesa_GetTexEnvfv;
214 exec->GetTexEnviv = _mesa_GetTexEnviv;
215 exec->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv;
216 exec->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv;
217 exec->GetTexParameterfv = _mesa_GetTexParameterfv;
218 exec->GetTexParameteriv = _mesa_GetTexParameteriv;
219 exec->GetTexGendv = _mesa_GetTexGendv;
220 exec->GetTexGenfv = _mesa_GetTexGenfv;
221 exec->GetTexGeniv = _mesa_GetTexGeniv;
222 exec->GetTexImage = _mesa_GetTexImage;
223 exec->Hint = _mesa_Hint;
224 exec->IndexMask = _mesa_IndexMask;
225 exec->IsEnabled = _mesa_IsEnabled;
226 exec->IsList = _mesa_IsList;
227 exec->LightModelf = _mesa_LightModelf;
228 exec->LightModelfv = _mesa_LightModelfv;
229 exec->LightModeli = _mesa_LightModeli;
230 exec->LightModeliv = _mesa_LightModeliv;
231 exec->Lightf = _mesa_Lightf;
232 exec->Lightfv = _mesa_Lightfv;
233 exec->Lighti = _mesa_Lighti;
234 exec->Lightiv = _mesa_Lightiv;
235 exec->ListBase = _mesa_ListBase;
236 exec->LoadMatrixd = _mesa_LoadMatrixd;
237 exec->Map1d = _mesa_Map1d;
238 exec->Map1f = _mesa_Map1f;
239 exec->Map2d = _mesa_Map2d;
240 exec->Map2f = _mesa_Map2f;
241 exec->MapGrid1d = _mesa_MapGrid1d;
242 exec->MapGrid1f = _mesa_MapGrid1f;
243 exec->MapGrid2d = _mesa_MapGrid2d;
244 exec->MapGrid2f = _mesa_MapGrid2f;
245 exec->MultMatrixd = _mesa_MultMatrixd;
246 exec->NewList = _mesa_NewList;
247 exec->PassThrough = _mesa_PassThrough;
248 exec->PixelMapfv = _mesa_PixelMapfv;
249 exec->PixelMapuiv = _mesa_PixelMapuiv;
250 exec->PixelMapusv = _mesa_PixelMapusv;
251 exec->PixelStoref = _mesa_PixelStoref;
252 exec->PixelTransferf = _mesa_PixelTransferf;
253 exec->PixelTransferi = _mesa_PixelTransferi;
254 exec->PixelZoom = _mesa_PixelZoom;
255 exec->PointSize = _mesa_PointSize;
256 exec->PolygonMode = _mesa_PolygonMode;
257 exec->PolygonOffset = _mesa_PolygonOffset;
258 exec->PolygonStipple = _mesa_PolygonStipple;
259 exec->PopAttrib = _mesa_PopAttrib;
260 exec->PushAttrib = _mesa_PushAttrib;
261 exec->RasterPos2d = _mesa_RasterPos2d;
262 exec->RasterPos2dv = _mesa_RasterPos2dv;
263 exec->RasterPos2s = _mesa_RasterPos2s;
264 exec->RasterPos2sv = _mesa_RasterPos2sv;
265 exec->RasterPos3d = _mesa_RasterPos3d;
266 exec->RasterPos3dv = _mesa_RasterPos3dv;
267 exec->RasterPos3f = _mesa_RasterPos3f;
268 exec->RasterPos3fv = _mesa_RasterPos3fv;
269 exec->RasterPos3i = _mesa_RasterPos3i;
270 exec->RasterPos3iv = _mesa_RasterPos3iv;
271 exec->RasterPos3s = _mesa_RasterPos3s;
272 exec->RasterPos3sv = _mesa_RasterPos3sv;
273 exec->RasterPos4d = _mesa_RasterPos4d;
274 exec->RasterPos4dv = _mesa_RasterPos4dv;
275 exec->RasterPos4f = _mesa_RasterPos4f;
276 exec->RasterPos4fv = _mesa_RasterPos4fv;
277 exec->RasterPos4i = _mesa_RasterPos4i;
278 exec->RasterPos4iv = _mesa_RasterPos4iv;
279 exec->RasterPos4s = _mesa_RasterPos4s;
280 exec->RasterPos4sv = _mesa_RasterPos4sv;
281 exec->ReadPixels = _mesa_ReadPixels;
282 exec->Rotated = _mesa_Rotated;
283 exec->Scaled = _mesa_Scaled;
284 exec->SecondaryColorPointerEXT = _mesa_SecondaryColorPointerEXT;
285 exec->TexEnvf = _mesa_TexEnvf;
286 exec->TexEnviv = _mesa_TexEnviv;
287 exec->TexGend = _mesa_TexGend;
288 exec->TexGendv = _mesa_TexGendv;
289 exec->TexGenf = _mesa_TexGenf;
290 exec->TexGenfv = _mesa_TexGenfv;
291 exec->TexGeni = _mesa_TexGeni;
292 exec->TexGeniv = _mesa_TexGeniv;
293 exec->TexImage1D = _mesa_TexImage1D;
294 exec->TexParameterf = _mesa_TexParameterf;
295 exec->TexParameterfv = _mesa_TexParameterfv;
296 exec->TexParameteriv = _mesa_TexParameteriv;
297 exec->Translated = _mesa_Translated;
298 #endif
299
300 /* 1.1 */
301 exec->BindTexture = _mesa_BindTexture;
302 exec->DeleteTextures = _mesa_DeleteTextures;
303 exec->GenTextures = _mesa_GenTextures;
304 #if _HAVE_FULL_GL
305 exec->AreTexturesResident = _mesa_AreTexturesResident;
306 exec->AreTexturesResidentEXT = _mesa_AreTexturesResident;
307 exec->ColorPointer = _mesa_ColorPointer;
308 exec->CopyTexImage1D = _mesa_CopyTexImage1D;
309 exec->CopyTexImage2D = _mesa_CopyTexImage2D;
310 exec->CopyTexSubImage1D = _mesa_CopyTexSubImage1D;
311 exec->CopyTexSubImage2D = _mesa_CopyTexSubImage2D;
312 exec->DisableClientState = _mesa_DisableClientState;
313 exec->EdgeFlagPointer = _mesa_EdgeFlagPointer;
314 exec->EnableClientState = _mesa_EnableClientState;
315 exec->GenTexturesEXT = _mesa_GenTextures;
316 exec->GetPointerv = _mesa_GetPointerv;
317 exec->IndexPointer = _mesa_IndexPointer;
318 exec->InterleavedArrays = _mesa_InterleavedArrays;
319 exec->IsTexture = _mesa_IsTexture;
320 exec->IsTextureEXT = _mesa_IsTexture;
321 exec->NormalPointer = _mesa_NormalPointer;
322 exec->PopClientAttrib = _mesa_PopClientAttrib;
323 exec->PrioritizeTextures = _mesa_PrioritizeTextures;
324 exec->PushClientAttrib = _mesa_PushClientAttrib;
325 exec->TexCoordPointer = _mesa_TexCoordPointer;
326 exec->TexSubImage1D = _mesa_TexSubImage1D;
327 exec->TexSubImage2D = _mesa_TexSubImage2D;
328 exec->VertexPointer = _mesa_VertexPointer;
329 #endif
330
331 /* 1.2 */
332 #if _HAVE_FULL_GL
333 exec->CopyTexSubImage3D = _mesa_CopyTexSubImage3D;
334 exec->TexImage3D = _mesa_TexImage3D;
335 exec->TexSubImage3D = _mesa_TexSubImage3D;
336 #endif
337
338 /* OpenGL 1.2 GL_ARB_imaging */
339 #if _HAVE_FULL_GL
340 exec->BlendColor = _mesa_BlendColor;
341 exec->BlendEquation = _mesa_BlendEquation;
342 exec->BlendEquationSeparateEXT = _mesa_BlendEquationSeparateEXT;
343 exec->ColorSubTable = _mesa_ColorSubTable;
344 exec->ColorTable = _mesa_ColorTable;
345 exec->ColorTableParameterfv = _mesa_ColorTableParameterfv;
346 exec->ColorTableParameteriv = _mesa_ColorTableParameteriv;
347 exec->ConvolutionFilter1D = _mesa_ConvolutionFilter1D;
348 exec->ConvolutionFilter2D = _mesa_ConvolutionFilter2D;
349 exec->ConvolutionParameterf = _mesa_ConvolutionParameterf;
350 exec->ConvolutionParameterfv = _mesa_ConvolutionParameterfv;
351 exec->ConvolutionParameteri = _mesa_ConvolutionParameteri;
352 exec->ConvolutionParameteriv = _mesa_ConvolutionParameteriv;
353 exec->CopyColorSubTable = _mesa_CopyColorSubTable;
354 exec->CopyColorTable = _mesa_CopyColorTable;
355 exec->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
356 exec->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
357 exec->GetColorTable = _mesa_GetColorTable;
358 exec->GetColorTableEXT = _mesa_GetColorTable;
359 exec->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
360 exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
361 exec->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
362 exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
363 exec->GetConvolutionFilter = _mesa_GetConvolutionFilter;
364 exec->GetConvolutionFilterEXT = _mesa_GetConvolutionFilter;
365 exec->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
366 exec->GetConvolutionParameterfvEXT = _mesa_GetConvolutionParameterfv;
367 exec->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
368 exec->GetConvolutionParameterivEXT = _mesa_GetConvolutionParameteriv;
369 exec->GetHistogram = _mesa_GetHistogram;
370 exec->GetHistogramEXT = _mesa_GetHistogram;
371 exec->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
372 exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv;
373 exec->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
374 exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv;
375 exec->GetMinmax = _mesa_GetMinmax;
376 exec->GetMinmaxEXT = _mesa_GetMinmax;
377 exec->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
378 exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv;
379 exec->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
380 exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv;
381 exec->GetSeparableFilter = _mesa_GetSeparableFilter;
382 exec->GetSeparableFilterEXT = _mesa_GetSeparableFilter;
383 exec->Histogram = _mesa_Histogram;
384 exec->Minmax = _mesa_Minmax;
385 exec->ResetHistogram = _mesa_ResetHistogram;
386 exec->ResetMinmax = _mesa_ResetMinmax;
387 exec->SeparableFilter2D = _mesa_SeparableFilter2D;
388 #endif
389
390 /* OpenGL 2.0 */
391 exec->StencilFuncSeparate = _mesa_StencilFuncSeparate;
392 exec->StencilMaskSeparate = _mesa_StencilMaskSeparate;
393 exec->StencilOpSeparate = _mesa_StencilOpSeparate;
394
395 /* 2. GL_EXT_blend_color */
396 #if 0
397 /* exec->BlendColorEXT = _mesa_BlendColorEXT; */
398 #endif
399
400 /* 3. GL_EXT_polygon_offset */
401 #if _HAVE_FULL_GL
402 exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT;
403 #endif
404
405 /* 6. GL_EXT_texture3d */
406 #if 0
407 /* exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; */
408 /* exec->TexImage3DEXT = _mesa_TexImage3DEXT; */
409 /* exec->TexSubImage3DEXT = _mesa_TexSubImage3D; */
410 #endif
411
412 /* 11. GL_EXT_histogram */
413 #if _HAVE_FULL_GL
414 exec->GetHistogramEXT = _mesa_GetHistogram;
415 exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv;
416 exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv;
417 exec->GetMinmaxEXT = _mesa_GetMinmax;
418 exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv;
419 exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv;
420 #endif
421
422 /* ?. GL_SGIX_pixel_texture */
423 #if _HAVE_FULL_GL
424 exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX;
425 #endif
426
427 /* 15. GL_SGIS_pixel_texture */
428 #if _HAVE_FULL_GL
429 exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS;
430 exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS;
431 exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS;
432 exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS;
433 exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS;
434 exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS;
435 #endif
436
437 /* 30. GL_EXT_vertex_array */
438 #if _HAVE_FULL_GL
439 exec->ColorPointerEXT = _mesa_ColorPointerEXT;
440 exec->EdgeFlagPointerEXT = _mesa_EdgeFlagPointerEXT;
441 exec->IndexPointerEXT = _mesa_IndexPointerEXT;
442 exec->NormalPointerEXT = _mesa_NormalPointerEXT;
443 exec->TexCoordPointerEXT = _mesa_TexCoordPointerEXT;
444 exec->VertexPointerEXT = _mesa_VertexPointerEXT;
445 #endif
446
447 /* 37. GL_EXT_blend_minmax */
448 #if 0
449 exec->BlendEquationEXT = _mesa_BlendEquationEXT;
450 #endif
451
452 /* 54. GL_EXT_point_parameters */
453 #if _HAVE_FULL_GL
454 exec->PointParameterfEXT = _mesa_PointParameterfEXT;
455 exec->PointParameterfvEXT = _mesa_PointParameterfvEXT;
456 #endif
457
458 /* 78. GL_EXT_paletted_texture */
459 #if 0
460 exec->ColorTableEXT = _mesa_ColorTableEXT;
461 exec->ColorSubTableEXT = _mesa_ColorSubTableEXT;
462 #endif
463 #if _HAVE_FULL_GL
464 exec->GetColorTableEXT = _mesa_GetColorTable;
465 exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
466 exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
467 #endif
468
469 /* 97. GL_EXT_compiled_vertex_array */
470 #if _HAVE_FULL_GL
471 exec->LockArraysEXT = _mesa_LockArraysEXT;
472 exec->UnlockArraysEXT = _mesa_UnlockArraysEXT;
473 #endif
474
475 /* 148. GL_EXT_multi_draw_arrays */
476 #if _HAVE_FULL_GL
477 exec->MultiDrawArraysEXT = _mesa_MultiDrawArraysEXT;
478 exec->MultiDrawElementsEXT = _mesa_MultiDrawElementsEXT;
479 #endif
480
481 /* 173. GL_INGR_blend_func_separate */
482 #if _HAVE_FULL_GL
483 exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT;
484 #endif
485
486 /* 196. GL_MESA_resize_buffers */
487 #if _HAVE_FULL_GL
488 exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
489 #endif
490
491 /* 197. GL_MESA_window_pos */
492 #if _HAVE_FULL_GL
493 exec->WindowPos2dMESA = _mesa_WindowPos2dMESA;
494 exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA;
495 exec->WindowPos2fMESA = _mesa_WindowPos2fMESA;
496 exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA;
497 exec->WindowPos2iMESA = _mesa_WindowPos2iMESA;
498 exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA;
499 exec->WindowPos2sMESA = _mesa_WindowPos2sMESA;
500 exec->WindowPos2svMESA = _mesa_WindowPos2svMESA;
501 exec->WindowPos3dMESA = _mesa_WindowPos3dMESA;
502 exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA;
503 exec->WindowPos3fMESA = _mesa_WindowPos3fMESA;
504 exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA;
505 exec->WindowPos3iMESA = _mesa_WindowPos3iMESA;
506 exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA;
507 exec->WindowPos3sMESA = _mesa_WindowPos3sMESA;
508 exec->WindowPos3svMESA = _mesa_WindowPos3svMESA;
509 exec->WindowPos4dMESA = _mesa_WindowPos4dMESA;
510 exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA;
511 exec->WindowPos4fMESA = _mesa_WindowPos4fMESA;
512 exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA;
513 exec->WindowPos4iMESA = _mesa_WindowPos4iMESA;
514 exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA;
515 exec->WindowPos4sMESA = _mesa_WindowPos4sMESA;
516 exec->WindowPos4svMESA = _mesa_WindowPos4svMESA;
517 #endif
518
519 /* 200. GL_IBM_multimode_draw_arrays */
520 #if _HAVE_FULL_GL
521 exec->MultiModeDrawArraysIBM = _mesa_MultiModeDrawArraysIBM;
522 exec->MultiModeDrawElementsIBM = _mesa_MultiModeDrawElementsIBM;
523 #endif
524
525 /* 233. GL_NV_vertex_program */
526 #if FEATURE_NV_vertex_program
527 exec->BindProgramNV = _mesa_BindProgram;
528 exec->DeleteProgramsNV = _mesa_DeletePrograms;
529 exec->ExecuteProgramNV = _mesa_ExecuteProgramNV;
530 exec->GenProgramsNV = _mesa_GenPrograms;
531 exec->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
532 exec->RequestResidentProgramsNV = _mesa_RequestResidentProgramsNV;
533 exec->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV;
534 exec->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV;
535 exec->GetProgramivNV = _mesa_GetProgramivNV;
536 exec->GetProgramStringNV = _mesa_GetProgramStringNV;
537 exec->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV;
538 exec->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
539 exec->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
540 exec->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
541 exec->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
542 exec->IsProgramNV = _mesa_IsProgram;
543 exec->LoadProgramNV = _mesa_LoadProgramNV;
544 exec->ProgramParameter4dNV = _mesa_ProgramParameter4dNV;
545 exec->ProgramParameter4dvNV = _mesa_ProgramParameter4dvNV;
546 exec->ProgramParameter4fNV = _mesa_ProgramParameter4fNV;
547 exec->ProgramParameter4fvNV = _mesa_ProgramParameter4fvNV;
548 exec->ProgramParameters4dvNV = _mesa_ProgramParameters4dvNV;
549 exec->ProgramParameters4fvNV = _mesa_ProgramParameters4fvNV;
550 exec->TrackMatrixNV = _mesa_TrackMatrixNV;
551 exec->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
552 /* glVertexAttrib*NV functions handled in api_loopback.c */
553 #endif
554
555 /* 282. GL_NV_fragment_program */
556 #if FEATURE_NV_fragment_program
557 exec->ProgramNamedParameter4fNV = _mesa_ProgramNamedParameter4fNV;
558 exec->ProgramNamedParameter4dNV = _mesa_ProgramNamedParameter4dNV;
559 exec->ProgramNamedParameter4fvNV = _mesa_ProgramNamedParameter4fvNV;
560 exec->ProgramNamedParameter4dvNV = _mesa_ProgramNamedParameter4dvNV;
561 exec->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV;
562 exec->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV;
563 exec->ProgramLocalParameter4dARB = _mesa_ProgramLocalParameter4dARB;
564 exec->ProgramLocalParameter4dvARB = _mesa_ProgramLocalParameter4dvARB;
565 exec->ProgramLocalParameter4fARB = _mesa_ProgramLocalParameter4fARB;
566 exec->ProgramLocalParameter4fvARB = _mesa_ProgramLocalParameter4fvARB;
567 exec->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
568 exec->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
569 #endif
570
571 /* 262. GL_NV_point_sprite */
572 #if _HAVE_FULL_GL
573 exec->PointParameteriNV = _mesa_PointParameteriNV;
574 exec->PointParameterivNV = _mesa_PointParameterivNV;
575 #endif
576
577 /* 268. GL_EXT_stencil_two_side */
578 #if _HAVE_FULL_GL
579 exec->ActiveStencilFaceEXT = _mesa_ActiveStencilFaceEXT;
580 #endif
581
582 /* ???. GL_EXT_depth_bounds_test */
583 exec->DepthBoundsEXT = _mesa_DepthBoundsEXT;
584
585 /* ARB 1. GL_ARB_multitexture */
586 #if _HAVE_FULL_GL
587 exec->ActiveTextureARB = _mesa_ActiveTextureARB;
588 exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB;
589 #endif
590
591 /* ARB 3. GL_ARB_transpose_matrix */
592 #if _HAVE_FULL_GL
593 exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB;
594 exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB;
595 exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB;
596 exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB;
597 #endif
598
599 /* ARB 5. GL_ARB_multisample */
600 #if _HAVE_FULL_GL
601 exec->SampleCoverageARB = _mesa_SampleCoverageARB;
602 #endif
603
604 /* ARB 12. GL_ARB_texture_compression */
605 #if _HAVE_FULL_GL
606 exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB;
607 exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB;
608 exec->CompressedTexImage1DARB = _mesa_CompressedTexImage1DARB;
609 exec->CompressedTexSubImage3DARB = _mesa_CompressedTexSubImage3DARB;
610 exec->CompressedTexSubImage2DARB = _mesa_CompressedTexSubImage2DARB;
611 exec->CompressedTexSubImage1DARB = _mesa_CompressedTexSubImage1DARB;
612 exec->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB;
613 #endif
614
615 /* ARB 14. GL_ARB_point_parameters */
616 /* reuse EXT_point_parameters functions */
617
618 /* ARB 26. GL_ARB_vertex_program */
619 /* ARB 27. GL_ARB_fragment_program */
620 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
621 /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */
622 /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */
623 /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */
624 /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */
625 /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */
626 /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */
627 /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */
628 /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */
629 /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */
630 /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */
631 /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */
632 /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */
633 /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */
634 /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */
635 /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */
636 /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */
637 /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */
638 /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */
639 /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */
640 /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */
641 /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */
642 /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */
643 /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */
644 /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */
645 /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */
646 /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */
647 /* glVertexAttrib4bvARB handled in api_loopback.c */
648 /* glVertexAttrib4ivARB handled in api_loopback.c */
649 /* glVertexAttrib4ubvARB handled in api_loopback.c */
650 /* glVertexAttrib4usvARB handled in api_loopback.c */
651 /* glVertexAttrib4uivARB handled in api_loopback.c */
652 /* glVertexAttrib4NbvARB handled in api_loopback.c */
653 /* glVertexAttrib4NsvARB handled in api_loopback.c */
654 /* glVertexAttrib4NivARB handled in api_loopback.c */
655 /* glVertexAttrib4NusvARB handled in api_loopback.c */
656 /* glVertexAttrib4NuivARB handled in api_loopback.c */
657 exec->VertexAttribPointerARB = _mesa_VertexAttribPointerARB;
658 exec->EnableVertexAttribArrayARB = _mesa_EnableVertexAttribArrayARB;
659 exec->DisableVertexAttribArrayARB = _mesa_DisableVertexAttribArrayARB;
660 exec->ProgramStringARB = _mesa_ProgramStringARB;
661 /* glBindProgramARB aliases glBindProgramNV */
662 /* glDeleteProgramsARB aliases glDeleteProgramsNV */
663 /* glGenProgramsARB aliases glGenProgramsNV */
664 /* glIsProgramARB aliases glIsProgramNV */
665 exec->GetVertexAttribdvARB = _mesa_GetVertexAttribdvARB;
666 exec->GetVertexAttribfvARB = _mesa_GetVertexAttribfvARB;
667 exec->GetVertexAttribivARB = _mesa_GetVertexAttribivARB;
668 /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */
669 exec->ProgramEnvParameter4dARB = _mesa_ProgramEnvParameter4dARB;
670 exec->ProgramEnvParameter4dvARB = _mesa_ProgramEnvParameter4dvARB;
671 exec->ProgramEnvParameter4fARB = _mesa_ProgramEnvParameter4fARB;
672 exec->ProgramEnvParameter4fvARB = _mesa_ProgramEnvParameter4fvARB;
673 exec->ProgramLocalParameter4dARB = _mesa_ProgramLocalParameter4dARB;
674 exec->ProgramLocalParameter4dvARB = _mesa_ProgramLocalParameter4dvARB;
675 exec->ProgramLocalParameter4fARB = _mesa_ProgramLocalParameter4fARB;
676 exec->ProgramLocalParameter4fvARB = _mesa_ProgramLocalParameter4fvARB;
677 exec->GetProgramEnvParameterdvARB = _mesa_GetProgramEnvParameterdvARB;
678 exec->GetProgramEnvParameterfvARB = _mesa_GetProgramEnvParameterfvARB;
679 exec->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
680 exec->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
681 exec->GetProgramivARB = _mesa_GetProgramivARB;
682 exec->GetProgramStringARB = _mesa_GetProgramStringARB;
683 #endif
684
685 /* ARB 28. GL_ARB_vertex_buffer_object */
686 #if FEATURE_ARB_vertex_buffer_object
687 exec->BindBufferARB = _mesa_BindBufferARB;
688 exec->BufferDataARB = _mesa_BufferDataARB;
689 exec->BufferSubDataARB = _mesa_BufferSubDataARB;
690 exec->DeleteBuffersARB = _mesa_DeleteBuffersARB;
691 exec->GenBuffersARB = _mesa_GenBuffersARB;
692 exec->GetBufferParameterivARB = _mesa_GetBufferParameterivARB;
693 exec->GetBufferPointervARB = _mesa_GetBufferPointervARB;
694 exec->GetBufferSubDataARB = _mesa_GetBufferSubDataARB;
695 exec->IsBufferARB = _mesa_IsBufferARB;
696 exec->MapBufferARB = _mesa_MapBufferARB;
697 exec->UnmapBufferARB = _mesa_UnmapBufferARB;
698 #endif
699
700 /* ARB 29. GL_ARB_occlusion_query */
701 #if FEATURE_ARB_occlusion_query
702 exec->GenQueriesARB = _mesa_GenQueriesARB;
703 exec->DeleteQueriesARB = _mesa_DeleteQueriesARB;
704 exec->IsQueryARB = _mesa_IsQueryARB;
705 exec->BeginQueryARB = _mesa_BeginQueryARB;
706 exec->EndQueryARB = _mesa_EndQueryARB;
707 exec->GetQueryivARB = _mesa_GetQueryivARB;
708 exec->GetQueryObjectivARB = _mesa_GetQueryObjectivARB;
709 exec->GetQueryObjectuivARB = _mesa_GetQueryObjectuivARB;
710 #endif
711
712 /* ARB 37. GL_ARB_draw_buffers */
713 exec->DrawBuffersARB = _mesa_DrawBuffersARB;
714
715 #if FEATURE_ARB_shader_objects
716 exec->DeleteObjectARB = _mesa_DeleteObjectARB;
717 exec->GetHandleARB = _mesa_GetHandleARB;
718 exec->DetachObjectARB = _mesa_DetachObjectARB;
719 exec->CreateShaderObjectARB = _mesa_CreateShaderObjectARB;
720 exec->ShaderSourceARB = _mesa_ShaderSourceARB;
721 exec->CompileShaderARB = _mesa_CompileShaderARB;
722 exec->CreateProgramObjectARB = _mesa_CreateProgramObjectARB;
723 exec->AttachObjectARB = _mesa_AttachObjectARB;
724 exec->LinkProgramARB = _mesa_LinkProgramARB;
725 exec->UseProgramObjectARB = _mesa_UseProgramObjectARB;
726 exec->ValidateProgramARB = _mesa_ValidateProgramARB;
727 exec->Uniform1fARB = _mesa_Uniform1fARB;
728 exec->Uniform2fARB = _mesa_Uniform2fARB;
729 exec->Uniform3fARB = _mesa_Uniform3fARB;
730 exec->Uniform4fARB = _mesa_Uniform4fARB;
731 exec->Uniform1iARB = _mesa_Uniform1iARB;
732 exec->Uniform2iARB = _mesa_Uniform2iARB;
733 exec->Uniform3iARB = _mesa_Uniform3iARB;
734 exec->Uniform4iARB = _mesa_Uniform4iARB;
735 exec->Uniform1fvARB = _mesa_Uniform1fvARB;
736 exec->Uniform2fvARB = _mesa_Uniform2fvARB;
737 exec->Uniform3fvARB = _mesa_Uniform3fvARB;
738 exec->Uniform4fvARB = _mesa_Uniform4fvARB;
739 exec->Uniform1ivARB = _mesa_Uniform1ivARB;
740 exec->Uniform2ivARB = _mesa_Uniform2ivARB;
741 exec->Uniform3ivARB = _mesa_Uniform3ivARB;
742 exec->Uniform4ivARB = _mesa_Uniform4ivARB;
743 exec->UniformMatrix2fvARB = _mesa_UniformMatrix2fvARB;
744 exec->UniformMatrix3fvARB = _mesa_UniformMatrix3fvARB;
745 exec->UniformMatrix4fvARB = _mesa_UniformMatrix4fvARB;
746 exec->GetObjectParameterfvARB = _mesa_GetObjectParameterfvARB;
747 exec->GetObjectParameterivARB = _mesa_GetObjectParameterivARB;
748 exec->GetInfoLogARB = _mesa_GetInfoLogARB;
749 exec->GetAttachedObjectsARB = _mesa_GetAttachedObjectsARB;
750 exec->GetUniformLocationARB = _mesa_GetUniformLocationARB;
751 exec->GetActiveUniformARB = _mesa_GetActiveUniformARB;
752 exec->GetUniformfvARB = _mesa_GetUniformfvARB;
753 exec->GetUniformivARB = _mesa_GetUniformivARB;
754 exec->GetShaderSourceARB = _mesa_GetShaderSourceARB;
755 #endif /* FEATURE_ARB_shader_objects */
756
757 #if FEATURE_ARB_vertex_shader
758 exec->BindAttribLocationARB = _mesa_BindAttribLocationARB;
759 exec->GetActiveAttribARB = _mesa_GetActiveAttribARB;
760 exec->GetAttribLocationARB = _mesa_GetAttribLocationARB;
761 #endif /* FEATURE_ARB_vertex_shader */
762
763 /* GL_ATI_fragment_shader */
764 #if FEATURE_ATI_fragment_shader
765 exec->GenFragmentShadersATI = _mesa_GenFragmentShadersATI;
766 exec->BindFragmentShaderATI = _mesa_BindFragmentShaderATI;
767 exec->DeleteFragmentShaderATI = _mesa_DeleteFragmentShaderATI;
768 exec->BeginFragmentShaderATI = _mesa_BeginFragmentShaderATI;
769 exec->EndFragmentShaderATI = _mesa_EndFragmentShaderATI;
770 exec->PassTexCoordATI = _mesa_PassTexCoordATI;
771 exec->SampleMapATI = _mesa_SampleMapATI;
772 exec->ColorFragmentOp1ATI = _mesa_ColorFragmentOp1ATI;
773 exec->ColorFragmentOp2ATI = _mesa_ColorFragmentOp2ATI;
774 exec->ColorFragmentOp3ATI = _mesa_ColorFragmentOp3ATI;
775 exec->AlphaFragmentOp1ATI = _mesa_AlphaFragmentOp1ATI;
776 exec->AlphaFragmentOp2ATI = _mesa_AlphaFragmentOp2ATI;
777 exec->AlphaFragmentOp3ATI = _mesa_AlphaFragmentOp3ATI;
778 exec->SetFragmentShaderConstantATI = _mesa_SetFragmentShaderConstantATI;
779 #endif
780
781 #if FEATURE_EXT_framebuffer_object
782 exec->IsRenderbufferEXT = _mesa_IsRenderbufferEXT;
783 exec->BindRenderbufferEXT = _mesa_BindRenderbufferEXT;
784 exec->DeleteRenderbuffersEXT = _mesa_DeleteRenderbuffersEXT;
785 exec->GenRenderbuffersEXT = _mesa_GenRenderbuffersEXT;
786 exec->RenderbufferStorageEXT = _mesa_RenderbufferStorageEXT;
787 exec->GetRenderbufferParameterivEXT = _mesa_GetRenderbufferParameterivEXT;
788 exec->IsFramebufferEXT = _mesa_IsFramebufferEXT;
789 exec->BindFramebufferEXT = _mesa_BindFramebufferEXT;
790 exec->DeleteFramebuffersEXT = _mesa_DeleteFramebuffersEXT;
791 exec->GenFramebuffersEXT = _mesa_GenFramebuffersEXT;
792 exec->CheckFramebufferStatusEXT = _mesa_CheckFramebufferStatusEXT;
793 exec->FramebufferTexture1DEXT = _mesa_FramebufferTexture1DEXT;
794 exec->FramebufferTexture2DEXT = _mesa_FramebufferTexture2DEXT;
795 exec->FramebufferTexture3DEXT = _mesa_FramebufferTexture3DEXT;
796 exec->FramebufferRenderbufferEXT = _mesa_FramebufferRenderbufferEXT;
797 exec->GetFramebufferAttachmentParameterivEXT = _mesa_GetFramebufferAttachmentParameterivEXT;
798 exec->GenerateMipmapEXT = _mesa_GenerateMipmapEXT;
799 #endif
800 }
801
802
803
804 /**********************************************************************/
805 /** \name State update logic */
806 /*@{*/
807
808
809 static void
810 update_separate_specular( GLcontext *ctx )
811 {
812 if (NEED_SECONDARY_COLOR(ctx))
813 ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
814 else
815 ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
816 }
817
818
819 /**
820 * Update state dependent on vertex arrays.
821 */
822 static void
823 update_arrays( GLcontext *ctx )
824 {
825 GLuint i, min;
826
827 /* find min of _MaxElement values for all enabled arrays */
828
829 /* 0 */
830 if (ctx->VertexProgram._Enabled
831 && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) {
832 min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
833 }
834 else if (ctx->Array.Vertex.Enabled) {
835 min = ctx->Array.Vertex._MaxElement;
836 }
837 else {
838 /* can't draw anything without vertex positions! */
839 min = 0;
840 }
841
842 /* 1 */
843 if (ctx->VertexProgram._Enabled
844 && ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
845 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement);
846 }
847 /* no conventional vertex weight array */
848
849 /* 2 */
850 if (ctx->VertexProgram._Enabled
851 && ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
852 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement);
853 }
854 else if (ctx->Array.Normal.Enabled) {
855 min = MIN2(min, ctx->Array.Normal._MaxElement);
856 }
857
858 /* 3 */
859 if (ctx->VertexProgram._Enabled
860 && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
861 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement);
862 }
863 else if (ctx->Array.Color.Enabled) {
864 min = MIN2(min, ctx->Array.Color._MaxElement);
865 }
866
867 /* 4 */
868 if (ctx->VertexProgram._Enabled
869 && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
870 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement);
871 }
872 else if (ctx->Array.SecondaryColor.Enabled) {
873 min = MIN2(min, ctx->Array.SecondaryColor._MaxElement);
874 }
875
876 /* 5 */
877 if (ctx->VertexProgram._Enabled
878 && ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
879 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]._MaxElement);
880 }
881 else if (ctx->Array.FogCoord.Enabled) {
882 min = MIN2(min, ctx->Array.FogCoord._MaxElement);
883 }
884
885 /* 6 */
886 if (ctx->VertexProgram._Enabled
887 && ctx->Array.VertexAttrib[VERT_ATTRIB_SIX].Enabled) {
888 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SIX]._MaxElement);
889 }
890
891 /* 7 */
892 if (ctx->VertexProgram._Enabled
893 && ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) {
894 min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement);
895 }
896
897 /* 8..15 */
898 for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) {
899 if (ctx->VertexProgram._Enabled
900 && ctx->Array.VertexAttrib[i].Enabled) {
901 min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement);
902 }
903 else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
904 && ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
905 min = MIN2(min, ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0]._MaxElement);
906 }
907 }
908
909 if (ctx->Array.Index.Enabled) {
910 min = MIN2(min, ctx->Array.Index._MaxElement);
911 }
912
913 if (ctx->Array.EdgeFlag.Enabled) {
914 min = MIN2(min, ctx->Array.EdgeFlag._MaxElement);
915 }
916
917 /* _MaxElement is one past the last legal array element */
918 ctx->Array._MaxElement = min;
919 }
920
921
922 /**
923 * Update derived vertex/fragment program state.
924 */
925 static void
926 update_program(GLcontext *ctx)
927 {
928 /* For now, just set the _Enabled (really enabled) flags.
929 * In the future we may have to check other state to be sure we really
930 * have a runable program or shader.
931 */
932 ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
933 && ctx->VertexProgram.Current->Instructions;
934 ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
935 && ctx->FragmentProgram.Current->Instructions;
936 ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
937 && ctx->ATIFragmentShader.Current->Instructions;
938
939 ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
940 ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
941
942 if (ctx->_MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) {
943 if (!ctx->_TexEnvProgram)
944 ctx->_TexEnvProgram = (struct fragment_program *)
945 ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
946
947 ctx->FragmentProgram._Current = ctx->_TexEnvProgram;
948 ctx->FragmentProgram._Active = GL_TRUE;
949 }
950 }
951
952
953 /**
954 * If __GLcontextRec::NewState is non-zero then this function \b must be called
955 * before rendering any primitive. Basically, function pointers and
956 * miscellaneous flags are updated to reflect the current state of the state
957 * machine.
958 *
959 * Calls dd_function_table::UpdateState to perform any internal state
960 * management necessary.
961 *
962 * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
963 * _mesa_update_buffer_bounds(), _mesa_update_polygon(),
964 * _mesa_update_lighting() and _mesa_update_tnl_spaces().
965 */
966 void
967 _mesa_update_state( GLcontext *ctx )
968 {
969 GLuint new_state = ctx->NewState;
970
971 if (MESA_VERBOSE & VERBOSE_STATE)
972 _mesa_print_state("_mesa_update_state", new_state);
973
974 if (new_state & _NEW_PROGRAM)
975 update_program( ctx );
976
977 if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
978 _mesa_update_modelview_project( ctx, new_state );
979
980 if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
981 _mesa_update_texture( ctx, new_state );
982
983 if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
984 _mesa_update_framebuffer(ctx);
985
986 if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS))
987 _mesa_update_draw_buffer_bounds( ctx );
988
989 if (new_state & _NEW_POLYGON)
990 _mesa_update_polygon( ctx );
991
992 if (new_state & _NEW_LIGHT)
993 _mesa_update_lighting( ctx );
994
995 if (new_state & _IMAGE_NEW_TRANSFER_STATE)
996 _mesa_update_pixel( ctx, new_state );
997
998 if (new_state & _DD_NEW_SEPARATE_SPECULAR)
999 update_separate_specular( ctx );
1000
1001 if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
1002 update_arrays( ctx );
1003
1004 if (ctx->_MaintainTexEnvProgram) {
1005 if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
1006 _mesa_UpdateTexEnvProgram(ctx);
1007 }
1008
1009 /* ctx->_NeedEyeCoords is now up to date.
1010 *
1011 * If the truth value of this variable has changed, update for the
1012 * new lighting space and recompute the positions of lights and the
1013 * normal transform.
1014 *
1015 * If the lighting space hasn't changed, may still need to recompute
1016 * light positions & normal transforms for other reasons.
1017 */
1018 if (new_state & _MESA_NEW_NEED_EYE_COORDS)
1019 _mesa_update_tnl_spaces( ctx, new_state );
1020
1021 /*
1022 * Give the driver a chance to act upon the new_state flags.
1023 * The driver might plug in different span functions, for example.
1024 * Also, this is where the driver can invalidate the state of any
1025 * active modules (such as swrast_setup, swrast, tnl, etc).
1026 *
1027 * Set ctx->NewState to zero to avoid recursion if
1028 * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
1029 */
1030 new_state = ctx->NewState;
1031 ctx->NewState = 0;
1032 ctx->Driver.UpdateState(ctx, new_state);
1033 ctx->Array.NewState = 0;
1034 }
1035
1036 /*@}*/