state.c revision 86a4810b09097714942bf2b889e6c62357bba931
1/*
2 * Mesa 3-D graphics library
3 * Version:  6.5.1
4 *
5 * Copyright (C) 1999-2006  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 "shader/arbprogram.h"
39#endif
40#if FEATURE_ATI_fragment_shader
41#include "shader/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 "arrayobj.h"
49#include "buffers.h"
50#include "clip.h"
51#include "colortab.h"
52#include "context.h"
53#include "convolve.h"
54#include "depth.h"
55#include "dlist.h"
56#include "drawpix.h"
57#include "enable.h"
58#include "eval.h"
59#include "get.h"
60#include "feedback.h"
61#include "fog.h"
62#if FEATURE_EXT_framebuffer_object
63#include "fbobject.h"
64#endif
65#include "framebuffer.h"
66#include "hint.h"
67#include "histogram.h"
68#include "imports.h"
69#include "light.h"
70#include "lines.h"
71#include "macros.h"
72#include "matrix.h"
73#include "pixel.h"
74#include "points.h"
75#include "polygon.h"
76#if FEATURE_ARB_occlusion_query || FEATURE_EXT_timer_query
77#include "queryobj.h"
78#endif
79#include "rastpos.h"
80#include "state.h"
81#include "stencil.h"
82#include "teximage.h"
83#include "texobj.h"
84#include "texstate.h"
85#include "mtypes.h"
86#include "varray.h"
87#if FEATURE_NV_vertex_program
88#include "shader/nvprogram.h"
89#endif
90#if FEATURE_NV_fragment_program
91#include "shader/nvprogram.h"
92#include "shader/program.h"
93#include "texenvprogram.h"
94#endif
95#if FEATURE_ARB_shader_objects
96#include "shaders.h"
97#endif
98#include "debug.h"
99#include "glapi/dispatch.h"
100
101
102
103/**
104 * Initialize a dispatch table with pointers to Mesa's immediate-mode
105 * commands.
106 *
107 * Pointers to glBegin()/glEnd() object commands and a few others
108 * are provided via the GLvertexformat interface.
109 *
110 * \param ctx  GL context to which \c exec belongs.
111 * \param exec dispatch table.
112 */
113void
114_mesa_init_exec_table(struct _glapi_table *exec)
115{
116#if _HAVE_FULL_GL
117   _mesa_loopback_init_api_table( exec );
118#endif
119
120   /* load the dispatch slots we understand */
121   SET_AlphaFunc(exec, _mesa_AlphaFunc);
122   SET_BlendFunc(exec, _mesa_BlendFunc);
123   SET_Clear(exec, _mesa_Clear);
124   SET_ClearColor(exec, _mesa_ClearColor);
125   SET_ClearStencil(exec, _mesa_ClearStencil);
126   SET_ColorMask(exec, _mesa_ColorMask);
127   SET_CullFace(exec, _mesa_CullFace);
128   SET_Disable(exec, _mesa_Disable);
129   SET_DrawBuffer(exec, _mesa_DrawBuffer);
130   SET_Enable(exec, _mesa_Enable);
131   SET_Finish(exec, _mesa_Finish);
132   SET_Flush(exec, _mesa_Flush);
133   SET_FrontFace(exec, _mesa_FrontFace);
134   SET_Frustum(exec, _mesa_Frustum);
135   SET_GetError(exec, _mesa_GetError);
136   SET_GetFloatv(exec, _mesa_GetFloatv);
137   SET_GetString(exec, _mesa_GetString);
138   SET_InitNames(exec, _mesa_InitNames);
139   SET_LineStipple(exec, _mesa_LineStipple);
140   SET_LineWidth(exec, _mesa_LineWidth);
141   SET_LoadIdentity(exec, _mesa_LoadIdentity);
142   SET_LoadMatrixf(exec, _mesa_LoadMatrixf);
143   SET_LoadName(exec, _mesa_LoadName);
144   SET_LogicOp(exec, _mesa_LogicOp);
145   SET_MatrixMode(exec, _mesa_MatrixMode);
146   SET_MultMatrixf(exec, _mesa_MultMatrixf);
147   SET_Ortho(exec, _mesa_Ortho);
148   SET_PixelStorei(exec, _mesa_PixelStorei);
149   SET_PopMatrix(exec, _mesa_PopMatrix);
150   SET_PopName(exec, _mesa_PopName);
151   SET_PushMatrix(exec, _mesa_PushMatrix);
152   SET_PushName(exec, _mesa_PushName);
153   SET_RasterPos2f(exec, _mesa_RasterPos2f);
154   SET_RasterPos2fv(exec, _mesa_RasterPos2fv);
155   SET_RasterPos2i(exec, _mesa_RasterPos2i);
156   SET_RasterPos2iv(exec, _mesa_RasterPos2iv);
157   SET_ReadBuffer(exec, _mesa_ReadBuffer);
158   SET_RenderMode(exec, _mesa_RenderMode);
159   SET_Rotatef(exec, _mesa_Rotatef);
160   SET_Scalef(exec, _mesa_Scalef);
161   SET_Scissor(exec, _mesa_Scissor);
162   SET_SelectBuffer(exec, _mesa_SelectBuffer);
163   SET_ShadeModel(exec, _mesa_ShadeModel);
164   SET_StencilFunc(exec, _mesa_StencilFunc);
165   SET_StencilMask(exec, _mesa_StencilMask);
166   SET_StencilOp(exec, _mesa_StencilOp);
167   SET_TexEnvfv(exec, _mesa_TexEnvfv);
168   SET_TexEnvi(exec, _mesa_TexEnvi);
169   SET_TexImage2D(exec, _mesa_TexImage2D);
170   SET_TexParameteri(exec, _mesa_TexParameteri);
171   SET_Translatef(exec, _mesa_Translatef);
172   SET_Viewport(exec, _mesa_Viewport);
173#if _HAVE_FULL_GL
174   SET_Accum(exec, _mesa_Accum);
175   SET_Bitmap(exec, _mesa_Bitmap);
176   SET_CallList(exec, _mesa_CallList);
177   SET_CallLists(exec, _mesa_CallLists);
178   SET_ClearAccum(exec, _mesa_ClearAccum);
179   SET_ClearDepth(exec, _mesa_ClearDepth);
180   SET_ClearIndex(exec, _mesa_ClearIndex);
181   SET_ClipPlane(exec, _mesa_ClipPlane);
182   SET_ColorMaterial(exec, _mesa_ColorMaterial);
183   SET_CopyPixels(exec, _mesa_CopyPixels);
184   SET_CullParameterfvEXT(exec, _mesa_CullParameterfvEXT);
185   SET_CullParameterdvEXT(exec, _mesa_CullParameterdvEXT);
186   SET_DeleteLists(exec, _mesa_DeleteLists);
187   SET_DepthFunc(exec, _mesa_DepthFunc);
188   SET_DepthMask(exec, _mesa_DepthMask);
189   SET_DepthRange(exec, _mesa_DepthRange);
190   SET_DrawPixels(exec, _mesa_DrawPixels);
191   SET_EndList(exec, _mesa_EndList);
192   SET_FeedbackBuffer(exec, _mesa_FeedbackBuffer);
193   SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT);
194   SET_Fogf(exec, _mesa_Fogf);
195   SET_Fogfv(exec, _mesa_Fogfv);
196   SET_Fogi(exec, _mesa_Fogi);
197   SET_Fogiv(exec, _mesa_Fogiv);
198   SET_GenLists(exec, _mesa_GenLists);
199   SET_GetClipPlane(exec, _mesa_GetClipPlane);
200   SET_GetBooleanv(exec, _mesa_GetBooleanv);
201   SET_GetDoublev(exec, _mesa_GetDoublev);
202   SET_GetIntegerv(exec, _mesa_GetIntegerv);
203   SET_GetLightfv(exec, _mesa_GetLightfv);
204   SET_GetLightiv(exec, _mesa_GetLightiv);
205   SET_GetMapdv(exec, _mesa_GetMapdv);
206   SET_GetMapfv(exec, _mesa_GetMapfv);
207   SET_GetMapiv(exec, _mesa_GetMapiv);
208   SET_GetMaterialfv(exec, _mesa_GetMaterialfv);
209   SET_GetMaterialiv(exec, _mesa_GetMaterialiv);
210   SET_GetPixelMapfv(exec, _mesa_GetPixelMapfv);
211   SET_GetPixelMapuiv(exec, _mesa_GetPixelMapuiv);
212   SET_GetPixelMapusv(exec, _mesa_GetPixelMapusv);
213   SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple);
214   SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv);
215   SET_GetTexEnviv(exec, _mesa_GetTexEnviv);
216   SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv);
217   SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv);
218   SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv);
219   SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv);
220   SET_GetTexGendv(exec, _mesa_GetTexGendv);
221   SET_GetTexGenfv(exec, _mesa_GetTexGenfv);
222   SET_GetTexGeniv(exec, _mesa_GetTexGeniv);
223   SET_GetTexImage(exec, _mesa_GetTexImage);
224   SET_Hint(exec, _mesa_Hint);
225   SET_IndexMask(exec, _mesa_IndexMask);
226   SET_IsEnabled(exec, _mesa_IsEnabled);
227   SET_IsList(exec, _mesa_IsList);
228   SET_LightModelf(exec, _mesa_LightModelf);
229   SET_LightModelfv(exec, _mesa_LightModelfv);
230   SET_LightModeli(exec, _mesa_LightModeli);
231   SET_LightModeliv(exec, _mesa_LightModeliv);
232   SET_Lightf(exec, _mesa_Lightf);
233   SET_Lightfv(exec, _mesa_Lightfv);
234   SET_Lighti(exec, _mesa_Lighti);
235   SET_Lightiv(exec, _mesa_Lightiv);
236   SET_ListBase(exec, _mesa_ListBase);
237   SET_LoadMatrixd(exec, _mesa_LoadMatrixd);
238   SET_Map1d(exec, _mesa_Map1d);
239   SET_Map1f(exec, _mesa_Map1f);
240   SET_Map2d(exec, _mesa_Map2d);
241   SET_Map2f(exec, _mesa_Map2f);
242   SET_MapGrid1d(exec, _mesa_MapGrid1d);
243   SET_MapGrid1f(exec, _mesa_MapGrid1f);
244   SET_MapGrid2d(exec, _mesa_MapGrid2d);
245   SET_MapGrid2f(exec, _mesa_MapGrid2f);
246   SET_MultMatrixd(exec, _mesa_MultMatrixd);
247   SET_NewList(exec, _mesa_NewList);
248   SET_PassThrough(exec, _mesa_PassThrough);
249   SET_PixelMapfv(exec, _mesa_PixelMapfv);
250   SET_PixelMapuiv(exec, _mesa_PixelMapuiv);
251   SET_PixelMapusv(exec, _mesa_PixelMapusv);
252   SET_PixelStoref(exec, _mesa_PixelStoref);
253   SET_PixelTransferf(exec, _mesa_PixelTransferf);
254   SET_PixelTransferi(exec, _mesa_PixelTransferi);
255   SET_PixelZoom(exec, _mesa_PixelZoom);
256   SET_PointSize(exec, _mesa_PointSize);
257   SET_PolygonMode(exec, _mesa_PolygonMode);
258   SET_PolygonOffset(exec, _mesa_PolygonOffset);
259   SET_PolygonStipple(exec, _mesa_PolygonStipple);
260   SET_PopAttrib(exec, _mesa_PopAttrib);
261   SET_PushAttrib(exec, _mesa_PushAttrib);
262   SET_RasterPos2d(exec, _mesa_RasterPos2d);
263   SET_RasterPos2dv(exec, _mesa_RasterPos2dv);
264   SET_RasterPos2s(exec, _mesa_RasterPos2s);
265   SET_RasterPos2sv(exec, _mesa_RasterPos2sv);
266   SET_RasterPos3d(exec, _mesa_RasterPos3d);
267   SET_RasterPos3dv(exec, _mesa_RasterPos3dv);
268   SET_RasterPos3f(exec, _mesa_RasterPos3f);
269   SET_RasterPos3fv(exec, _mesa_RasterPos3fv);
270   SET_RasterPos3i(exec, _mesa_RasterPos3i);
271   SET_RasterPos3iv(exec, _mesa_RasterPos3iv);
272   SET_RasterPos3s(exec, _mesa_RasterPos3s);
273   SET_RasterPos3sv(exec, _mesa_RasterPos3sv);
274   SET_RasterPos4d(exec, _mesa_RasterPos4d);
275   SET_RasterPos4dv(exec, _mesa_RasterPos4dv);
276   SET_RasterPos4f(exec, _mesa_RasterPos4f);
277   SET_RasterPos4fv(exec, _mesa_RasterPos4fv);
278   SET_RasterPos4i(exec, _mesa_RasterPos4i);
279   SET_RasterPos4iv(exec, _mesa_RasterPos4iv);
280   SET_RasterPos4s(exec, _mesa_RasterPos4s);
281   SET_RasterPos4sv(exec, _mesa_RasterPos4sv);
282   SET_ReadPixels(exec, _mesa_ReadPixels);
283   SET_Rotated(exec, _mesa_Rotated);
284   SET_Scaled(exec, _mesa_Scaled);
285   SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT);
286   SET_TexEnvf(exec, _mesa_TexEnvf);
287   SET_TexEnviv(exec, _mesa_TexEnviv);
288   SET_TexGend(exec, _mesa_TexGend);
289   SET_TexGendv(exec, _mesa_TexGendv);
290   SET_TexGenf(exec, _mesa_TexGenf);
291   SET_TexGenfv(exec, _mesa_TexGenfv);
292   SET_TexGeni(exec, _mesa_TexGeni);
293   SET_TexGeniv(exec, _mesa_TexGeniv);
294   SET_TexImage1D(exec, _mesa_TexImage1D);
295   SET_TexParameterf(exec, _mesa_TexParameterf);
296   SET_TexParameterfv(exec, _mesa_TexParameterfv);
297   SET_TexParameteriv(exec, _mesa_TexParameteriv);
298   SET_Translated(exec, _mesa_Translated);
299#endif
300
301   /* 1.1 */
302   SET_BindTexture(exec, _mesa_BindTexture);
303   SET_DeleteTextures(exec, _mesa_DeleteTextures);
304   SET_GenTextures(exec, _mesa_GenTextures);
305#if _HAVE_FULL_GL
306   SET_AreTexturesResident(exec, _mesa_AreTexturesResident);
307   SET_ColorPointer(exec, _mesa_ColorPointer);
308   SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D);
309   SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D);
310   SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D);
311   SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D);
312   SET_DisableClientState(exec, _mesa_DisableClientState);
313   SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
314   SET_EnableClientState(exec, _mesa_EnableClientState);
315   SET_GetPointerv(exec, _mesa_GetPointerv);
316   SET_IndexPointer(exec, _mesa_IndexPointer);
317   SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
318   SET_IsTexture(exec, _mesa_IsTexture);
319   SET_NormalPointer(exec, _mesa_NormalPointer);
320   SET_PopClientAttrib(exec, _mesa_PopClientAttrib);
321   SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures);
322   SET_PushClientAttrib(exec, _mesa_PushClientAttrib);
323   SET_TexCoordPointer(exec, _mesa_TexCoordPointer);
324   SET_TexSubImage1D(exec, _mesa_TexSubImage1D);
325   SET_TexSubImage2D(exec, _mesa_TexSubImage2D);
326   SET_VertexPointer(exec, _mesa_VertexPointer);
327#endif
328
329   /* 1.2 */
330#if _HAVE_FULL_GL
331   SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D);
332   SET_TexImage3D(exec, _mesa_TexImage3D);
333   SET_TexSubImage3D(exec, _mesa_TexSubImage3D);
334#endif
335
336   /* OpenGL 1.2  GL_ARB_imaging */
337#if _HAVE_FULL_GL
338   SET_BlendColor(exec, _mesa_BlendColor);
339   SET_BlendEquation(exec, _mesa_BlendEquation);
340   SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT);
341   SET_ColorSubTable(exec, _mesa_ColorSubTable);
342   SET_ColorTable(exec, _mesa_ColorTable);
343   SET_ColorTableParameterfv(exec, _mesa_ColorTableParameterfv);
344   SET_ColorTableParameteriv(exec, _mesa_ColorTableParameteriv);
345   SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D);
346   SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D);
347   SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf);
348   SET_ConvolutionParameterfv(exec, _mesa_ConvolutionParameterfv);
349   SET_ConvolutionParameteri(exec, _mesa_ConvolutionParameteri);
350   SET_ConvolutionParameteriv(exec, _mesa_ConvolutionParameteriv);
351   SET_CopyColorSubTable(exec, _mesa_CopyColorSubTable);
352   SET_CopyColorTable(exec, _mesa_CopyColorTable);
353   SET_CopyConvolutionFilter1D(exec, _mesa_CopyConvolutionFilter1D);
354   SET_CopyConvolutionFilter2D(exec, _mesa_CopyConvolutionFilter2D);
355   SET_GetColorTable(exec, _mesa_GetColorTable);
356   SET_GetColorTableParameterfv(exec, _mesa_GetColorTableParameterfv);
357   SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv);
358   SET_GetConvolutionFilter(exec, _mesa_GetConvolutionFilter);
359   SET_GetConvolutionParameterfv(exec, _mesa_GetConvolutionParameterfv);
360   SET_GetConvolutionParameteriv(exec, _mesa_GetConvolutionParameteriv);
361   SET_GetHistogram(exec, _mesa_GetHistogram);
362   SET_GetHistogramParameterfv(exec, _mesa_GetHistogramParameterfv);
363   SET_GetHistogramParameteriv(exec, _mesa_GetHistogramParameteriv);
364   SET_GetMinmax(exec, _mesa_GetMinmax);
365   SET_GetMinmaxParameterfv(exec, _mesa_GetMinmaxParameterfv);
366   SET_GetMinmaxParameteriv(exec, _mesa_GetMinmaxParameteriv);
367   SET_GetSeparableFilter(exec, _mesa_GetSeparableFilter);
368   SET_Histogram(exec, _mesa_Histogram);
369   SET_Minmax(exec, _mesa_Minmax);
370   SET_ResetHistogram(exec, _mesa_ResetHistogram);
371   SET_ResetMinmax(exec, _mesa_ResetMinmax);
372   SET_SeparableFilter2D(exec, _mesa_SeparableFilter2D);
373#endif
374
375   /* OpenGL 2.0 */
376   SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate);
377   SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate);
378   SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate);
379#if FEATURE_ARB_shader_objects
380   SET_AttachShader(exec, _mesa_AttachShader);
381   SET_CreateProgram(exec, _mesa_CreateProgram);
382   SET_CreateShader(exec, _mesa_CreateShader);
383   SET_DeleteProgram(exec, _mesa_DeleteProgram);
384   SET_DeleteShader(exec, _mesa_DeleteShader);
385   SET_DetachShader(exec, _mesa_DetachShader);
386   SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders);
387   SET_GetProgramiv(exec, _mesa_GetProgramiv);
388   SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog);
389   SET_GetShaderiv(exec, _mesa_GetShaderiv);
390   SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog);
391   SET_IsProgram(exec, _mesa_IsProgram);
392   SET_IsShader(exec, _mesa_IsShader);
393#endif
394
395   /* OpenGL 2.1 */
396#if FEATURE_ARB_shader_objects
397   SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv);
398   SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv);
399   SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv);
400   SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv);
401   SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv);
402   SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv);
403#endif
404
405
406   /* 2. GL_EXT_blend_color */
407#if 0
408/*    SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */
409#endif
410
411   /* 3. GL_EXT_polygon_offset */
412#if _HAVE_FULL_GL
413   SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT);
414#endif
415
416   /* 6. GL_EXT_texture3d */
417#if 0
418/*    SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */
419/*    SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */
420/*    SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */
421#endif
422
423   /* 11. GL_EXT_histogram */
424#if 0
425   SET_GetHistogramEXT(exec, _mesa_GetHistogram);
426   SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv);
427   SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv);
428   SET_GetMinmaxEXT(exec, _mesa_GetMinmax);
429   SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv);
430   SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv);
431#endif
432
433   /* 14. SGI_color_table */
434#if 0
435   SET_ColorTableSGI(exec, _mesa_ColorTable);
436   SET_ColorSubTableSGI(exec, _mesa_ColorSubTable);
437   SET_GetColorTableSGI(exec, _mesa_GetColorTable);
438   SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv);
439   SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv);
440#endif
441
442   /* 30. GL_EXT_vertex_array */
443#if _HAVE_FULL_GL
444   SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT);
445   SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT);
446   SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT);
447   SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT);
448   SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT);
449   SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT);
450#endif
451
452   /* 37. GL_EXT_blend_minmax */
453#if 0
454   SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT);
455#endif
456
457   /* 54. GL_EXT_point_parameters */
458#if _HAVE_FULL_GL
459   SET_PointParameterfEXT(exec, _mesa_PointParameterfEXT);
460   SET_PointParameterfvEXT(exec, _mesa_PointParameterfvEXT);
461#endif
462
463   /* 97. GL_EXT_compiled_vertex_array */
464#if _HAVE_FULL_GL
465   SET_LockArraysEXT(exec, _mesa_LockArraysEXT);
466   SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT);
467#endif
468
469   /* 148. GL_EXT_multi_draw_arrays */
470#if _HAVE_FULL_GL
471   SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT);
472   SET_MultiDrawElementsEXT(exec, _mesa_MultiDrawElementsEXT);
473#endif
474
475   /* 173. GL_INGR_blend_func_separate */
476#if _HAVE_FULL_GL
477   SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT);
478#endif
479
480   /* 196. GL_MESA_resize_buffers */
481#if _HAVE_FULL_GL
482   SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA);
483#endif
484
485   /* 197. GL_MESA_window_pos */
486#if _HAVE_FULL_GL
487   SET_WindowPos2dMESA(exec, _mesa_WindowPos2dMESA);
488   SET_WindowPos2dvMESA(exec, _mesa_WindowPos2dvMESA);
489   SET_WindowPos2fMESA(exec, _mesa_WindowPos2fMESA);
490   SET_WindowPos2fvMESA(exec, _mesa_WindowPos2fvMESA);
491   SET_WindowPos2iMESA(exec, _mesa_WindowPos2iMESA);
492   SET_WindowPos2ivMESA(exec, _mesa_WindowPos2ivMESA);
493   SET_WindowPos2sMESA(exec, _mesa_WindowPos2sMESA);
494   SET_WindowPos2svMESA(exec, _mesa_WindowPos2svMESA);
495   SET_WindowPos3dMESA(exec, _mesa_WindowPos3dMESA);
496   SET_WindowPos3dvMESA(exec, _mesa_WindowPos3dvMESA);
497   SET_WindowPos3fMESA(exec, _mesa_WindowPos3fMESA);
498   SET_WindowPos3fvMESA(exec, _mesa_WindowPos3fvMESA);
499   SET_WindowPos3iMESA(exec, _mesa_WindowPos3iMESA);
500   SET_WindowPos3ivMESA(exec, _mesa_WindowPos3ivMESA);
501   SET_WindowPos3sMESA(exec, _mesa_WindowPos3sMESA);
502   SET_WindowPos3svMESA(exec, _mesa_WindowPos3svMESA);
503   SET_WindowPos4dMESA(exec, _mesa_WindowPos4dMESA);
504   SET_WindowPos4dvMESA(exec, _mesa_WindowPos4dvMESA);
505   SET_WindowPos4fMESA(exec, _mesa_WindowPos4fMESA);
506   SET_WindowPos4fvMESA(exec, _mesa_WindowPos4fvMESA);
507   SET_WindowPos4iMESA(exec, _mesa_WindowPos4iMESA);
508   SET_WindowPos4ivMESA(exec, _mesa_WindowPos4ivMESA);
509   SET_WindowPos4sMESA(exec, _mesa_WindowPos4sMESA);
510   SET_WindowPos4svMESA(exec, _mesa_WindowPos4svMESA);
511#endif
512
513   /* 200. GL_IBM_multimode_draw_arrays */
514#if _HAVE_FULL_GL
515   SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM);
516   SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM);
517#endif
518
519   /* 233. GL_NV_vertex_program */
520#if FEATURE_NV_vertex_program
521   SET_BindProgramNV(exec, _mesa_BindProgram);
522   SET_DeleteProgramsNV(exec, _mesa_DeletePrograms);
523   SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV);
524   SET_GenProgramsNV(exec, _mesa_GenPrograms);
525   SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV);
526   SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV);
527   SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV);
528   SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV);
529   SET_GetProgramivNV(exec, _mesa_GetProgramivNV);
530   SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV);
531   SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV);
532   SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV);
533   SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV);
534   SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV);
535   SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV);
536   SET_IsProgramNV(exec, _mesa_IsProgramARB);
537   SET_LoadProgramNV(exec, _mesa_LoadProgramNV);
538   SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */
539   SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB);  /* alias to ProgramParameter4dvNV */
540   SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB);  /* alias to ProgramParameter4fNV */
541   SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB);  /* alias to ProgramParameter4fvNV */
542   SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV);
543   SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV);
544   SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV);
545   SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV);
546   /* glVertexAttrib*NV functions handled in api_loopback.c */
547#endif
548
549   /* 273. GL_APPLE_vertex_array_object */
550   SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE);
551   SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE);
552   SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE);
553   SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE);
554
555   /* 282. GL_NV_fragment_program */
556#if FEATURE_NV_fragment_program
557   SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV);
558   SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV);
559   SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV);
560   SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV);
561   SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV);
562   SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV);
563   SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB);
564   SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB);
565   SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB);
566   SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB);
567   SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB);
568   SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB);
569#endif
570
571   /* 262. GL_NV_point_sprite */
572#if _HAVE_FULL_GL
573   SET_PointParameteriNV(exec, _mesa_PointParameteriNV);
574   SET_PointParameterivNV(exec, _mesa_PointParameterivNV);
575#endif
576
577   /* 268. GL_EXT_stencil_two_side */
578#if _HAVE_FULL_GL
579   SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT);
580#endif
581
582   /* ???. GL_EXT_depth_bounds_test */
583   SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT);
584
585   /* ARB 1. GL_ARB_multitexture */
586#if _HAVE_FULL_GL
587   SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB);
588   SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB);
589#endif
590
591   /* ARB 3. GL_ARB_transpose_matrix */
592#if _HAVE_FULL_GL
593   SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB);
594   SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB);
595   SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB);
596   SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB);
597#endif
598
599   /* ARB 5. GL_ARB_multisample */
600#if _HAVE_FULL_GL
601   SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB);
602#endif
603
604   /* ARB 12. GL_ARB_texture_compression */
605#if _HAVE_FULL_GL
606   SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB);
607   SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB);
608   SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB);
609   SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB);
610   SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB);
611   SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB);
612   SET_GetCompressedTexImageARB(exec, _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   SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB);
658   SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB);
659   SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB);
660   SET_ProgramStringARB(exec, _mesa_ProgramStringARB);
661   /* glBindProgramARB aliases glBindProgramNV */
662   /* glDeleteProgramsARB aliases glDeleteProgramsNV */
663   /* glGenProgramsARB aliases glGenProgramsNV */
664   /* glIsProgramARB aliases glIsProgramNV */
665   SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB);
666   SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB);
667   SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB);
668   /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */
669   SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB);
670   SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB);
671   SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB);
672   SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB);
673   SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB);
674   SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB);
675   SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB);
676   SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB);
677   SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB);
678   SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB);
679   SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB);
680   SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB);
681   SET_GetProgramivARB(exec, _mesa_GetProgramivARB);
682   SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB);
683#endif
684
685   /* ARB 28. GL_ARB_vertex_buffer_object */
686#if FEATURE_ARB_vertex_buffer_object
687   SET_BindBufferARB(exec, _mesa_BindBufferARB);
688   SET_BufferDataARB(exec, _mesa_BufferDataARB);
689   SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB);
690   SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB);
691   SET_GenBuffersARB(exec, _mesa_GenBuffersARB);
692   SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB);
693   SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB);
694   SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB);
695   SET_IsBufferARB(exec, _mesa_IsBufferARB);
696   SET_MapBufferARB(exec, _mesa_MapBufferARB);
697   SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB);
698#endif
699
700   /* ARB 29. GL_ARB_occlusion_query */
701#if FEATURE_ARB_occlusion_query
702   SET_GenQueriesARB(exec, _mesa_GenQueriesARB);
703   SET_DeleteQueriesARB(exec, _mesa_DeleteQueriesARB);
704   SET_IsQueryARB(exec, _mesa_IsQueryARB);
705   SET_BeginQueryARB(exec, _mesa_BeginQueryARB);
706   SET_EndQueryARB(exec, _mesa_EndQueryARB);
707   SET_GetQueryivARB(exec, _mesa_GetQueryivARB);
708   SET_GetQueryObjectivARB(exec, _mesa_GetQueryObjectivARB);
709   SET_GetQueryObjectuivARB(exec, _mesa_GetQueryObjectuivARB);
710#endif
711
712   /* ARB 37. GL_ARB_draw_buffers */
713   SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB);
714
715#if FEATURE_ARB_shader_objects
716   SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB);
717   SET_GetHandleARB(exec, _mesa_GetHandleARB);
718   SET_DetachObjectARB(exec, _mesa_DetachObjectARB);
719   SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB);
720   SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB);
721   SET_CompileShaderARB(exec, _mesa_CompileShaderARB);
722   SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB);
723   SET_AttachObjectARB(exec, _mesa_AttachObjectARB);
724   SET_LinkProgramARB(exec, _mesa_LinkProgramARB);
725   SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB);
726   SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB);
727   SET_Uniform1fARB(exec, _mesa_Uniform1fARB);
728   SET_Uniform2fARB(exec, _mesa_Uniform2fARB);
729   SET_Uniform3fARB(exec, _mesa_Uniform3fARB);
730   SET_Uniform4fARB(exec, _mesa_Uniform4fARB);
731   SET_Uniform1iARB(exec, _mesa_Uniform1iARB);
732   SET_Uniform2iARB(exec, _mesa_Uniform2iARB);
733   SET_Uniform3iARB(exec, _mesa_Uniform3iARB);
734   SET_Uniform4iARB(exec, _mesa_Uniform4iARB);
735   SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB);
736   SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB);
737   SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB);
738   SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB);
739   SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB);
740   SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB);
741   SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB);
742   SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB);
743   SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB);
744   SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB);
745   SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB);
746   SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB);
747   SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB);
748   SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB);
749   SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB);
750   SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB);
751   SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB);
752   SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB);
753   SET_GetUniformivARB(exec, _mesa_GetUniformivARB);
754   SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB);
755#endif    /* FEATURE_ARB_shader_objects */
756
757#if FEATURE_ARB_vertex_shader
758   SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB);
759   SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB);
760   SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
761#endif    /* FEATURE_ARB_vertex_shader */
762
763  /* GL_ATI_fragment_shader */
764#if FEATURE_ATI_fragment_shader
765   SET_GenFragmentShadersATI(exec, _mesa_GenFragmentShadersATI);
766   SET_BindFragmentShaderATI(exec, _mesa_BindFragmentShaderATI);
767   SET_DeleteFragmentShaderATI(exec, _mesa_DeleteFragmentShaderATI);
768   SET_BeginFragmentShaderATI(exec, _mesa_BeginFragmentShaderATI);
769   SET_EndFragmentShaderATI(exec, _mesa_EndFragmentShaderATI);
770   SET_PassTexCoordATI(exec, _mesa_PassTexCoordATI);
771   SET_SampleMapATI(exec, _mesa_SampleMapATI);
772   SET_ColorFragmentOp1ATI(exec, _mesa_ColorFragmentOp1ATI);
773   SET_ColorFragmentOp2ATI(exec, _mesa_ColorFragmentOp2ATI);
774   SET_ColorFragmentOp3ATI(exec, _mesa_ColorFragmentOp3ATI);
775   SET_AlphaFragmentOp1ATI(exec, _mesa_AlphaFragmentOp1ATI);
776   SET_AlphaFragmentOp2ATI(exec, _mesa_AlphaFragmentOp2ATI);
777   SET_AlphaFragmentOp3ATI(exec, _mesa_AlphaFragmentOp3ATI);
778   SET_SetFragmentShaderConstantATI(exec, _mesa_SetFragmentShaderConstantATI);
779#endif
780
781#if FEATURE_EXT_framebuffer_object
782   SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT);
783   SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT);
784   SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT);
785   SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT);
786   SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT);
787   SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT);
788   SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT);
789   SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT);
790   SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT);
791   SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT);
792   SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT);
793   SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT);
794   SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT);
795   SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT);
796   SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT);
797   SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT);
798   SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT);
799#endif
800
801#if FEATURE_EXT_timer_query
802   SET_GetQueryObjecti64vEXT(exec, _mesa_GetQueryObjecti64vEXT);
803   SET_GetQueryObjectui64vEXT(exec, _mesa_GetQueryObjectui64vEXT);
804#endif
805
806#if FEATURE_EXT_framebuffer_blit
807   SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT);
808#endif
809
810   /* GL_EXT_gpu_program_parameters */
811#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
812   SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT);
813   SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT);
814#endif
815
816   /* GL_MESA_texture_array / GL_EXT_texture_array */
817#if FEATURE_EXT_framebuffer_object
818   SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT);
819#endif
820
821   /* GL_ATI_separate_stencil */
822   SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI);
823}
824
825
826
827/**********************************************************************/
828/** \name State update logic */
829/*@{*/
830
831
832static void
833update_separate_specular(GLcontext *ctx)
834{
835   if (NEED_SECONDARY_COLOR(ctx))
836      ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
837   else
838      ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
839}
840
841
842/**
843 * Update state dependent on vertex arrays.
844 */
845static void
846update_arrays( GLcontext *ctx )
847{
848   GLuint i, min;
849
850   /* find min of _MaxElement values for all enabled arrays */
851
852   /* 0 */
853   if (ctx->VertexProgram._Current
854       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
855      min = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
856   }
857   else if (ctx->Array.ArrayObj->Vertex.Enabled) {
858      min = ctx->Array.ArrayObj->Vertex._MaxElement;
859   }
860   else {
861      /* can't draw anything without vertex positions! */
862      min = 0;
863   }
864
865   /* 1 */
866   if (ctx->VertexProgram._Enabled
867       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
868      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement);
869   }
870   /* no conventional vertex weight array */
871
872   /* 2 */
873   if (ctx->VertexProgram._Enabled
874       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
875      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement);
876   }
877   else if (ctx->Array.ArrayObj->Normal.Enabled) {
878      min = MIN2(min, ctx->Array.ArrayObj->Normal._MaxElement);
879   }
880
881   /* 3 */
882   if (ctx->VertexProgram._Enabled
883       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
884      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement);
885   }
886   else if (ctx->Array.ArrayObj->Color.Enabled) {
887      min = MIN2(min, ctx->Array.ArrayObj->Color._MaxElement);
888   }
889
890   /* 4 */
891   if (ctx->VertexProgram._Enabled
892       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
893      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement);
894   }
895   else if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
896      min = MIN2(min, ctx->Array.ArrayObj->SecondaryColor._MaxElement);
897   }
898
899   /* 5 */
900   if (ctx->VertexProgram._Enabled
901       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
902      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG]._MaxElement);
903   }
904   else if (ctx->Array.ArrayObj->FogCoord.Enabled) {
905      min = MIN2(min, ctx->Array.ArrayObj->FogCoord._MaxElement);
906   }
907
908   /* 6 */
909   if (ctx->VertexProgram._Enabled
910       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
911      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]._MaxElement);
912   }
913   else if (ctx->Array.ArrayObj->Index.Enabled) {
914      min = MIN2(min, ctx->Array.ArrayObj->Index._MaxElement);
915   }
916
917
918   /* 7 */
919   if (ctx->VertexProgram._Enabled
920       && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
921      min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]._MaxElement);
922   }
923
924   /* 8..15 */
925   for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) {
926      if (ctx->VertexProgram._Enabled
927          && ctx->Array.ArrayObj->VertexAttrib[i].Enabled) {
928         min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement);
929      }
930      else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
931               && ctx->Array.ArrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
932         min = MIN2(min, ctx->Array.ArrayObj->TexCoord[i - VERT_ATTRIB_TEX0]._MaxElement);
933      }
934   }
935
936   /* 16..31 */
937   if (ctx->VertexProgram._Current) {
938      for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
939         if (ctx->Array.ArrayObj->VertexAttrib[i].Enabled) {
940            min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[i]._MaxElement);
941         }
942      }
943   }
944
945   if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
946      min = MIN2(min, ctx->Array.ArrayObj->EdgeFlag._MaxElement);
947   }
948
949   /* _MaxElement is one past the last legal array element */
950   ctx->Array._MaxElement = min;
951}
952
953
954/**
955 * Update derived vertex/fragment program state.
956 */
957static void
958update_program(GLcontext *ctx)
959{
960   const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
961
962   /* These _Enabled flags indicate if the program is enabled AND valid. */
963   ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
964      && ctx->VertexProgram.Current->Base.Instructions;
965   ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
966      && ctx->FragmentProgram.Current->Base.Instructions;
967   ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
968      && ctx->ATIFragmentShader.Current->Instructions;
969
970   /*
971    * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
972    * pointers to the programs that should be enabled/used.
973    *
974    * These programs may come from several sources.  The priority is as
975    * follows:
976    *   1. OpenGL 2.0/ARB vertex/fragment shaders
977    *   2. ARB/NV vertex/fragment programs
978    *   3. Programs derived from fixed-function state.
979    */
980
981   ctx->FragmentProgram._Current = NULL;
982
983   if (shProg && shProg->LinkStatus) {
984      /* Use shader programs */
985      /* XXX this isn't quite right, since we may have either a vertex
986       * _or_ fragment shader (not always both).
987       */
988      ctx->VertexProgram._Current = shProg->VertexProgram;
989      ctx->FragmentProgram._Current = shProg->FragmentProgram;
990   }
991   else {
992      if (ctx->VertexProgram._Enabled) {
993         /* use user-defined vertex program */
994         ctx->VertexProgram._Current = ctx->VertexProgram.Current;
995      }
996      else if (ctx->VertexProgram._MaintainTnlProgram) {
997         /* Use vertex program generated from fixed-function state.
998          * The _Current pointer will get set in
999          * _tnl_UpdateFixedFunctionProgram() later if appropriate.
1000          */
1001         ctx->VertexProgram._Current = NULL;
1002      }
1003      else {
1004         /* no vertex program */
1005         ctx->VertexProgram._Current = NULL;
1006      }
1007
1008      if (ctx->FragmentProgram._Enabled) {
1009         /* use user-defined vertex program */
1010         ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
1011      }
1012      else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
1013         /* Use fragment program generated from fixed-function state.
1014          * The _Current pointer will get set in _mesa_UpdateTexEnvProgram()
1015          * later if appropriate.
1016          */
1017         ctx->FragmentProgram._Current = NULL;
1018      }
1019      else {
1020         /* no fragment program */
1021         ctx->FragmentProgram._Current = NULL;
1022      }
1023   }
1024
1025   ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
1026   if (ctx->FragmentProgram._MaintainTexEnvProgram &&
1027       !ctx->FragmentProgram._Enabled) {
1028      if (ctx->FragmentProgram._UseTexEnvProgram)
1029	 ctx->FragmentProgram._Active = GL_TRUE;
1030   }
1031}
1032
1033
1034static void
1035update_viewport_matrix(GLcontext *ctx)
1036{
1037   const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
1038
1039   ASSERT(depthMax > 0);
1040
1041   /* Compute scale and bias values. This is really driver-specific
1042    * and should be maintained elsewhere if at all.
1043    * NOTE: RasterPos uses this.
1044    */
1045   _math_matrix_viewport(&ctx->Viewport._WindowMap,
1046                         ctx->Viewport.X, ctx->Viewport.Y,
1047                         ctx->Viewport.Width, ctx->Viewport.Height,
1048                         ctx->Viewport.Near, ctx->Viewport.Far,
1049                         depthMax);
1050}
1051
1052
1053/**
1054 * Update derived color/blend/logicop state.
1055 */
1056static void
1057update_color(GLcontext *ctx)
1058{
1059   /* This is needed to support 1.1's RGB logic ops AND
1060    * 1.0's blending logicops.
1061    */
1062   ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx);
1063}
1064
1065
1066/*
1067 * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
1068 * in ctx->_TriangleCaps if needed.
1069 */
1070static void
1071update_polygon(GLcontext *ctx)
1072{
1073   ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);
1074
1075   if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
1076      ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
1077
1078   if (   ctx->Polygon.OffsetPoint
1079       || ctx->Polygon.OffsetLine
1080       || ctx->Polygon.OffsetFill)
1081      ctx->_TriangleCaps |= DD_TRI_OFFSET;
1082}
1083
1084
1085/**
1086 * Update the ctx->_TriangleCaps bitfield.
1087 * XXX that bitfield should really go away someday!
1088 * This function must be called after other update_*() functions since
1089 * there are dependencies on some other derived values.
1090 */
1091#if 0
1092static void
1093update_tricaps(GLcontext *ctx, GLbitfield new_state)
1094{
1095   ctx->_TriangleCaps = 0;
1096
1097   /*
1098    * Points
1099    */
1100   if (1/*new_state & _NEW_POINT*/) {
1101      if (ctx->Point.SmoothFlag)
1102         ctx->_TriangleCaps |= DD_POINT_SMOOTH;
1103      if (ctx->Point.Size != 1.0F)
1104         ctx->_TriangleCaps |= DD_POINT_SIZE;
1105      if (ctx->Point._Attenuated)
1106         ctx->_TriangleCaps |= DD_POINT_ATTEN;
1107   }
1108
1109   /*
1110    * Lines
1111    */
1112   if (1/*new_state & _NEW_LINE*/) {
1113      if (ctx->Line.SmoothFlag)
1114         ctx->_TriangleCaps |= DD_LINE_SMOOTH;
1115      if (ctx->Line.StippleFlag)
1116         ctx->_TriangleCaps |= DD_LINE_STIPPLE;
1117      if (ctx->Line.Width != 1.0)
1118         ctx->_TriangleCaps |= DD_LINE_WIDTH;
1119   }
1120
1121   /*
1122    * Polygons
1123    */
1124   if (1/*new_state & _NEW_POLYGON*/) {
1125      if (ctx->Polygon.SmoothFlag)
1126         ctx->_TriangleCaps |= DD_TRI_SMOOTH;
1127      if (ctx->Polygon.StippleFlag)
1128         ctx->_TriangleCaps |= DD_TRI_STIPPLE;
1129      if (ctx->Polygon.FrontMode != GL_FILL
1130          || ctx->Polygon.BackMode != GL_FILL)
1131         ctx->_TriangleCaps |= DD_TRI_UNFILLED;
1132      if (ctx->Polygon.CullFlag
1133          && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
1134         ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
1135      if (ctx->Polygon.OffsetPoint ||
1136          ctx->Polygon.OffsetLine ||
1137          ctx->Polygon.OffsetFill)
1138         ctx->_TriangleCaps |= DD_TRI_OFFSET;
1139   }
1140
1141   /*
1142    * Lighting and shading
1143    */
1144   if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
1145      ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
1146   if (ctx->Light.ShadeModel == GL_FLAT)
1147      ctx->_TriangleCaps |= DD_FLATSHADE;
1148   if (NEED_SECONDARY_COLOR(ctx))
1149      ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
1150
1151   /*
1152    * Stencil
1153    */
1154   if (ctx->Stencil._TestTwoSide)
1155      ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
1156}
1157#endif
1158
1159
1160/**
1161 * Compute derived GL state.
1162 * If __GLcontextRec::NewState is non-zero then this function \b must
1163 * be called before rendering anything.
1164 *
1165 * Calls dd_function_table::UpdateState to perform any internal state
1166 * management necessary.
1167 *
1168 * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
1169 * _mesa_update_buffer_bounds(),
1170 * _mesa_update_lighting() and _mesa_update_tnl_spaces().
1171 */
1172void
1173_mesa_update_state_locked( GLcontext *ctx )
1174{
1175   GLbitfield new_state = ctx->NewState;
1176
1177   if (MESA_VERBOSE & VERBOSE_STATE)
1178      _mesa_print_state("_mesa_update_state", new_state);
1179
1180   if (new_state & _NEW_PROGRAM)
1181      update_program( ctx );
1182
1183   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
1184      _mesa_update_modelview_project( ctx, new_state );
1185
1186   if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
1187      _mesa_update_texture( ctx, new_state );
1188
1189   if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
1190      _mesa_update_framebuffer(ctx);
1191
1192   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
1193      _mesa_update_draw_buffer_bounds( ctx );
1194
1195   if (new_state & _NEW_POLYGON)
1196      update_polygon( ctx );
1197
1198   if (new_state & _NEW_LIGHT)
1199      _mesa_update_lighting( ctx );
1200
1201   if (new_state & _NEW_STENCIL)
1202      _mesa_update_stencil( ctx );
1203
1204   if (new_state & _IMAGE_NEW_TRANSFER_STATE)
1205      _mesa_update_pixel( ctx, new_state );
1206
1207   if (new_state & _DD_NEW_SEPARATE_SPECULAR)
1208      update_separate_specular( ctx );
1209
1210   if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
1211      update_arrays( ctx );
1212
1213   if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT))
1214      update_viewport_matrix(ctx);
1215
1216   if (new_state & _NEW_COLOR)
1217      update_color( ctx );
1218
1219#if 0
1220   if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
1221                    | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
1222      update_tricaps( ctx, new_state );
1223#endif
1224
1225   if (ctx->FragmentProgram._MaintainTexEnvProgram) {
1226      if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
1227	 _mesa_UpdateTexEnvProgram(ctx);
1228   }
1229
1230   /* ctx->_NeedEyeCoords is now up to date.
1231    *
1232    * If the truth value of this variable has changed, update for the
1233    * new lighting space and recompute the positions of lights and the
1234    * normal transform.
1235    *
1236    * If the lighting space hasn't changed, may still need to recompute
1237    * light positions & normal transforms for other reasons.
1238    */
1239   if (new_state & _MESA_NEW_NEED_EYE_COORDS)
1240      _mesa_update_tnl_spaces( ctx, new_state );
1241
1242   /*
1243    * Give the driver a chance to act upon the new_state flags.
1244    * The driver might plug in different span functions, for example.
1245    * Also, this is where the driver can invalidate the state of any
1246    * active modules (such as swrast_setup, swrast, tnl, etc).
1247    *
1248    * Set ctx->NewState to zero to avoid recursion if
1249    * Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)
1250    */
1251   new_state = ctx->NewState;
1252   ctx->NewState = 0;
1253   ctx->Driver.UpdateState(ctx, new_state);
1254   ctx->Array.NewState = 0;
1255}
1256
1257
1258/* This is the usual entrypoint for state updates:
1259 */
1260void
1261_mesa_update_state( GLcontext *ctx )
1262{
1263   _mesa_lock_context_textures(ctx);
1264   _mesa_update_state_locked(ctx);
1265   _mesa_unlock_context_textures(ctx);
1266}
1267
1268
1269
1270/*@}*/
1271
1272
1273