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