dlist.c revision 1e2f57425153d73646fde7c91c16aa5559491556
1010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)/*
2010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Mesa 3-D graphics library
3010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Version:  7.1
4010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) *
5010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
6010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) *
7010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Permission is hereby granted, free of charge, to any person obtaining a
8010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * copy of this software and associated documentation files (the "Software"),
9010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * to deal in the Software without restriction, including without limitation
10010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * and/or sell copies of the Software, and to permit persons to whom the
12010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Software is furnished to do so, subject to the following conditions:
13010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) *
14010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * The above copyright notice and this permission notice shall be included
15010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * in all copies or substantial portions of the Software.
16010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) *
17010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) */
24010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
25010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
26010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)/**
27010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * \file dlist.c
28010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) * Display lists management functions.
29010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) */
30010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
31010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "glheader.h"
32010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "imports.h"
33010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "api_arrayelt.h"
34010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "api_loopback.h"
35010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "config.h"
36010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "attrib.h"
37010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "blend.h"
38010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "buffers.h"
39010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#if FEATURE_ARB_vertex_buffer_object
40010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "bufferobj.h"
41010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#endif
42010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "arrayobj.h"
43010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "clip.h"
44010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "colortab.h"
45010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "context.h"
46010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "convolve.h"
47010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "depth.h"
48#include "dlist.h"
49#include "enable.h"
50#include "enums.h"
51#include "eval.h"
52#include "extensions.h"
53#include "feedback.h"
54#include "framebuffer.h"
55#include "get.h"
56#include "glapi/glapi.h"
57#include "hash.h"
58#include "histogram.h"
59#include "image.h"
60#include "light.h"
61#include "lines.h"
62#include "dlist.h"
63#include "macros.h"
64#include "matrix.h"
65#include "pixel.h"
66#include "points.h"
67#include "polygon.h"
68#include "queryobj.h"
69#include "state.h"
70#include "texobj.h"
71#include "teximage.h"
72#include "texstate.h"
73#include "mtypes.h"
74#include "varray.h"
75#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
76#include "shader/arbprogram.h"
77#include "shader/program.h"
78#endif
79#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
80#include "shader/nvprogram.h"
81#include "shader/program.h"
82#endif
83#if FEATURE_ATI_fragment_shader
84#include "shader/atifragshader.h"
85#endif
86
87#include "math/m_matrix.h"
88#include "math/m_xform.h"
89
90#include "glapi/dispatch.h"
91
92
93/**
94 * Flush vertices.
95 *
96 * \param ctx GL context.
97 *
98 * Checks if dd_function_table::SaveNeedFlush is marked to flush
99 * stored (save) vertices, and calls
100 * dd_function_table::SaveFlushVertices if so.
101 */
102#define SAVE_FLUSH_VERTICES(ctx)		\
103do {						\
104   if (ctx->Driver.SaveNeedFlush)		\
105      ctx->Driver.SaveFlushVertices(ctx);	\
106} while (0)
107
108
109/**
110 * Macro to assert that the API call was made outside the
111 * glBegin()/glEnd() pair, with return value.
112 *
113 * \param ctx GL context.
114 * \param retval value to return value in case the assertion fails.
115 */
116#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)		\
117do {									\
118   if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||		\
119       ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) {	\
120      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" );	\
121      return retval;							\
122   }									\
123} while (0)
124
125/**
126 * Macro to assert that the API call was made outside the
127 * glBegin()/glEnd() pair.
128 *
129 * \param ctx GL context.
130 */
131#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)				\
132do {									\
133   if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||		\
134       ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) {	\
135      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" );	\
136      return;								\
137   }									\
138} while (0)
139
140/**
141 * Macro to assert that the API call was made outside the
142 * glBegin()/glEnd() pair and flush the vertices.
143 *
144 * \param ctx GL context.
145 */
146#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)			\
147do {									\
148   ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);					\
149   SAVE_FLUSH_VERTICES(ctx);						\
150} while (0)
151
152/**
153 * Macro to assert that the API call was made outside the
154 * glBegin()/glEnd() pair and flush the vertices, with return value.
155 *
156 * \param ctx GL context.
157 * \param retval value to return value in case the assertion fails.
158 */
159#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
160do {									\
161   ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);		\
162   SAVE_FLUSH_VERTICES(ctx);						\
163} while (0)
164
165
166
167/**
168 * Display list opcodes.
169 *
170 * The fact that these identifiers are assigned consecutive
171 * integer values starting at 0 is very important, see InstSize array usage)
172 */
173typedef enum
174{
175   OPCODE_INVALID = -1,         /* Force signed enum */
176   OPCODE_ACCUM,
177   OPCODE_ALPHA_FUNC,
178   OPCODE_BIND_TEXTURE,
179   OPCODE_BITMAP,
180   OPCODE_BLEND_COLOR,
181   OPCODE_BLEND_EQUATION,
182   OPCODE_BLEND_EQUATION_SEPARATE,
183   OPCODE_BLEND_FUNC_SEPARATE,
184   OPCODE_CALL_LIST,
185   OPCODE_CALL_LIST_OFFSET,
186   OPCODE_CLEAR,
187   OPCODE_CLEAR_ACCUM,
188   OPCODE_CLEAR_COLOR,
189   OPCODE_CLEAR_DEPTH,
190   OPCODE_CLEAR_INDEX,
191   OPCODE_CLEAR_STENCIL,
192   OPCODE_CLIP_PLANE,
193   OPCODE_COLOR_MASK,
194   OPCODE_COLOR_MATERIAL,
195   OPCODE_COLOR_TABLE,
196   OPCODE_COLOR_TABLE_PARAMETER_FV,
197   OPCODE_COLOR_TABLE_PARAMETER_IV,
198   OPCODE_COLOR_SUB_TABLE,
199   OPCODE_CONVOLUTION_FILTER_1D,
200   OPCODE_CONVOLUTION_FILTER_2D,
201   OPCODE_CONVOLUTION_PARAMETER_I,
202   OPCODE_CONVOLUTION_PARAMETER_IV,
203   OPCODE_CONVOLUTION_PARAMETER_F,
204   OPCODE_CONVOLUTION_PARAMETER_FV,
205   OPCODE_COPY_COLOR_SUB_TABLE,
206   OPCODE_COPY_COLOR_TABLE,
207   OPCODE_COPY_PIXELS,
208   OPCODE_COPY_TEX_IMAGE1D,
209   OPCODE_COPY_TEX_IMAGE2D,
210   OPCODE_COPY_TEX_SUB_IMAGE1D,
211   OPCODE_COPY_TEX_SUB_IMAGE2D,
212   OPCODE_COPY_TEX_SUB_IMAGE3D,
213   OPCODE_CULL_FACE,
214   OPCODE_DEPTH_FUNC,
215   OPCODE_DEPTH_MASK,
216   OPCODE_DEPTH_RANGE,
217   OPCODE_DISABLE,
218   OPCODE_DRAW_BUFFER,
219   OPCODE_DRAW_PIXELS,
220   OPCODE_ENABLE,
221   OPCODE_EVALMESH1,
222   OPCODE_EVALMESH2,
223   OPCODE_FOG,
224   OPCODE_FRONT_FACE,
225   OPCODE_FRUSTUM,
226   OPCODE_HINT,
227   OPCODE_HISTOGRAM,
228   OPCODE_INDEX_MASK,
229   OPCODE_INIT_NAMES,
230   OPCODE_LIGHT,
231   OPCODE_LIGHT_MODEL,
232   OPCODE_LINE_STIPPLE,
233   OPCODE_LINE_WIDTH,
234   OPCODE_LIST_BASE,
235   OPCODE_LOAD_IDENTITY,
236   OPCODE_LOAD_MATRIX,
237   OPCODE_LOAD_NAME,
238   OPCODE_LOGIC_OP,
239   OPCODE_MAP1,
240   OPCODE_MAP2,
241   OPCODE_MAPGRID1,
242   OPCODE_MAPGRID2,
243   OPCODE_MATRIX_MODE,
244   OPCODE_MIN_MAX,
245   OPCODE_MULT_MATRIX,
246   OPCODE_ORTHO,
247   OPCODE_PASSTHROUGH,
248   OPCODE_PIXEL_MAP,
249   OPCODE_PIXEL_TRANSFER,
250   OPCODE_PIXEL_ZOOM,
251   OPCODE_POINT_SIZE,
252   OPCODE_POINT_PARAMETERS,
253   OPCODE_POLYGON_MODE,
254   OPCODE_POLYGON_STIPPLE,
255   OPCODE_POLYGON_OFFSET,
256   OPCODE_POP_ATTRIB,
257   OPCODE_POP_MATRIX,
258   OPCODE_POP_NAME,
259   OPCODE_PRIORITIZE_TEXTURE,
260   OPCODE_PUSH_ATTRIB,
261   OPCODE_PUSH_MATRIX,
262   OPCODE_PUSH_NAME,
263   OPCODE_RASTER_POS,
264   OPCODE_READ_BUFFER,
265   OPCODE_RESET_HISTOGRAM,
266   OPCODE_RESET_MIN_MAX,
267   OPCODE_ROTATE,
268   OPCODE_SCALE,
269   OPCODE_SCISSOR,
270   OPCODE_SELECT_TEXTURE_SGIS,
271   OPCODE_SELECT_TEXTURE_COORD_SET,
272   OPCODE_SHADE_MODEL,
273   OPCODE_STENCIL_FUNC,
274   OPCODE_STENCIL_MASK,
275   OPCODE_STENCIL_OP,
276   OPCODE_TEXENV,
277   OPCODE_TEXGEN,
278   OPCODE_TEXPARAMETER,
279   OPCODE_TEX_IMAGE1D,
280   OPCODE_TEX_IMAGE2D,
281   OPCODE_TEX_IMAGE3D,
282   OPCODE_TEX_SUB_IMAGE1D,
283   OPCODE_TEX_SUB_IMAGE2D,
284   OPCODE_TEX_SUB_IMAGE3D,
285   OPCODE_TRANSLATE,
286   OPCODE_VIEWPORT,
287   OPCODE_WINDOW_POS,
288   /* GL_ARB_multitexture */
289   OPCODE_ACTIVE_TEXTURE,
290   /* GL_ARB_texture_compression */
291   OPCODE_COMPRESSED_TEX_IMAGE_1D,
292   OPCODE_COMPRESSED_TEX_IMAGE_2D,
293   OPCODE_COMPRESSED_TEX_IMAGE_3D,
294   OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
295   OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
296   OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
297   /* GL_ARB_multisample */
298   OPCODE_SAMPLE_COVERAGE,
299   /* GL_ARB_window_pos */
300   OPCODE_WINDOW_POS_ARB,
301   /* GL_NV_vertex_program */
302   OPCODE_BIND_PROGRAM_NV,
303   OPCODE_EXECUTE_PROGRAM_NV,
304   OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
305   OPCODE_LOAD_PROGRAM_NV,
306   OPCODE_TRACK_MATRIX_NV,
307   /* GL_NV_fragment_program */
308   OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
309   OPCODE_PROGRAM_NAMED_PARAMETER_NV,
310   /* GL_EXT_stencil_two_side */
311   OPCODE_ACTIVE_STENCIL_FACE_EXT,
312   /* GL_EXT_depth_bounds_test */
313   OPCODE_DEPTH_BOUNDS_EXT,
314   /* GL_ARB_vertex/fragment_program */
315   OPCODE_PROGRAM_STRING_ARB,
316   OPCODE_PROGRAM_ENV_PARAMETER_ARB,
317   /* GL_ARB_occlusion_query */
318   OPCODE_BEGIN_QUERY_ARB,
319   OPCODE_END_QUERY_ARB,
320   /* GL_ARB_draw_buffers */
321   OPCODE_DRAW_BUFFERS_ARB,
322   /* GL_ATI_fragment_shader */
323   OPCODE_BIND_FRAGMENT_SHADER_ATI,
324   OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
325   /* OpenGL 2.0 */
326   OPCODE_STENCIL_FUNC_SEPARATE,
327   OPCODE_STENCIL_OP_SEPARATE,
328   OPCODE_STENCIL_MASK_SEPARATE,
329
330   /* GL_EXT_framebuffer_blit */
331   OPCODE_BLIT_FRAMEBUFFER,
332
333   /* Vertex attributes -- fallback for when optimized display
334    * list build isn't active.
335    */
336   OPCODE_ATTR_1F_NV,
337   OPCODE_ATTR_2F_NV,
338   OPCODE_ATTR_3F_NV,
339   OPCODE_ATTR_4F_NV,
340   OPCODE_ATTR_1F_ARB,
341   OPCODE_ATTR_2F_ARB,
342   OPCODE_ATTR_3F_ARB,
343   OPCODE_ATTR_4F_ARB,
344   OPCODE_MATERIAL,
345   OPCODE_BEGIN,
346   OPCODE_END,
347   OPCODE_RECTF,
348   OPCODE_EVAL_C1,
349   OPCODE_EVAL_C2,
350   OPCODE_EVAL_P1,
351   OPCODE_EVAL_P2,
352
353   /* The following three are meta instructions */
354   OPCODE_ERROR,                /* raise compiled-in error */
355   OPCODE_CONTINUE,
356   OPCODE_END_OF_LIST,
357   OPCODE_EXT_0
358} OpCode;
359
360
361
362/**
363 * Display list node.
364 *
365 * Display list instructions are stored as sequences of "nodes".  Nodes
366 * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
367 * are linked together with a pointer.
368 *
369 * Each instruction in the display list is stored as a sequence of
370 * contiguous nodes in memory.
371 * Each node is the union of a variety of data types.
372 */
373union node
374{
375   OpCode opcode;
376   GLboolean b;
377   GLbitfield bf;
378   GLubyte ub;
379   GLshort s;
380   GLushort us;
381   GLint i;
382   GLuint ui;
383   GLenum e;
384   GLfloat f;
385   GLvoid *data;
386   void *next;                  /* If prev node's opcode==OPCODE_CONTINUE */
387};
388
389
390/**
391 * How many nodes to allocate at a time.
392 *
393 * \note Reduced now that we hold vertices etc. elsewhere.
394 */
395#define BLOCK_SIZE 256
396
397
398
399/**
400 * Number of nodes of storage needed for each instruction.
401 * Sizes for dynamically allocated opcodes are stored in the context struct.
402 */
403static GLuint InstSize[OPCODE_END_OF_LIST + 1];
404
405void mesa_print_display_list(GLuint list);
406
407
408/**********************************************************************/
409/*****                           Private                          *****/
410/**********************************************************************/
411
412
413/**
414 * Make an empty display list.  This is used by glGenLists() to
415 * reserve display list IDs.
416 */
417static struct mesa_display_list *
418make_list(GLuint list, GLuint count)
419{
420   struct mesa_display_list *dlist = CALLOC_STRUCT(mesa_display_list);
421   dlist->id = list;
422   dlist->node = (Node *) _mesa_malloc(sizeof(Node) * count);
423   dlist->node[0].opcode = OPCODE_END_OF_LIST;
424   return dlist;
425}
426
427
428/**
429 * Lookup function to just encapsulate casting.
430 */
431static INLINE struct mesa_display_list *
432lookup_list(GLcontext *ctx, GLuint list)
433{
434   return (struct mesa_display_list *)
435      _mesa_HashLookup(ctx->Shared->DisplayList, list);
436}
437
438
439
440/**
441 * Delete the named display list, but don't remove from hash table.
442 * \param dlist - display list pointer
443 */
444void
445_mesa_delete_list(GLcontext *ctx, struct mesa_display_list *dlist)
446{
447   Node *n, *block;
448   GLboolean done;
449
450   n = block = dlist->node;
451
452   done = block ? GL_FALSE : GL_TRUE;
453   while (!done) {
454
455      /* check for extension opcodes first */
456
457      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
458      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
459         ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
460         n += ctx->ListExt.Opcode[i].Size;
461      }
462      else {
463         switch (n[0].opcode) {
464            /* for some commands, we need to free malloc'd memory */
465         case OPCODE_MAP1:
466            _mesa_free(n[6].data);
467            n += InstSize[n[0].opcode];
468            break;
469         case OPCODE_MAP2:
470            _mesa_free(n[10].data);
471            n += InstSize[n[0].opcode];
472            break;
473         case OPCODE_DRAW_PIXELS:
474            _mesa_free(n[5].data);
475            n += InstSize[n[0].opcode];
476            break;
477         case OPCODE_BITMAP:
478            _mesa_free(n[7].data);
479            n += InstSize[n[0].opcode];
480            break;
481         case OPCODE_COLOR_TABLE:
482            _mesa_free(n[6].data);
483            n += InstSize[n[0].opcode];
484            break;
485         case OPCODE_COLOR_SUB_TABLE:
486            _mesa_free(n[6].data);
487            n += InstSize[n[0].opcode];
488            break;
489         case OPCODE_CONVOLUTION_FILTER_1D:
490            _mesa_free(n[6].data);
491            n += InstSize[n[0].opcode];
492            break;
493         case OPCODE_CONVOLUTION_FILTER_2D:
494            _mesa_free(n[7].data);
495            n += InstSize[n[0].opcode];
496            break;
497         case OPCODE_POLYGON_STIPPLE:
498            _mesa_free(n[1].data);
499            n += InstSize[n[0].opcode];
500            break;
501         case OPCODE_TEX_IMAGE1D:
502            _mesa_free(n[8].data);
503            n += InstSize[n[0].opcode];
504            break;
505         case OPCODE_TEX_IMAGE2D:
506            _mesa_free(n[9].data);
507            n += InstSize[n[0].opcode];
508            break;
509         case OPCODE_TEX_IMAGE3D:
510            _mesa_free(n[10].data);
511            n += InstSize[n[0].opcode];
512            break;
513         case OPCODE_TEX_SUB_IMAGE1D:
514            _mesa_free(n[7].data);
515            n += InstSize[n[0].opcode];
516            break;
517         case OPCODE_TEX_SUB_IMAGE2D:
518            _mesa_free(n[9].data);
519            n += InstSize[n[0].opcode];
520            break;
521         case OPCODE_TEX_SUB_IMAGE3D:
522            _mesa_free(n[11].data);
523            n += InstSize[n[0].opcode];
524            break;
525         case OPCODE_COMPRESSED_TEX_IMAGE_1D:
526            _mesa_free(n[7].data);
527            n += InstSize[n[0].opcode];
528            break;
529         case OPCODE_COMPRESSED_TEX_IMAGE_2D:
530            _mesa_free(n[8].data);
531            n += InstSize[n[0].opcode];
532            break;
533         case OPCODE_COMPRESSED_TEX_IMAGE_3D:
534            _mesa_free(n[9].data);
535            n += InstSize[n[0].opcode];
536            break;
537         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
538            _mesa_free(n[7].data);
539            n += InstSize[n[0].opcode];
540            break;
541         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
542            _mesa_free(n[9].data);
543            n += InstSize[n[0].opcode];
544            break;
545         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
546            _mesa_free(n[11].data);
547            n += InstSize[n[0].opcode];
548            break;
549#if FEATURE_NV_vertex_program
550         case OPCODE_LOAD_PROGRAM_NV:
551            _mesa_free(n[4].data);      /* program string */
552            n += InstSize[n[0].opcode];
553            break;
554         case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
555            _mesa_free(n[2].data);      /* array of program ids */
556            n += InstSize[n[0].opcode];
557            break;
558#endif
559#if FEATURE_NV_fragment_program
560         case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
561            _mesa_free(n[3].data);      /* parameter name */
562            n += InstSize[n[0].opcode];
563            break;
564#endif
565#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
566         case OPCODE_PROGRAM_STRING_ARB:
567            _mesa_free(n[4].data);      /* program string */
568            n += InstSize[n[0].opcode];
569            break;
570#endif
571         case OPCODE_CONTINUE:
572            n = (Node *) n[1].next;
573            _mesa_free(block);
574            block = n;
575            break;
576         case OPCODE_END_OF_LIST:
577            _mesa_free(block);
578            done = GL_TRUE;
579            break;
580         default:
581            /* Most frequent case */
582            n += InstSize[n[0].opcode];
583            break;
584         }
585      }
586   }
587
588   _mesa_free(dlist);
589}
590
591
592/**
593 * Destroy a display list and remove from hash table.
594 * \param list - display list number
595 */
596static void
597destroy_list(GLcontext *ctx, GLuint list)
598{
599   struct mesa_display_list *dlist;
600
601   if (list == 0)
602      return;
603
604   dlist = lookup_list(ctx, list);
605   if (!dlist)
606      return;
607
608   _mesa_delete_list(ctx, dlist);
609   _mesa_HashRemove(ctx->Shared->DisplayList, list);
610}
611
612
613/*
614 * Translate the nth element of list from <type> to GLint.
615 */
616static GLint
617translate_id(GLsizei n, GLenum type, const GLvoid * list)
618{
619   GLbyte *bptr;
620   GLubyte *ubptr;
621   GLshort *sptr;
622   GLushort *usptr;
623   GLint *iptr;
624   GLuint *uiptr;
625   GLfloat *fptr;
626
627   switch (type) {
628   case GL_BYTE:
629      bptr = (GLbyte *) list;
630      return (GLint) bptr[n];
631   case GL_UNSIGNED_BYTE:
632      ubptr = (GLubyte *) list;
633      return (GLint) ubptr[n];
634   case GL_SHORT:
635      sptr = (GLshort *) list;
636      return (GLint) sptr[n];
637   case GL_UNSIGNED_SHORT:
638      usptr = (GLushort *) list;
639      return (GLint) usptr[n];
640   case GL_INT:
641      iptr = (GLint *) list;
642      return iptr[n];
643   case GL_UNSIGNED_INT:
644      uiptr = (GLuint *) list;
645      return (GLint) uiptr[n];
646   case GL_FLOAT:
647      fptr = (GLfloat *) list;
648      return (GLint) FLOORF(fptr[n]);
649   case GL_2_BYTES:
650      ubptr = ((GLubyte *) list) + 2 * n;
651      return (GLint) ubptr[0] * 256
652           + (GLint) ubptr[1];
653   case GL_3_BYTES:
654      ubptr = ((GLubyte *) list) + 3 * n;
655      return (GLint) ubptr[0] * 65536
656           + (GLint) ubptr[1] * 256
657           + (GLint) ubptr[2];
658   case GL_4_BYTES:
659      ubptr = ((GLubyte *) list) + 4 * n;
660      return (GLint) ubptr[0] * 16777216
661           + (GLint) ubptr[1] * 65536
662           + (GLint) ubptr[2] * 256
663           + (GLint) ubptr[3];
664   default:
665      return 0;
666   }
667}
668
669
670
671
672/**********************************************************************/
673/*****                        Public                              *****/
674/**********************************************************************/
675
676/**
677 * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
678 * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
679 */
680static GLvoid *
681unpack_image(GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth,
682             GLenum format, GLenum type, const GLvoid * pixels,
683             const struct gl_pixelstore_attrib *unpack)
684{
685   if (unpack->BufferObj->Name == 0) {
686      /* no PBO */
687      return _mesa_unpack_image(dimensions, width, height, depth, format,
688                                type, pixels, unpack);
689   }
690   else
691      if (_mesa_validate_pbo_access
692          (dimensions, unpack, width, height, depth, format, type, pixels)) {
693      const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
694      return _mesa_unpack_image(dimensions, width, height, depth, format,
695                                type, src, unpack);
696   }
697   /* bad access! */
698   return NULL;
699}
700
701
702/**
703 * Allocate space for a display list instruction.
704 * \param opcode  the instruction opcode (OPCODE_* value)
705 * \param size   instruction size in bytes, not counting opcode.
706 * \return pointer to the usable data area (not including the internal
707 *         opcode).
708 */
709void *
710_mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint bytes)
711{
712   const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
713   Node *n;
714
715   if (opcode < (GLuint) OPCODE_EXT_0) {
716      if (InstSize[opcode] == 0) {
717         /* save instruction size now */
718         InstSize[opcode] = numNodes;
719      }
720      else {
721         /* make sure instruction size agrees */
722         ASSERT(numNodes == InstSize[opcode]);
723      }
724   }
725
726   if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) {
727      /* This block is full.  Allocate a new block and chain to it */
728      Node *newblock;
729      n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
730      n[0].opcode = OPCODE_CONTINUE;
731      newblock = (Node *) _mesa_malloc(sizeof(Node) * BLOCK_SIZE);
732      if (!newblock) {
733         _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
734         return NULL;
735      }
736      n[1].next = (Node *) newblock;
737      ctx->ListState.CurrentBlock = newblock;
738      ctx->ListState.CurrentPos = 0;
739   }
740
741   n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
742   ctx->ListState.CurrentPos += numNodes;
743
744   n[0].opcode = (OpCode) opcode;
745
746   return (void *) (n + 1);     /* return ptr to node following opcode */
747}
748
749
750/**
751 * This function allows modules and drivers to get their own opcodes
752 * for extending display list functionality.
753 * \param ctx  the rendering context
754 * \param size  number of bytes for storing the new display list command
755 * \param execute  function to execute the new display list command
756 * \param destroy  function to destroy the new display list command
757 * \param print  function to print the new display list command
758 * \return  the new opcode number or -1 if error
759 */
760GLint
761_mesa_alloc_opcode(GLcontext *ctx,
762                   GLuint size,
763                   void (*execute) (GLcontext *, void *),
764                   void (*destroy) (GLcontext *, void *),
765                   void (*print) (GLcontext *, void *))
766{
767   if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
768      const GLuint i = ctx->ListExt.NumOpcodes++;
769      ctx->ListExt.Opcode[i].Size =
770         1 + (size + sizeof(Node) - 1) / sizeof(Node);
771      ctx->ListExt.Opcode[i].Execute = execute;
772      ctx->ListExt.Opcode[i].Destroy = destroy;
773      ctx->ListExt.Opcode[i].Print = print;
774      return i + OPCODE_EXT_0;
775   }
776   return -1;
777}
778
779
780
781/**
782 * Allocate display list instruction.  Returns Node ptr to where the opcode
783 * is stored.
784 *   - nParams is the number of function parameters
785 *   - return value a pointer to sizeof(Node) before the actual
786 *     usable data area.
787 */
788#define ALLOC_INSTRUCTION(CTX, OPCODE, NPARAMS) \
789    ((Node *)_mesa_alloc_instruction(CTX, OPCODE, (NPARAMS)*sizeof(Node)) - 1)
790
791
792
793/*
794 * Display List compilation functions
795 */
796static void GLAPIENTRY
797save_Accum(GLenum op, GLfloat value)
798{
799   GET_CURRENT_CONTEXT(ctx);
800   Node *n;
801   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
802   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACCUM, 2);
803   if (n) {
804      n[1].e = op;
805      n[2].f = value;
806   }
807   if (ctx->ExecuteFlag) {
808      CALL_Accum(ctx->Exec, (op, value));
809   }
810}
811
812
813static void GLAPIENTRY
814save_AlphaFunc(GLenum func, GLclampf ref)
815{
816   GET_CURRENT_CONTEXT(ctx);
817   Node *n;
818   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
819   n = ALLOC_INSTRUCTION(ctx, OPCODE_ALPHA_FUNC, 2);
820   if (n) {
821      n[1].e = func;
822      n[2].f = (GLfloat) ref;
823   }
824   if (ctx->ExecuteFlag) {
825      CALL_AlphaFunc(ctx->Exec, (func, ref));
826   }
827}
828
829
830static void GLAPIENTRY
831save_BindTexture(GLenum target, GLuint texture)
832{
833   GET_CURRENT_CONTEXT(ctx);
834   Node *n;
835   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
836   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_TEXTURE, 2);
837   if (n) {
838      n[1].e = target;
839      n[2].ui = texture;
840   }
841   if (ctx->ExecuteFlag) {
842      CALL_BindTexture(ctx->Exec, (target, texture));
843   }
844}
845
846
847static void GLAPIENTRY
848save_Bitmap(GLsizei width, GLsizei height,
849            GLfloat xorig, GLfloat yorig,
850            GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
851{
852   GET_CURRENT_CONTEXT(ctx);
853   GLvoid *image = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack);
854   Node *n;
855   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
856   n = ALLOC_INSTRUCTION(ctx, OPCODE_BITMAP, 7);
857   if (n) {
858      n[1].i = (GLint) width;
859      n[2].i = (GLint) height;
860      n[3].f = xorig;
861      n[4].f = yorig;
862      n[5].f = xmove;
863      n[6].f = ymove;
864      n[7].data = image;
865   }
866   else if (image) {
867      _mesa_free(image);
868   }
869   if (ctx->ExecuteFlag) {
870      CALL_Bitmap(ctx->Exec, (width, height,
871                              xorig, yorig, xmove, ymove, pixels));
872   }
873}
874
875
876static void GLAPIENTRY
877save_BlendEquation(GLenum mode)
878{
879   GET_CURRENT_CONTEXT(ctx);
880   Node *n;
881   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
882   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_EQUATION, 1);
883   if (n) {
884      n[1].e = mode;
885   }
886   if (ctx->ExecuteFlag) {
887      CALL_BlendEquation(ctx->Exec, (mode));
888   }
889}
890
891
892static void GLAPIENTRY
893save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
894{
895   GET_CURRENT_CONTEXT(ctx);
896   Node *n;
897   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
898   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
899   if (n) {
900      n[1].e = modeRGB;
901      n[2].e = modeA;
902   }
903   if (ctx->ExecuteFlag) {
904      CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA));
905   }
906}
907
908
909static void GLAPIENTRY
910save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
911                          GLenum sfactorA, GLenum dfactorA)
912{
913   GET_CURRENT_CONTEXT(ctx);
914   Node *n;
915   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
916   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
917   if (n) {
918      n[1].e = sfactorRGB;
919      n[2].e = dfactorRGB;
920      n[3].e = sfactorA;
921      n[4].e = dfactorA;
922   }
923   if (ctx->ExecuteFlag) {
924      CALL_BlendFuncSeparateEXT(ctx->Exec,
925                                (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
926   }
927}
928
929
930static void GLAPIENTRY
931save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
932{
933   save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
934}
935
936
937static void GLAPIENTRY
938save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
939{
940   GET_CURRENT_CONTEXT(ctx);
941   Node *n;
942   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
943   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLEND_COLOR, 4);
944   if (n) {
945      n[1].f = red;
946      n[2].f = green;
947      n[3].f = blue;
948      n[4].f = alpha;
949   }
950   if (ctx->ExecuteFlag) {
951      CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
952   }
953}
954
955
956void GLAPIENTRY
957_mesa_save_CallList(GLuint list)
958{
959   GET_CURRENT_CONTEXT(ctx);
960   Node *n;
961   SAVE_FLUSH_VERTICES(ctx);
962
963   n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST, 1);
964   if (n) {
965      n[1].ui = list;
966   }
967
968   /* After this, we don't know what begin/end state we're in:
969    */
970   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
971
972   if (ctx->ExecuteFlag) {
973      CALL_CallList(ctx->Exec, (list));
974   }
975}
976
977
978void GLAPIENTRY
979_mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
980{
981   GET_CURRENT_CONTEXT(ctx);
982   GLint i;
983   GLboolean typeErrorFlag;
984
985   SAVE_FLUSH_VERTICES(ctx);
986
987   switch (type) {
988   case GL_BYTE:
989   case GL_UNSIGNED_BYTE:
990   case GL_SHORT:
991   case GL_UNSIGNED_SHORT:
992   case GL_INT:
993   case GL_UNSIGNED_INT:
994   case GL_FLOAT:
995   case GL_2_BYTES:
996   case GL_3_BYTES:
997   case GL_4_BYTES:
998      typeErrorFlag = GL_FALSE;
999      break;
1000   default:
1001      typeErrorFlag = GL_TRUE;
1002   }
1003
1004   for (i = 0; i < n; i++) {
1005      GLint list = translate_id(i, type, lists);
1006      Node *n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST_OFFSET, 2);
1007      if (n) {
1008         n[1].i = list;
1009         n[2].b = typeErrorFlag;
1010      }
1011   }
1012
1013   /* After this, we don't know what begin/end state we're in:
1014    */
1015   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1016
1017   if (ctx->ExecuteFlag) {
1018      CALL_CallLists(ctx->Exec, (n, type, lists));
1019   }
1020}
1021
1022
1023static void GLAPIENTRY
1024save_Clear(GLbitfield mask)
1025{
1026   GET_CURRENT_CONTEXT(ctx);
1027   Node *n;
1028   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1029   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR, 1);
1030   if (n) {
1031      n[1].bf = mask;
1032   }
1033   if (ctx->ExecuteFlag) {
1034      CALL_Clear(ctx->Exec, (mask));
1035   }
1036}
1037
1038
1039static void GLAPIENTRY
1040save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1041{
1042   GET_CURRENT_CONTEXT(ctx);
1043   Node *n;
1044   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1045   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_ACCUM, 4);
1046   if (n) {
1047      n[1].f = red;
1048      n[2].f = green;
1049      n[3].f = blue;
1050      n[4].f = alpha;
1051   }
1052   if (ctx->ExecuteFlag) {
1053      CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
1054   }
1055}
1056
1057
1058static void GLAPIENTRY
1059save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1060{
1061   GET_CURRENT_CONTEXT(ctx);
1062   Node *n;
1063   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1064   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_COLOR, 4);
1065   if (n) {
1066      n[1].f = red;
1067      n[2].f = green;
1068      n[3].f = blue;
1069      n[4].f = alpha;
1070   }
1071   if (ctx->ExecuteFlag) {
1072      CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
1073   }
1074}
1075
1076
1077static void GLAPIENTRY
1078save_ClearDepth(GLclampd depth)
1079{
1080   GET_CURRENT_CONTEXT(ctx);
1081   Node *n;
1082   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1083   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_DEPTH, 1);
1084   if (n) {
1085      n[1].f = (GLfloat) depth;
1086   }
1087   if (ctx->ExecuteFlag) {
1088      CALL_ClearDepth(ctx->Exec, (depth));
1089   }
1090}
1091
1092
1093static void GLAPIENTRY
1094save_ClearIndex(GLfloat c)
1095{
1096   GET_CURRENT_CONTEXT(ctx);
1097   Node *n;
1098   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1099   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_INDEX, 1);
1100   if (n) {
1101      n[1].f = c;
1102   }
1103   if (ctx->ExecuteFlag) {
1104      CALL_ClearIndex(ctx->Exec, (c));
1105   }
1106}
1107
1108
1109static void GLAPIENTRY
1110save_ClearStencil(GLint s)
1111{
1112   GET_CURRENT_CONTEXT(ctx);
1113   Node *n;
1114   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1115   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLEAR_STENCIL, 1);
1116   if (n) {
1117      n[1].i = s;
1118   }
1119   if (ctx->ExecuteFlag) {
1120      CALL_ClearStencil(ctx->Exec, (s));
1121   }
1122}
1123
1124
1125static void GLAPIENTRY
1126save_ClipPlane(GLenum plane, const GLdouble * equ)
1127{
1128   GET_CURRENT_CONTEXT(ctx);
1129   Node *n;
1130   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1131   n = ALLOC_INSTRUCTION(ctx, OPCODE_CLIP_PLANE, 5);
1132   if (n) {
1133      n[1].e = plane;
1134      n[2].f = (GLfloat) equ[0];
1135      n[3].f = (GLfloat) equ[1];
1136      n[4].f = (GLfloat) equ[2];
1137      n[5].f = (GLfloat) equ[3];
1138   }
1139   if (ctx->ExecuteFlag) {
1140      CALL_ClipPlane(ctx->Exec, (plane, equ));
1141   }
1142}
1143
1144
1145
1146static void GLAPIENTRY
1147save_ColorMask(GLboolean red, GLboolean green,
1148               GLboolean blue, GLboolean alpha)
1149{
1150   GET_CURRENT_CONTEXT(ctx);
1151   Node *n;
1152   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1153   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MASK, 4);
1154   if (n) {
1155      n[1].b = red;
1156      n[2].b = green;
1157      n[3].b = blue;
1158      n[4].b = alpha;
1159   }
1160   if (ctx->ExecuteFlag) {
1161      CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
1162   }
1163}
1164
1165
1166static void GLAPIENTRY
1167save_ColorMaterial(GLenum face, GLenum mode)
1168{
1169   GET_CURRENT_CONTEXT(ctx);
1170   Node *n;
1171   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1172
1173   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_MATERIAL, 2);
1174   if (n) {
1175      n[1].e = face;
1176      n[2].e = mode;
1177   }
1178   if (ctx->ExecuteFlag) {
1179      CALL_ColorMaterial(ctx->Exec, (face, mode));
1180   }
1181}
1182
1183
1184static void GLAPIENTRY
1185save_ColorTable(GLenum target, GLenum internalFormat,
1186                GLsizei width, GLenum format, GLenum type,
1187                const GLvoid * table)
1188{
1189   GET_CURRENT_CONTEXT(ctx);
1190   if (_mesa_is_proxy_texture(target)) {
1191      /* execute immediately */
1192      CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1193                                  format, type, table));
1194   }
1195   else {
1196      GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
1197                                   &ctx->Unpack);
1198      Node *n;
1199      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1200      n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE, 6);
1201      if (n) {
1202         n[1].e = target;
1203         n[2].e = internalFormat;
1204         n[3].i = width;
1205         n[4].e = format;
1206         n[5].e = type;
1207         n[6].data = image;
1208      }
1209      else if (image) {
1210         _mesa_free(image);
1211      }
1212      if (ctx->ExecuteFlag) {
1213         CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1214                                     format, type, table));
1215      }
1216   }
1217}
1218
1219
1220
1221static void GLAPIENTRY
1222save_ColorTableParameterfv(GLenum target, GLenum pname,
1223                           const GLfloat *params)
1224{
1225   GET_CURRENT_CONTEXT(ctx);
1226   Node *n;
1227
1228   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1229
1230   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
1231   if (n) {
1232      n[1].e = target;
1233      n[2].e = pname;
1234      n[3].f = params[0];
1235      if (pname == GL_COLOR_TABLE_SGI ||
1236          pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1237          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1238          pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1239         n[4].f = params[1];
1240         n[5].f = params[2];
1241         n[6].f = params[3];
1242      }
1243   }
1244
1245   if (ctx->ExecuteFlag) {
1246      CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params));
1247   }
1248}
1249
1250
1251static void GLAPIENTRY
1252save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1253{
1254   GET_CURRENT_CONTEXT(ctx);
1255   Node *n;
1256
1257   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1258
1259   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
1260   if (n) {
1261      n[1].e = target;
1262      n[2].e = pname;
1263      n[3].i = params[0];
1264      if (pname == GL_COLOR_TABLE_SGI ||
1265          pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1266          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
1267          pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1268         n[4].i = params[1];
1269         n[5].i = params[2];
1270         n[6].i = params[3];
1271      }
1272   }
1273
1274   if (ctx->ExecuteFlag) {
1275      CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params));
1276   }
1277}
1278
1279
1280
1281static void GLAPIENTRY
1282save_ColorSubTable(GLenum target, GLsizei start, GLsizei count,
1283                   GLenum format, GLenum type, const GLvoid * table)
1284{
1285   GET_CURRENT_CONTEXT(ctx);
1286   GLvoid *image = unpack_image(1, count, 1, 1, format, type, table,
1287                                &ctx->Unpack);
1288   Node *n;
1289   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1290   n = ALLOC_INSTRUCTION(ctx, OPCODE_COLOR_SUB_TABLE, 6);
1291   if (n) {
1292      n[1].e = target;
1293      n[2].i = start;
1294      n[3].i = count;
1295      n[4].e = format;
1296      n[5].e = type;
1297      n[6].data = image;
1298   }
1299   else if (image) {
1300      _mesa_free(image);
1301   }
1302   if (ctx->ExecuteFlag) {
1303      CALL_ColorSubTable(ctx->Exec,
1304                         (target, start, count, format, type, table));
1305   }
1306}
1307
1308
1309static void GLAPIENTRY
1310save_CopyColorSubTable(GLenum target, GLsizei start,
1311                       GLint x, GLint y, GLsizei width)
1312{
1313   GET_CURRENT_CONTEXT(ctx);
1314   Node *n;
1315
1316   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1317   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
1318   if (n) {
1319      n[1].e = target;
1320      n[2].i = start;
1321      n[3].i = x;
1322      n[4].i = y;
1323      n[5].i = width;
1324   }
1325   if (ctx->ExecuteFlag) {
1326      CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width));
1327   }
1328}
1329
1330
1331static void GLAPIENTRY
1332save_CopyColorTable(GLenum target, GLenum internalformat,
1333                    GLint x, GLint y, GLsizei width)
1334{
1335   GET_CURRENT_CONTEXT(ctx);
1336   Node *n;
1337
1338   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1339   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_COLOR_TABLE, 5);
1340   if (n) {
1341      n[1].e = target;
1342      n[2].e = internalformat;
1343      n[3].i = x;
1344      n[4].i = y;
1345      n[5].i = width;
1346   }
1347   if (ctx->ExecuteFlag) {
1348      CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width));
1349   }
1350}
1351
1352
1353static void GLAPIENTRY
1354save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1355                         GLenum format, GLenum type, const GLvoid * filter)
1356{
1357   GET_CURRENT_CONTEXT(ctx);
1358   GLvoid *image = unpack_image(1, width, 1, 1, format, type, filter,
1359                                &ctx->Unpack);
1360   Node *n;
1361   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1362   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
1363   if (n) {
1364      n[1].e = target;
1365      n[2].e = internalFormat;
1366      n[3].i = width;
1367      n[4].e = format;
1368      n[5].e = type;
1369      n[6].data = image;
1370   }
1371   else if (image) {
1372      _mesa_free(image);
1373   }
1374   if (ctx->ExecuteFlag) {
1375      CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width,
1376                                           format, type, filter));
1377   }
1378}
1379
1380
1381static void GLAPIENTRY
1382save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1383                         GLsizei width, GLsizei height, GLenum format,
1384                         GLenum type, const GLvoid * filter)
1385{
1386   GET_CURRENT_CONTEXT(ctx);
1387   GLvoid *image = unpack_image(2, width, height, 1, format, type, filter,
1388                                &ctx->Unpack);
1389   Node *n;
1390   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1391   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
1392   if (n) {
1393      n[1].e = target;
1394      n[2].e = internalFormat;
1395      n[3].i = width;
1396      n[4].i = height;
1397      n[5].e = format;
1398      n[6].e = type;
1399      n[7].data = image;
1400   }
1401   else if (image) {
1402      _mesa_free(image);
1403   }
1404   if (ctx->ExecuteFlag) {
1405      CALL_ConvolutionFilter2D(ctx->Exec,
1406                               (target, internalFormat, width, height, format,
1407                                type, filter));
1408   }
1409}
1410
1411
1412static void GLAPIENTRY
1413save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1414{
1415   GET_CURRENT_CONTEXT(ctx);
1416   Node *n;
1417   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1418   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
1419   if (n) {
1420      n[1].e = target;
1421      n[2].e = pname;
1422      n[3].i = param;
1423   }
1424   if (ctx->ExecuteFlag) {
1425      CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param));
1426   }
1427}
1428
1429
1430static void GLAPIENTRY
1431save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1432{
1433   GET_CURRENT_CONTEXT(ctx);
1434   Node *n;
1435   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1436   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
1437   if (n) {
1438      n[1].e = target;
1439      n[2].e = pname;
1440      n[3].i = params[0];
1441      if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1442          pname == GL_CONVOLUTION_FILTER_SCALE ||
1443          pname == GL_CONVOLUTION_FILTER_BIAS) {
1444         n[4].i = params[1];
1445         n[5].i = params[2];
1446         n[6].i = params[3];
1447      }
1448      else {
1449         n[4].i = n[5].i = n[6].i = 0;
1450      }
1451   }
1452   if (ctx->ExecuteFlag) {
1453      CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params));
1454   }
1455}
1456
1457
1458static void GLAPIENTRY
1459save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
1460{
1461   GET_CURRENT_CONTEXT(ctx);
1462   Node *n;
1463   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1464   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
1465   if (n) {
1466      n[1].e = target;
1467      n[2].e = pname;
1468      n[3].f = param;
1469   }
1470   if (ctx->ExecuteFlag) {
1471      CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param));
1472   }
1473}
1474
1475
1476static void GLAPIENTRY
1477save_ConvolutionParameterfv(GLenum target, GLenum pname,
1478                            const GLfloat *params)
1479{
1480   GET_CURRENT_CONTEXT(ctx);
1481   Node *n;
1482   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1483   n = ALLOC_INSTRUCTION(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
1484   if (n) {
1485      n[1].e = target;
1486      n[2].e = pname;
1487      n[3].f = params[0];
1488      if (pname == GL_CONVOLUTION_BORDER_COLOR ||
1489          pname == GL_CONVOLUTION_FILTER_SCALE ||
1490          pname == GL_CONVOLUTION_FILTER_BIAS) {
1491         n[4].f = params[1];
1492         n[5].f = params[2];
1493         n[6].f = params[3];
1494      }
1495      else {
1496         n[4].f = n[5].f = n[6].f = 0.0F;
1497      }
1498   }
1499   if (ctx->ExecuteFlag) {
1500      CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params));
1501   }
1502}
1503
1504
1505static void GLAPIENTRY
1506save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
1507{
1508   GET_CURRENT_CONTEXT(ctx);
1509   Node *n;
1510   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1511   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_PIXELS, 5);
1512   if (n) {
1513      n[1].i = x;
1514      n[2].i = y;
1515      n[3].i = (GLint) width;
1516      n[4].i = (GLint) height;
1517      n[5].e = type;
1518   }
1519   if (ctx->ExecuteFlag) {
1520      CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
1521   }
1522}
1523
1524
1525
1526static void GLAPIENTRY
1527save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
1528                    GLint x, GLint y, GLsizei width, GLint border)
1529{
1530   GET_CURRENT_CONTEXT(ctx);
1531   Node *n;
1532   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1533   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
1534   if (n) {
1535      n[1].e = target;
1536      n[2].i = level;
1537      n[3].e = internalformat;
1538      n[4].i = x;
1539      n[5].i = y;
1540      n[6].i = width;
1541      n[7].i = border;
1542   }
1543   if (ctx->ExecuteFlag) {
1544      CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
1545                                      x, y, width, border));
1546   }
1547}
1548
1549
1550static void GLAPIENTRY
1551save_CopyTexImage2D(GLenum target, GLint level,
1552                    GLenum internalformat,
1553                    GLint x, GLint y, GLsizei width,
1554                    GLsizei height, GLint border)
1555{
1556   GET_CURRENT_CONTEXT(ctx);
1557   Node *n;
1558   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1559   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
1560   if (n) {
1561      n[1].e = target;
1562      n[2].i = level;
1563      n[3].e = internalformat;
1564      n[4].i = x;
1565      n[5].i = y;
1566      n[6].i = width;
1567      n[7].i = height;
1568      n[8].i = border;
1569   }
1570   if (ctx->ExecuteFlag) {
1571      CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
1572                                      x, y, width, height, border));
1573   }
1574}
1575
1576
1577
1578static void GLAPIENTRY
1579save_CopyTexSubImage1D(GLenum target, GLint level,
1580                       GLint xoffset, GLint x, GLint y, GLsizei width)
1581{
1582   GET_CURRENT_CONTEXT(ctx);
1583   Node *n;
1584   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1585   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
1586   if (n) {
1587      n[1].e = target;
1588      n[2].i = level;
1589      n[3].i = xoffset;
1590      n[4].i = x;
1591      n[5].i = y;
1592      n[6].i = width;
1593   }
1594   if (ctx->ExecuteFlag) {
1595      CALL_CopyTexSubImage1D(ctx->Exec,
1596                             (target, level, xoffset, x, y, width));
1597   }
1598}
1599
1600
1601static void GLAPIENTRY
1602save_CopyTexSubImage2D(GLenum target, GLint level,
1603                       GLint xoffset, GLint yoffset,
1604                       GLint x, GLint y, GLsizei width, GLint height)
1605{
1606   GET_CURRENT_CONTEXT(ctx);
1607   Node *n;
1608   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1609   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
1610   if (n) {
1611      n[1].e = target;
1612      n[2].i = level;
1613      n[3].i = xoffset;
1614      n[4].i = yoffset;
1615      n[5].i = x;
1616      n[6].i = y;
1617      n[7].i = width;
1618      n[8].i = height;
1619   }
1620   if (ctx->ExecuteFlag) {
1621      CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
1622                                         x, y, width, height));
1623   }
1624}
1625
1626
1627static void GLAPIENTRY
1628save_CopyTexSubImage3D(GLenum target, GLint level,
1629                       GLint xoffset, GLint yoffset, GLint zoffset,
1630                       GLint x, GLint y, GLsizei width, GLint height)
1631{
1632   GET_CURRENT_CONTEXT(ctx);
1633   Node *n;
1634   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1635   n = ALLOC_INSTRUCTION(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
1636   if (n) {
1637      n[1].e = target;
1638      n[2].i = level;
1639      n[3].i = xoffset;
1640      n[4].i = yoffset;
1641      n[5].i = zoffset;
1642      n[6].i = x;
1643      n[7].i = y;
1644      n[8].i = width;
1645      n[9].i = height;
1646   }
1647   if (ctx->ExecuteFlag) {
1648      CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
1649                                         xoffset, yoffset, zoffset,
1650                                         x, y, width, height));
1651   }
1652}
1653
1654
1655static void GLAPIENTRY
1656save_CullFace(GLenum mode)
1657{
1658   GET_CURRENT_CONTEXT(ctx);
1659   Node *n;
1660   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1661   n = ALLOC_INSTRUCTION(ctx, OPCODE_CULL_FACE, 1);
1662   if (n) {
1663      n[1].e = mode;
1664   }
1665   if (ctx->ExecuteFlag) {
1666      CALL_CullFace(ctx->Exec, (mode));
1667   }
1668}
1669
1670
1671static void GLAPIENTRY
1672save_DepthFunc(GLenum func)
1673{
1674   GET_CURRENT_CONTEXT(ctx);
1675   Node *n;
1676   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1677   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_FUNC, 1);
1678   if (n) {
1679      n[1].e = func;
1680   }
1681   if (ctx->ExecuteFlag) {
1682      CALL_DepthFunc(ctx->Exec, (func));
1683   }
1684}
1685
1686
1687static void GLAPIENTRY
1688save_DepthMask(GLboolean mask)
1689{
1690   GET_CURRENT_CONTEXT(ctx);
1691   Node *n;
1692   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1693   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_MASK, 1);
1694   if (n) {
1695      n[1].b = mask;
1696   }
1697   if (ctx->ExecuteFlag) {
1698      CALL_DepthMask(ctx->Exec, (mask));
1699   }
1700}
1701
1702
1703static void GLAPIENTRY
1704save_DepthRange(GLclampd nearval, GLclampd farval)
1705{
1706   GET_CURRENT_CONTEXT(ctx);
1707   Node *n;
1708   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1709   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_RANGE, 2);
1710   if (n) {
1711      n[1].f = (GLfloat) nearval;
1712      n[2].f = (GLfloat) farval;
1713   }
1714   if (ctx->ExecuteFlag) {
1715      CALL_DepthRange(ctx->Exec, (nearval, farval));
1716   }
1717}
1718
1719
1720static void GLAPIENTRY
1721save_Disable(GLenum cap)
1722{
1723   GET_CURRENT_CONTEXT(ctx);
1724   Node *n;
1725   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1726   n = ALLOC_INSTRUCTION(ctx, OPCODE_DISABLE, 1);
1727   if (n) {
1728      n[1].e = cap;
1729   }
1730   if (ctx->ExecuteFlag) {
1731      CALL_Disable(ctx->Exec, (cap));
1732   }
1733}
1734
1735
1736static void GLAPIENTRY
1737save_DrawBuffer(GLenum mode)
1738{
1739   GET_CURRENT_CONTEXT(ctx);
1740   Node *n;
1741   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1742   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFER, 1);
1743   if (n) {
1744      n[1].e = mode;
1745   }
1746   if (ctx->ExecuteFlag) {
1747      CALL_DrawBuffer(ctx->Exec, (mode));
1748   }
1749}
1750
1751
1752static void GLAPIENTRY
1753save_DrawPixels(GLsizei width, GLsizei height,
1754                GLenum format, GLenum type, const GLvoid * pixels)
1755{
1756   GET_CURRENT_CONTEXT(ctx);
1757   GLvoid *image = unpack_image(2, width, height, 1, format, type,
1758                                pixels, &ctx->Unpack);
1759   Node *n;
1760   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1761   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_PIXELS, 5);
1762   if (n) {
1763      n[1].i = width;
1764      n[2].i = height;
1765      n[3].e = format;
1766      n[4].e = type;
1767      n[5].data = image;
1768   }
1769   else if (image) {
1770      _mesa_free(image);
1771   }
1772   if (ctx->ExecuteFlag) {
1773      CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
1774   }
1775}
1776
1777
1778
1779static void GLAPIENTRY
1780save_Enable(GLenum cap)
1781{
1782   GET_CURRENT_CONTEXT(ctx);
1783   Node *n;
1784   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1785   n = ALLOC_INSTRUCTION(ctx, OPCODE_ENABLE, 1);
1786   if (n) {
1787      n[1].e = cap;
1788   }
1789   if (ctx->ExecuteFlag) {
1790      CALL_Enable(ctx->Exec, (cap));
1791   }
1792}
1793
1794
1795
1796static void GLAPIENTRY
1797_mesa_save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
1798{
1799   GET_CURRENT_CONTEXT(ctx);
1800   Node *n;
1801   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1802   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH1, 3);
1803   if (n) {
1804      n[1].e = mode;
1805      n[2].i = i1;
1806      n[3].i = i2;
1807   }
1808   if (ctx->ExecuteFlag) {
1809      CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
1810   }
1811}
1812
1813
1814static void GLAPIENTRY
1815_mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
1816{
1817   GET_CURRENT_CONTEXT(ctx);
1818   Node *n;
1819   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1820   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVALMESH2, 5);
1821   if (n) {
1822      n[1].e = mode;
1823      n[2].i = i1;
1824      n[3].i = i2;
1825      n[4].i = j1;
1826      n[5].i = j2;
1827   }
1828   if (ctx->ExecuteFlag) {
1829      CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
1830   }
1831}
1832
1833
1834
1835
1836static void GLAPIENTRY
1837save_Fogfv(GLenum pname, const GLfloat *params)
1838{
1839   GET_CURRENT_CONTEXT(ctx);
1840   Node *n;
1841   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1842   n = ALLOC_INSTRUCTION(ctx, OPCODE_FOG, 5);
1843   if (n) {
1844      n[1].e = pname;
1845      n[2].f = params[0];
1846      n[3].f = params[1];
1847      n[4].f = params[2];
1848      n[5].f = params[3];
1849   }
1850   if (ctx->ExecuteFlag) {
1851      CALL_Fogfv(ctx->Exec, (pname, params));
1852   }
1853}
1854
1855
1856static void GLAPIENTRY
1857save_Fogf(GLenum pname, GLfloat param)
1858{
1859   save_Fogfv(pname, &param);
1860}
1861
1862
1863static void GLAPIENTRY
1864save_Fogiv(GLenum pname, const GLint *params)
1865{
1866   GLfloat p[4];
1867   switch (pname) {
1868   case GL_FOG_MODE:
1869   case GL_FOG_DENSITY:
1870   case GL_FOG_START:
1871   case GL_FOG_END:
1872   case GL_FOG_INDEX:
1873      p[0] = (GLfloat) *params;
1874      break;
1875   case GL_FOG_COLOR:
1876      p[0] = INT_TO_FLOAT(params[0]);
1877      p[1] = INT_TO_FLOAT(params[1]);
1878      p[2] = INT_TO_FLOAT(params[2]);
1879      p[3] = INT_TO_FLOAT(params[3]);
1880      break;
1881   default:
1882      /* Error will be caught later in gl_Fogfv */
1883      ;
1884   }
1885   save_Fogfv(pname, p);
1886}
1887
1888
1889static void GLAPIENTRY
1890save_Fogi(GLenum pname, GLint param)
1891{
1892   save_Fogiv(pname, &param);
1893}
1894
1895
1896static void GLAPIENTRY
1897save_FrontFace(GLenum mode)
1898{
1899   GET_CURRENT_CONTEXT(ctx);
1900   Node *n;
1901   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1902   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRONT_FACE, 1);
1903   if (n) {
1904      n[1].e = mode;
1905   }
1906   if (ctx->ExecuteFlag) {
1907      CALL_FrontFace(ctx->Exec, (mode));
1908   }
1909}
1910
1911
1912static void GLAPIENTRY
1913save_Frustum(GLdouble left, GLdouble right,
1914             GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
1915{
1916   GET_CURRENT_CONTEXT(ctx);
1917   Node *n;
1918   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1919   n = ALLOC_INSTRUCTION(ctx, OPCODE_FRUSTUM, 6);
1920   if (n) {
1921      n[1].f = (GLfloat) left;
1922      n[2].f = (GLfloat) right;
1923      n[3].f = (GLfloat) bottom;
1924      n[4].f = (GLfloat) top;
1925      n[5].f = (GLfloat) nearval;
1926      n[6].f = (GLfloat) farval;
1927   }
1928   if (ctx->ExecuteFlag) {
1929      CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
1930   }
1931}
1932
1933
1934static void GLAPIENTRY
1935save_Hint(GLenum target, GLenum mode)
1936{
1937   GET_CURRENT_CONTEXT(ctx);
1938   Node *n;
1939   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1940   n = ALLOC_INSTRUCTION(ctx, OPCODE_HINT, 2);
1941   if (n) {
1942      n[1].e = target;
1943      n[2].e = mode;
1944   }
1945   if (ctx->ExecuteFlag) {
1946      CALL_Hint(ctx->Exec, (target, mode));
1947   }
1948}
1949
1950
1951static void GLAPIENTRY
1952save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
1953               GLboolean sink)
1954{
1955   GET_CURRENT_CONTEXT(ctx);
1956   Node *n;
1957
1958   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1959   n = ALLOC_INSTRUCTION(ctx, OPCODE_HISTOGRAM, 4);
1960   if (n) {
1961      n[1].e = target;
1962      n[2].i = width;
1963      n[3].e = internalFormat;
1964      n[4].b = sink;
1965   }
1966   if (ctx->ExecuteFlag) {
1967      CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink));
1968   }
1969}
1970
1971
1972static void GLAPIENTRY
1973save_IndexMask(GLuint mask)
1974{
1975   GET_CURRENT_CONTEXT(ctx);
1976   Node *n;
1977   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1978   n = ALLOC_INSTRUCTION(ctx, OPCODE_INDEX_MASK, 1);
1979   if (n) {
1980      n[1].ui = mask;
1981   }
1982   if (ctx->ExecuteFlag) {
1983      CALL_IndexMask(ctx->Exec, (mask));
1984   }
1985}
1986
1987
1988static void GLAPIENTRY
1989save_InitNames(void)
1990{
1991   GET_CURRENT_CONTEXT(ctx);
1992   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1993   (void) ALLOC_INSTRUCTION(ctx, OPCODE_INIT_NAMES, 0);
1994   if (ctx->ExecuteFlag) {
1995      CALL_InitNames(ctx->Exec, ());
1996   }
1997}
1998
1999
2000static void GLAPIENTRY
2001save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2002{
2003   GET_CURRENT_CONTEXT(ctx);
2004   Node *n;
2005   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2006   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT, 6);
2007   if (n) {
2008      GLint i, nParams;
2009      n[1].e = light;
2010      n[2].e = pname;
2011      switch (pname) {
2012      case GL_AMBIENT:
2013         nParams = 4;
2014         break;
2015      case GL_DIFFUSE:
2016         nParams = 4;
2017         break;
2018      case GL_SPECULAR:
2019         nParams = 4;
2020         break;
2021      case GL_POSITION:
2022         nParams = 4;
2023         break;
2024      case GL_SPOT_DIRECTION:
2025         nParams = 3;
2026         break;
2027      case GL_SPOT_EXPONENT:
2028         nParams = 1;
2029         break;
2030      case GL_SPOT_CUTOFF:
2031         nParams = 1;
2032         break;
2033      case GL_CONSTANT_ATTENUATION:
2034         nParams = 1;
2035         break;
2036      case GL_LINEAR_ATTENUATION:
2037         nParams = 1;
2038         break;
2039      case GL_QUADRATIC_ATTENUATION:
2040         nParams = 1;
2041         break;
2042      default:
2043         nParams = 0;
2044      }
2045      for (i = 0; i < nParams; i++) {
2046         n[3 + i].f = params[i];
2047      }
2048   }
2049   if (ctx->ExecuteFlag) {
2050      CALL_Lightfv(ctx->Exec, (light, pname, params));
2051   }
2052}
2053
2054
2055static void GLAPIENTRY
2056save_Lightf(GLenum light, GLenum pname, GLfloat params)
2057{
2058   save_Lightfv(light, pname, &params);
2059}
2060
2061
2062static void GLAPIENTRY
2063save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2064{
2065   GLfloat fparam[4];
2066   switch (pname) {
2067   case GL_AMBIENT:
2068   case GL_DIFFUSE:
2069   case GL_SPECULAR:
2070      fparam[0] = INT_TO_FLOAT(params[0]);
2071      fparam[1] = INT_TO_FLOAT(params[1]);
2072      fparam[2] = INT_TO_FLOAT(params[2]);
2073      fparam[3] = INT_TO_FLOAT(params[3]);
2074      break;
2075   case GL_POSITION:
2076      fparam[0] = (GLfloat) params[0];
2077      fparam[1] = (GLfloat) params[1];
2078      fparam[2] = (GLfloat) params[2];
2079      fparam[3] = (GLfloat) params[3];
2080      break;
2081   case GL_SPOT_DIRECTION:
2082      fparam[0] = (GLfloat) params[0];
2083      fparam[1] = (GLfloat) params[1];
2084      fparam[2] = (GLfloat) params[2];
2085      break;
2086   case GL_SPOT_EXPONENT:
2087   case GL_SPOT_CUTOFF:
2088   case GL_CONSTANT_ATTENUATION:
2089   case GL_LINEAR_ATTENUATION:
2090   case GL_QUADRATIC_ATTENUATION:
2091      fparam[0] = (GLfloat) params[0];
2092      break;
2093   default:
2094      /* error will be caught later in gl_Lightfv */
2095      ;
2096   }
2097   save_Lightfv(light, pname, fparam);
2098}
2099
2100
2101static void GLAPIENTRY
2102save_Lighti(GLenum light, GLenum pname, GLint param)
2103{
2104   save_Lightiv(light, pname, &param);
2105}
2106
2107
2108static void GLAPIENTRY
2109save_LightModelfv(GLenum pname, const GLfloat *params)
2110{
2111   GET_CURRENT_CONTEXT(ctx);
2112   Node *n;
2113   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2114   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIGHT_MODEL, 5);
2115   if (n) {
2116      n[1].e = pname;
2117      n[2].f = params[0];
2118      n[3].f = params[1];
2119      n[4].f = params[2];
2120      n[5].f = params[3];
2121   }
2122   if (ctx->ExecuteFlag) {
2123      CALL_LightModelfv(ctx->Exec, (pname, params));
2124   }
2125}
2126
2127
2128static void GLAPIENTRY
2129save_LightModelf(GLenum pname, GLfloat param)
2130{
2131   save_LightModelfv(pname, &param);
2132}
2133
2134
2135static void GLAPIENTRY
2136save_LightModeliv(GLenum pname, const GLint *params)
2137{
2138   GLfloat fparam[4];
2139   switch (pname) {
2140   case GL_LIGHT_MODEL_AMBIENT:
2141      fparam[0] = INT_TO_FLOAT(params[0]);
2142      fparam[1] = INT_TO_FLOAT(params[1]);
2143      fparam[2] = INT_TO_FLOAT(params[2]);
2144      fparam[3] = INT_TO_FLOAT(params[3]);
2145      break;
2146   case GL_LIGHT_MODEL_LOCAL_VIEWER:
2147   case GL_LIGHT_MODEL_TWO_SIDE:
2148   case GL_LIGHT_MODEL_COLOR_CONTROL:
2149      fparam[0] = (GLfloat) params[0];
2150      break;
2151   default:
2152      /* Error will be caught later in gl_LightModelfv */
2153      ;
2154   }
2155   save_LightModelfv(pname, fparam);
2156}
2157
2158
2159static void GLAPIENTRY
2160save_LightModeli(GLenum pname, GLint param)
2161{
2162   save_LightModeliv(pname, &param);
2163}
2164
2165
2166static void GLAPIENTRY
2167save_LineStipple(GLint factor, GLushort pattern)
2168{
2169   GET_CURRENT_CONTEXT(ctx);
2170   Node *n;
2171   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2172   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_STIPPLE, 2);
2173   if (n) {
2174      n[1].i = factor;
2175      n[2].us = pattern;
2176   }
2177   if (ctx->ExecuteFlag) {
2178      CALL_LineStipple(ctx->Exec, (factor, pattern));
2179   }
2180}
2181
2182
2183static void GLAPIENTRY
2184save_LineWidth(GLfloat width)
2185{
2186   GET_CURRENT_CONTEXT(ctx);
2187   Node *n;
2188   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2189   n = ALLOC_INSTRUCTION(ctx, OPCODE_LINE_WIDTH, 1);
2190   if (n) {
2191      n[1].f = width;
2192   }
2193   if (ctx->ExecuteFlag) {
2194      CALL_LineWidth(ctx->Exec, (width));
2195   }
2196}
2197
2198
2199static void GLAPIENTRY
2200save_ListBase(GLuint base)
2201{
2202   GET_CURRENT_CONTEXT(ctx);
2203   Node *n;
2204   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2205   n = ALLOC_INSTRUCTION(ctx, OPCODE_LIST_BASE, 1);
2206   if (n) {
2207      n[1].ui = base;
2208   }
2209   if (ctx->ExecuteFlag) {
2210      CALL_ListBase(ctx->Exec, (base));
2211   }
2212}
2213
2214
2215static void GLAPIENTRY
2216save_LoadIdentity(void)
2217{
2218   GET_CURRENT_CONTEXT(ctx);
2219   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2220   (void) ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_IDENTITY, 0);
2221   if (ctx->ExecuteFlag) {
2222      CALL_LoadIdentity(ctx->Exec, ());
2223   }
2224}
2225
2226
2227static void GLAPIENTRY
2228save_LoadMatrixf(const GLfloat * m)
2229{
2230   GET_CURRENT_CONTEXT(ctx);
2231   Node *n;
2232   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2233   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_MATRIX, 16);
2234   if (n) {
2235      GLuint i;
2236      for (i = 0; i < 16; i++) {
2237         n[1 + i].f = m[i];
2238      }
2239   }
2240   if (ctx->ExecuteFlag) {
2241      CALL_LoadMatrixf(ctx->Exec, (m));
2242   }
2243}
2244
2245
2246static void GLAPIENTRY
2247save_LoadMatrixd(const GLdouble * m)
2248{
2249   GLfloat f[16];
2250   GLint i;
2251   for (i = 0; i < 16; i++) {
2252      f[i] = (GLfloat) m[i];
2253   }
2254   save_LoadMatrixf(f);
2255}
2256
2257
2258static void GLAPIENTRY
2259save_LoadName(GLuint name)
2260{
2261   GET_CURRENT_CONTEXT(ctx);
2262   Node *n;
2263   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2264   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_NAME, 1);
2265   if (n) {
2266      n[1].ui = name;
2267   }
2268   if (ctx->ExecuteFlag) {
2269      CALL_LoadName(ctx->Exec, (name));
2270   }
2271}
2272
2273
2274static void GLAPIENTRY
2275save_LogicOp(GLenum opcode)
2276{
2277   GET_CURRENT_CONTEXT(ctx);
2278   Node *n;
2279   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2280   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOGIC_OP, 1);
2281   if (n) {
2282      n[1].e = opcode;
2283   }
2284   if (ctx->ExecuteFlag) {
2285      CALL_LogicOp(ctx->Exec, (opcode));
2286   }
2287}
2288
2289
2290static void GLAPIENTRY
2291save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2292           GLint order, const GLdouble * points)
2293{
2294   GET_CURRENT_CONTEXT(ctx);
2295   Node *n;
2296   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2297   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
2298   if (n) {
2299      GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
2300      n[1].e = target;
2301      n[2].f = (GLfloat) u1;
2302      n[3].f = (GLfloat) u2;
2303      n[4].i = _mesa_evaluator_components(target);      /* stride */
2304      n[5].i = order;
2305      n[6].data = (void *) pnts;
2306   }
2307   if (ctx->ExecuteFlag) {
2308      CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
2309   }
2310}
2311
2312static void GLAPIENTRY
2313save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2314           GLint order, const GLfloat * points)
2315{
2316   GET_CURRENT_CONTEXT(ctx);
2317   Node *n;
2318   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2319   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP1, 6);
2320   if (n) {
2321      GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
2322      n[1].e = target;
2323      n[2].f = u1;
2324      n[3].f = u2;
2325      n[4].i = _mesa_evaluator_components(target);      /* stride */
2326      n[5].i = order;
2327      n[6].data = (void *) pnts;
2328   }
2329   if (ctx->ExecuteFlag) {
2330      CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
2331   }
2332}
2333
2334
2335static void GLAPIENTRY
2336save_Map2d(GLenum target,
2337           GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2338           GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2339           const GLdouble * points)
2340{
2341   GET_CURRENT_CONTEXT(ctx);
2342   Node *n;
2343   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2344   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
2345   if (n) {
2346      GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
2347                                              vstride, vorder, points);
2348      n[1].e = target;
2349      n[2].f = (GLfloat) u1;
2350      n[3].f = (GLfloat) u2;
2351      n[4].f = (GLfloat) v1;
2352      n[5].f = (GLfloat) v2;
2353      /* XXX verify these strides are correct */
2354      n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
2355      n[7].i = _mesa_evaluator_components(target);      /*vstride */
2356      n[8].i = uorder;
2357      n[9].i = vorder;
2358      n[10].data = (void *) pnts;
2359   }
2360   if (ctx->ExecuteFlag) {
2361      CALL_Map2d(ctx->Exec, (target,
2362                             u1, u2, ustride, uorder,
2363                             v1, v2, vstride, vorder, points));
2364   }
2365}
2366
2367
2368static void GLAPIENTRY
2369save_Map2f(GLenum target,
2370           GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2371           GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2372           const GLfloat * points)
2373{
2374   GET_CURRENT_CONTEXT(ctx);
2375   Node *n;
2376   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2377   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAP2, 10);
2378   if (n) {
2379      GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
2380                                              vstride, vorder, points);
2381      n[1].e = target;
2382      n[2].f = u1;
2383      n[3].f = u2;
2384      n[4].f = v1;
2385      n[5].f = v2;
2386      /* XXX verify these strides are correct */
2387      n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
2388      n[7].i = _mesa_evaluator_components(target);      /*vstride */
2389      n[8].i = uorder;
2390      n[9].i = vorder;
2391      n[10].data = (void *) pnts;
2392   }
2393   if (ctx->ExecuteFlag) {
2394      CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
2395                             v1, v2, vstride, vorder, points));
2396   }
2397}
2398
2399
2400static void GLAPIENTRY
2401save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
2402{
2403   GET_CURRENT_CONTEXT(ctx);
2404   Node *n;
2405   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2406   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID1, 3);
2407   if (n) {
2408      n[1].i = un;
2409      n[2].f = u1;
2410      n[3].f = u2;
2411   }
2412   if (ctx->ExecuteFlag) {
2413      CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
2414   }
2415}
2416
2417
2418static void GLAPIENTRY
2419save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
2420{
2421   save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
2422}
2423
2424
2425static void GLAPIENTRY
2426save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
2427               GLint vn, GLfloat v1, GLfloat v2)
2428{
2429   GET_CURRENT_CONTEXT(ctx);
2430   Node *n;
2431   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2432   n = ALLOC_INSTRUCTION(ctx, OPCODE_MAPGRID2, 6);
2433   if (n) {
2434      n[1].i = un;
2435      n[2].f = u1;
2436      n[3].f = u2;
2437      n[4].i = vn;
2438      n[5].f = v1;
2439      n[6].f = v2;
2440   }
2441   if (ctx->ExecuteFlag) {
2442      CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
2443   }
2444}
2445
2446
2447
2448static void GLAPIENTRY
2449save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
2450               GLint vn, GLdouble v1, GLdouble v2)
2451{
2452   save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
2453                  vn, (GLfloat) v1, (GLfloat) v2);
2454}
2455
2456
2457static void GLAPIENTRY
2458save_MatrixMode(GLenum mode)
2459{
2460   GET_CURRENT_CONTEXT(ctx);
2461   Node *n;
2462   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2463   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATRIX_MODE, 1);
2464   if (n) {
2465      n[1].e = mode;
2466   }
2467   if (ctx->ExecuteFlag) {
2468      CALL_MatrixMode(ctx->Exec, (mode));
2469   }
2470}
2471
2472
2473static void GLAPIENTRY
2474save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
2475{
2476   GET_CURRENT_CONTEXT(ctx);
2477   Node *n;
2478
2479   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2480   n = ALLOC_INSTRUCTION(ctx, OPCODE_MIN_MAX, 3);
2481   if (n) {
2482      n[1].e = target;
2483      n[2].e = internalFormat;
2484      n[3].b = sink;
2485   }
2486   if (ctx->ExecuteFlag) {
2487      CALL_Minmax(ctx->Exec, (target, internalFormat, sink));
2488   }
2489}
2490
2491
2492static void GLAPIENTRY
2493save_MultMatrixf(const GLfloat * m)
2494{
2495   GET_CURRENT_CONTEXT(ctx);
2496   Node *n;
2497   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2498   n = ALLOC_INSTRUCTION(ctx, OPCODE_MULT_MATRIX, 16);
2499   if (n) {
2500      GLuint i;
2501      for (i = 0; i < 16; i++) {
2502         n[1 + i].f = m[i];
2503      }
2504   }
2505   if (ctx->ExecuteFlag) {
2506      CALL_MultMatrixf(ctx->Exec, (m));
2507   }
2508}
2509
2510
2511static void GLAPIENTRY
2512save_MultMatrixd(const GLdouble * m)
2513{
2514   GLfloat f[16];
2515   GLint i;
2516   for (i = 0; i < 16; i++) {
2517      f[i] = (GLfloat) m[i];
2518   }
2519   save_MultMatrixf(f);
2520}
2521
2522
2523static void GLAPIENTRY
2524save_NewList(GLuint list, GLenum mode)
2525{
2526   GET_CURRENT_CONTEXT(ctx);
2527   /* It's an error to call this function while building a display list */
2528   _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
2529   (void) list;
2530   (void) mode;
2531}
2532
2533
2534
2535static void GLAPIENTRY
2536save_Ortho(GLdouble left, GLdouble right,
2537           GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2538{
2539   GET_CURRENT_CONTEXT(ctx);
2540   Node *n;
2541   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2542   n = ALLOC_INSTRUCTION(ctx, OPCODE_ORTHO, 6);
2543   if (n) {
2544      n[1].f = (GLfloat) left;
2545      n[2].f = (GLfloat) right;
2546      n[3].f = (GLfloat) bottom;
2547      n[4].f = (GLfloat) top;
2548      n[5].f = (GLfloat) nearval;
2549      n[6].f = (GLfloat) farval;
2550   }
2551   if (ctx->ExecuteFlag) {
2552      CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
2553   }
2554}
2555
2556
2557static void GLAPIENTRY
2558save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
2559{
2560   GET_CURRENT_CONTEXT(ctx);
2561   Node *n;
2562   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2563   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_MAP, 3);
2564   if (n) {
2565      n[1].e = map;
2566      n[2].i = mapsize;
2567      n[3].data = (void *) _mesa_malloc(mapsize * sizeof(GLfloat));
2568      MEMCPY(n[3].data, (void *) values, mapsize * sizeof(GLfloat));
2569   }
2570   if (ctx->ExecuteFlag) {
2571      CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
2572   }
2573}
2574
2575
2576static void GLAPIENTRY
2577save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
2578{
2579   GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2580   GLint i;
2581   if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
2582      for (i = 0; i < mapsize; i++) {
2583         fvalues[i] = (GLfloat) values[i];
2584      }
2585   }
2586   else {
2587      for (i = 0; i < mapsize; i++) {
2588         fvalues[i] = UINT_TO_FLOAT(values[i]);
2589      }
2590   }
2591   save_PixelMapfv(map, mapsize, fvalues);
2592}
2593
2594
2595static void GLAPIENTRY
2596save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2597{
2598   GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2599   GLint i;
2600   if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
2601      for (i = 0; i < mapsize; i++) {
2602         fvalues[i] = (GLfloat) values[i];
2603      }
2604   }
2605   else {
2606      for (i = 0; i < mapsize; i++) {
2607         fvalues[i] = USHORT_TO_FLOAT(values[i]);
2608      }
2609   }
2610   save_PixelMapfv(map, mapsize, fvalues);
2611}
2612
2613
2614static void GLAPIENTRY
2615save_PixelTransferf(GLenum pname, GLfloat param)
2616{
2617   GET_CURRENT_CONTEXT(ctx);
2618   Node *n;
2619   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2620   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_TRANSFER, 2);
2621   if (n) {
2622      n[1].e = pname;
2623      n[2].f = param;
2624   }
2625   if (ctx->ExecuteFlag) {
2626      CALL_PixelTransferf(ctx->Exec, (pname, param));
2627   }
2628}
2629
2630
2631static void GLAPIENTRY
2632save_PixelTransferi(GLenum pname, GLint param)
2633{
2634   save_PixelTransferf(pname, (GLfloat) param);
2635}
2636
2637
2638static void GLAPIENTRY
2639save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
2640{
2641   GET_CURRENT_CONTEXT(ctx);
2642   Node *n;
2643   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2644   n = ALLOC_INSTRUCTION(ctx, OPCODE_PIXEL_ZOOM, 2);
2645   if (n) {
2646      n[1].f = xfactor;
2647      n[2].f = yfactor;
2648   }
2649   if (ctx->ExecuteFlag) {
2650      CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
2651   }
2652}
2653
2654
2655static void GLAPIENTRY
2656save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
2657{
2658   GET_CURRENT_CONTEXT(ctx);
2659   Node *n;
2660   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2661   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_PARAMETERS, 4);
2662   if (n) {
2663      n[1].e = pname;
2664      n[2].f = params[0];
2665      n[3].f = params[1];
2666      n[4].f = params[2];
2667   }
2668   if (ctx->ExecuteFlag) {
2669      CALL_PointParameterfvEXT(ctx->Exec, (pname, params));
2670   }
2671}
2672
2673
2674static void GLAPIENTRY
2675save_PointParameterfEXT(GLenum pname, GLfloat param)
2676{
2677   save_PointParameterfvEXT(pname, &param);
2678}
2679
2680static void GLAPIENTRY
2681save_PointParameteriNV(GLenum pname, GLint param)
2682{
2683   GLfloat p = (GLfloat) param;
2684   save_PointParameterfvEXT(pname, &p);
2685}
2686
2687static void GLAPIENTRY
2688save_PointParameterivNV(GLenum pname, const GLint * param)
2689{
2690   GLfloat p = (GLfloat) param[0];
2691   save_PointParameterfvEXT(pname, &p);
2692}
2693
2694
2695static void GLAPIENTRY
2696save_PointSize(GLfloat size)
2697{
2698   GET_CURRENT_CONTEXT(ctx);
2699   Node *n;
2700   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2701   n = ALLOC_INSTRUCTION(ctx, OPCODE_POINT_SIZE, 1);
2702   if (n) {
2703      n[1].f = size;
2704   }
2705   if (ctx->ExecuteFlag) {
2706      CALL_PointSize(ctx->Exec, (size));
2707   }
2708}
2709
2710
2711static void GLAPIENTRY
2712save_PolygonMode(GLenum face, GLenum mode)
2713{
2714   GET_CURRENT_CONTEXT(ctx);
2715   Node *n;
2716   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2717   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_MODE, 2);
2718   if (n) {
2719      n[1].e = face;
2720      n[2].e = mode;
2721   }
2722   if (ctx->ExecuteFlag) {
2723      CALL_PolygonMode(ctx->Exec, (face, mode));
2724   }
2725}
2726
2727
2728static void GLAPIENTRY
2729save_PolygonStipple(const GLubyte * pattern)
2730{
2731   GET_CURRENT_CONTEXT(ctx);
2732   GLvoid *image = unpack_image(2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
2733                                pattern, &ctx->Unpack);
2734   Node *n;
2735   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2736   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1);
2737   if (n) {
2738      n[1].data = image;
2739   }
2740   else if (image) {
2741      _mesa_free(image);
2742   }
2743   if (ctx->ExecuteFlag) {
2744      CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
2745   }
2746}
2747
2748
2749static void GLAPIENTRY
2750save_PolygonOffset(GLfloat factor, GLfloat units)
2751{
2752   GET_CURRENT_CONTEXT(ctx);
2753   Node *n;
2754   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2755   n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_OFFSET, 2);
2756   if (n) {
2757      n[1].f = factor;
2758      n[2].f = units;
2759   }
2760   if (ctx->ExecuteFlag) {
2761      CALL_PolygonOffset(ctx->Exec, (factor, units));
2762   }
2763}
2764
2765
2766static void GLAPIENTRY
2767save_PolygonOffsetEXT(GLfloat factor, GLfloat bias)
2768{
2769   GET_CURRENT_CONTEXT(ctx);
2770   /* XXX mult by DepthMaxF here??? */
2771   save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
2772}
2773
2774
2775static void GLAPIENTRY
2776save_PopAttrib(void)
2777{
2778   GET_CURRENT_CONTEXT(ctx);
2779   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2780   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_ATTRIB, 0);
2781   if (ctx->ExecuteFlag) {
2782      CALL_PopAttrib(ctx->Exec, ());
2783   }
2784}
2785
2786
2787static void GLAPIENTRY
2788save_PopMatrix(void)
2789{
2790   GET_CURRENT_CONTEXT(ctx);
2791   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2792   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_MATRIX, 0);
2793   if (ctx->ExecuteFlag) {
2794      CALL_PopMatrix(ctx->Exec, ());
2795   }
2796}
2797
2798
2799static void GLAPIENTRY
2800save_PopName(void)
2801{
2802   GET_CURRENT_CONTEXT(ctx);
2803   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2804   (void) ALLOC_INSTRUCTION(ctx, OPCODE_POP_NAME, 0);
2805   if (ctx->ExecuteFlag) {
2806      CALL_PopName(ctx->Exec, ());
2807   }
2808}
2809
2810
2811static void GLAPIENTRY
2812save_PrioritizeTextures(GLsizei num, const GLuint * textures,
2813                        const GLclampf * priorities)
2814{
2815   GET_CURRENT_CONTEXT(ctx);
2816   GLint i;
2817   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2818
2819   for (i = 0; i < num; i++) {
2820      Node *n;
2821      n = ALLOC_INSTRUCTION(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
2822      if (n) {
2823         n[1].ui = textures[i];
2824         n[2].f = priorities[i];
2825      }
2826   }
2827   if (ctx->ExecuteFlag) {
2828      CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
2829   }
2830}
2831
2832
2833static void GLAPIENTRY
2834save_PushAttrib(GLbitfield mask)
2835{
2836   GET_CURRENT_CONTEXT(ctx);
2837   Node *n;
2838   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2839   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_ATTRIB, 1);
2840   if (n) {
2841      n[1].bf = mask;
2842   }
2843   if (ctx->ExecuteFlag) {
2844      CALL_PushAttrib(ctx->Exec, (mask));
2845   }
2846}
2847
2848
2849static void GLAPIENTRY
2850save_PushMatrix(void)
2851{
2852   GET_CURRENT_CONTEXT(ctx);
2853   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2854   (void) ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_MATRIX, 0);
2855   if (ctx->ExecuteFlag) {
2856      CALL_PushMatrix(ctx->Exec, ());
2857   }
2858}
2859
2860
2861static void GLAPIENTRY
2862save_PushName(GLuint name)
2863{
2864   GET_CURRENT_CONTEXT(ctx);
2865   Node *n;
2866   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2867   n = ALLOC_INSTRUCTION(ctx, OPCODE_PUSH_NAME, 1);
2868   if (n) {
2869      n[1].ui = name;
2870   }
2871   if (ctx->ExecuteFlag) {
2872      CALL_PushName(ctx->Exec, (name));
2873   }
2874}
2875
2876
2877static void GLAPIENTRY
2878save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2879{
2880   GET_CURRENT_CONTEXT(ctx);
2881   Node *n;
2882   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2883   n = ALLOC_INSTRUCTION(ctx, OPCODE_RASTER_POS, 4);
2884   if (n) {
2885      n[1].f = x;
2886      n[2].f = y;
2887      n[3].f = z;
2888      n[4].f = w;
2889   }
2890   if (ctx->ExecuteFlag) {
2891      CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
2892   }
2893}
2894
2895static void GLAPIENTRY
2896save_RasterPos2d(GLdouble x, GLdouble y)
2897{
2898   save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2899}
2900
2901static void GLAPIENTRY
2902save_RasterPos2f(GLfloat x, GLfloat y)
2903{
2904   save_RasterPos4f(x, y, 0.0F, 1.0F);
2905}
2906
2907static void GLAPIENTRY
2908save_RasterPos2i(GLint x, GLint y)
2909{
2910   save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
2911}
2912
2913static void GLAPIENTRY
2914save_RasterPos2s(GLshort x, GLshort y)
2915{
2916   save_RasterPos4f(x, y, 0.0F, 1.0F);
2917}
2918
2919static void GLAPIENTRY
2920save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2921{
2922   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2923}
2924
2925static void GLAPIENTRY
2926save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2927{
2928   save_RasterPos4f(x, y, z, 1.0F);
2929}
2930
2931static void GLAPIENTRY
2932save_RasterPos3i(GLint x, GLint y, GLint z)
2933{
2934   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
2935}
2936
2937static void GLAPIENTRY
2938save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2939{
2940   save_RasterPos4f(x, y, z, 1.0F);
2941}
2942
2943static void GLAPIENTRY
2944save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2945{
2946   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2947}
2948
2949static void GLAPIENTRY
2950save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2951{
2952   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
2953}
2954
2955static void GLAPIENTRY
2956save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2957{
2958   save_RasterPos4f(x, y, z, w);
2959}
2960
2961static void GLAPIENTRY
2962save_RasterPos2dv(const GLdouble * v)
2963{
2964   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2965}
2966
2967static void GLAPIENTRY
2968save_RasterPos2fv(const GLfloat * v)
2969{
2970   save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2971}
2972
2973static void GLAPIENTRY
2974save_RasterPos2iv(const GLint * v)
2975{
2976   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
2977}
2978
2979static void GLAPIENTRY
2980save_RasterPos2sv(const GLshort * v)
2981{
2982   save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2983}
2984
2985static void GLAPIENTRY
2986save_RasterPos3dv(const GLdouble * v)
2987{
2988   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
2989}
2990
2991static void GLAPIENTRY
2992save_RasterPos3fv(const GLfloat * v)
2993{
2994   save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2995}
2996
2997static void GLAPIENTRY
2998save_RasterPos3iv(const GLint * v)
2999{
3000   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3001}
3002
3003static void GLAPIENTRY
3004save_RasterPos3sv(const GLshort * v)
3005{
3006   save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3007}
3008
3009static void GLAPIENTRY
3010save_RasterPos4dv(const GLdouble * v)
3011{
3012   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3013                    (GLfloat) v[2], (GLfloat) v[3]);
3014}
3015
3016static void GLAPIENTRY
3017save_RasterPos4fv(const GLfloat * v)
3018{
3019   save_RasterPos4f(v[0], v[1], v[2], v[3]);
3020}
3021
3022static void GLAPIENTRY
3023save_RasterPos4iv(const GLint * v)
3024{
3025   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3026                    (GLfloat) v[2], (GLfloat) v[3]);
3027}
3028
3029static void GLAPIENTRY
3030save_RasterPos4sv(const GLshort * v)
3031{
3032   save_RasterPos4f(v[0], v[1], v[2], v[3]);
3033}
3034
3035
3036static void GLAPIENTRY
3037save_PassThrough(GLfloat token)
3038{
3039   GET_CURRENT_CONTEXT(ctx);
3040   Node *n;
3041   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3042   n = ALLOC_INSTRUCTION(ctx, OPCODE_PASSTHROUGH, 1);
3043   if (n) {
3044      n[1].f = token;
3045   }
3046   if (ctx->ExecuteFlag) {
3047      CALL_PassThrough(ctx->Exec, (token));
3048   }
3049}
3050
3051
3052static void GLAPIENTRY
3053save_ReadBuffer(GLenum mode)
3054{
3055   GET_CURRENT_CONTEXT(ctx);
3056   Node *n;
3057   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3058   n = ALLOC_INSTRUCTION(ctx, OPCODE_READ_BUFFER, 1);
3059   if (n) {
3060      n[1].e = mode;
3061   }
3062   if (ctx->ExecuteFlag) {
3063      CALL_ReadBuffer(ctx->Exec, (mode));
3064   }
3065}
3066
3067
3068static void GLAPIENTRY
3069save_ResetHistogram(GLenum target)
3070{
3071   GET_CURRENT_CONTEXT(ctx);
3072   Node *n;
3073   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3074   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_HISTOGRAM, 1);
3075   if (n) {
3076      n[1].e = target;
3077   }
3078   if (ctx->ExecuteFlag) {
3079      CALL_ResetHistogram(ctx->Exec, (target));
3080   }
3081}
3082
3083
3084static void GLAPIENTRY
3085save_ResetMinmax(GLenum target)
3086{
3087   GET_CURRENT_CONTEXT(ctx);
3088   Node *n;
3089   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3090   n = ALLOC_INSTRUCTION(ctx, OPCODE_RESET_MIN_MAX, 1);
3091   if (n) {
3092      n[1].e = target;
3093   }
3094   if (ctx->ExecuteFlag) {
3095      CALL_ResetMinmax(ctx->Exec, (target));
3096   }
3097}
3098
3099
3100static void GLAPIENTRY
3101save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
3102{
3103   GET_CURRENT_CONTEXT(ctx);
3104   Node *n;
3105   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3106   n = ALLOC_INSTRUCTION(ctx, OPCODE_ROTATE, 4);
3107   if (n) {
3108      n[1].f = angle;
3109      n[2].f = x;
3110      n[3].f = y;
3111      n[4].f = z;
3112   }
3113   if (ctx->ExecuteFlag) {
3114      CALL_Rotatef(ctx->Exec, (angle, x, y, z));
3115   }
3116}
3117
3118
3119static void GLAPIENTRY
3120save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
3121{
3122   save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3123}
3124
3125
3126static void GLAPIENTRY
3127save_Scalef(GLfloat x, GLfloat y, GLfloat z)
3128{
3129   GET_CURRENT_CONTEXT(ctx);
3130   Node *n;
3131   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3132   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCALE, 3);
3133   if (n) {
3134      n[1].f = x;
3135      n[2].f = y;
3136      n[3].f = z;
3137   }
3138   if (ctx->ExecuteFlag) {
3139      CALL_Scalef(ctx->Exec, (x, y, z));
3140   }
3141}
3142
3143
3144static void GLAPIENTRY
3145save_Scaled(GLdouble x, GLdouble y, GLdouble z)
3146{
3147   save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3148}
3149
3150
3151static void GLAPIENTRY
3152save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
3153{
3154   GET_CURRENT_CONTEXT(ctx);
3155   Node *n;
3156   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3157   n = ALLOC_INSTRUCTION(ctx, OPCODE_SCISSOR, 4);
3158   if (n) {
3159      n[1].i = x;
3160      n[2].i = y;
3161      n[3].i = width;
3162      n[4].i = height;
3163   }
3164   if (ctx->ExecuteFlag) {
3165      CALL_Scissor(ctx->Exec, (x, y, width, height));
3166   }
3167}
3168
3169
3170static void GLAPIENTRY
3171save_ShadeModel(GLenum mode)
3172{
3173   GET_CURRENT_CONTEXT(ctx);
3174   Node *n;
3175   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3176   n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1);
3177   if (n) {
3178      n[1].e = mode;
3179   }
3180   if (ctx->ExecuteFlag) {
3181      CALL_ShadeModel(ctx->Exec, (mode));
3182   }
3183}
3184
3185
3186static void GLAPIENTRY
3187save_StencilFunc(GLenum func, GLint ref, GLuint mask)
3188{
3189   GET_CURRENT_CONTEXT(ctx);
3190   Node *n;
3191   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3192   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC, 3);
3193   if (n) {
3194      n[1].e = func;
3195      n[2].i = ref;
3196      n[3].ui = mask;
3197   }
3198   if (ctx->ExecuteFlag) {
3199      CALL_StencilFunc(ctx->Exec, (func, ref, mask));
3200   }
3201}
3202
3203
3204static void GLAPIENTRY
3205save_StencilMask(GLuint mask)
3206{
3207   GET_CURRENT_CONTEXT(ctx);
3208   Node *n;
3209   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3210   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK, 1);
3211   if (n) {
3212      n[1].ui = mask;
3213   }
3214   if (ctx->ExecuteFlag) {
3215      CALL_StencilMask(ctx->Exec, (mask));
3216   }
3217}
3218
3219
3220static void GLAPIENTRY
3221save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3222{
3223   GET_CURRENT_CONTEXT(ctx);
3224   Node *n;
3225   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3226   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP, 3);
3227   if (n) {
3228      n[1].e = fail;
3229      n[2].e = zfail;
3230      n[3].e = zpass;
3231   }
3232   if (ctx->ExecuteFlag) {
3233      CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
3234   }
3235}
3236
3237
3238static void GLAPIENTRY
3239save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3240{
3241   GET_CURRENT_CONTEXT(ctx);
3242   Node *n;
3243   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3244   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3245   if (n) {
3246      n[1].e = face;
3247      n[2].e = func;
3248      n[3].i = ref;
3249      n[4].ui = mask;
3250   }
3251   if (ctx->ExecuteFlag) {
3252      CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
3253   }
3254}
3255
3256
3257static void GLAPIENTRY
3258save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
3259                            GLuint mask)
3260{
3261   GET_CURRENT_CONTEXT(ctx);
3262   Node *n;
3263   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3264   /* GL_FRONT */
3265   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3266   if (n) {
3267      n[1].e = GL_FRONT;
3268      n[2].e = frontfunc;
3269      n[3].i = ref;
3270      n[4].ui = mask;
3271   }
3272   /* GL_BACK */
3273   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3274   if (n) {
3275      n[1].e = GL_BACK;
3276      n[2].e = backfunc;
3277      n[3].i = ref;
3278      n[4].ui = mask;
3279   }
3280   if (ctx->ExecuteFlag) {
3281      CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
3282      CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
3283   }
3284}
3285
3286
3287static void GLAPIENTRY
3288save_StencilMaskSeparate(GLenum face, GLuint mask)
3289{
3290   GET_CURRENT_CONTEXT(ctx);
3291   Node *n;
3292   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3293   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
3294   if (n) {
3295      n[1].e = face;
3296      n[2].ui = mask;
3297   }
3298   if (ctx->ExecuteFlag) {
3299      CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
3300   }
3301}
3302
3303
3304static void GLAPIENTRY
3305save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3306{
3307   GET_CURRENT_CONTEXT(ctx);
3308   Node *n;
3309   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3310   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
3311   if (n) {
3312      n[1].e = face;
3313      n[2].e = fail;
3314      n[3].e = zfail;
3315      n[4].e = zpass;
3316   }
3317   if (ctx->ExecuteFlag) {
3318      CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
3319   }
3320}
3321
3322
3323static void GLAPIENTRY
3324save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
3325{
3326   GET_CURRENT_CONTEXT(ctx);
3327   Node *n;
3328   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3329   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXENV, 6);
3330   if (n) {
3331      n[1].e = target;
3332      n[2].e = pname;
3333      if (pname == GL_TEXTURE_ENV_COLOR) {
3334         n[3].f = params[0];
3335         n[4].f = params[1];
3336         n[5].f = params[2];
3337         n[6].f = params[3];
3338      }
3339      else {
3340         n[3].f = params[0];
3341         n[4].f = n[5].f = n[6].f = 0.0F;
3342      }
3343   }
3344   if (ctx->ExecuteFlag) {
3345      CALL_TexEnvfv(ctx->Exec, (target, pname, params));
3346   }
3347}
3348
3349
3350static void GLAPIENTRY
3351save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
3352{
3353   save_TexEnvfv(target, pname, &param);
3354}
3355
3356
3357static void GLAPIENTRY
3358save_TexEnvi(GLenum target, GLenum pname, GLint param)
3359{
3360   GLfloat p[4];
3361   p[0] = (GLfloat) param;
3362   p[1] = p[2] = p[3] = 0.0;
3363   save_TexEnvfv(target, pname, p);
3364}
3365
3366
3367static void GLAPIENTRY
3368save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
3369{
3370   GLfloat p[4];
3371   if (pname == GL_TEXTURE_ENV_COLOR) {
3372      p[0] = INT_TO_FLOAT(param[0]);
3373      p[1] = INT_TO_FLOAT(param[1]);
3374      p[2] = INT_TO_FLOAT(param[2]);
3375      p[3] = INT_TO_FLOAT(param[3]);
3376   }
3377   else {
3378      p[0] = (GLfloat) param[0];
3379      p[1] = p[2] = p[3] = 0.0F;
3380   }
3381   save_TexEnvfv(target, pname, p);
3382}
3383
3384
3385static void GLAPIENTRY
3386save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
3387{
3388   GET_CURRENT_CONTEXT(ctx);
3389   Node *n;
3390   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3391   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXGEN, 6);
3392   if (n) {
3393      n[1].e = coord;
3394      n[2].e = pname;
3395      n[3].f = params[0];
3396      n[4].f = params[1];
3397      n[5].f = params[2];
3398      n[6].f = params[3];
3399   }
3400   if (ctx->ExecuteFlag) {
3401      CALL_TexGenfv(ctx->Exec, (coord, pname, params));
3402   }
3403}
3404
3405
3406static void GLAPIENTRY
3407save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
3408{
3409   GLfloat p[4];
3410   p[0] = (GLfloat) params[0];
3411   p[1] = (GLfloat) params[1];
3412   p[2] = (GLfloat) params[2];
3413   p[3] = (GLfloat) params[3];
3414   save_TexGenfv(coord, pname, p);
3415}
3416
3417
3418static void GLAPIENTRY
3419save_TexGend(GLenum coord, GLenum pname, GLdouble param)
3420{
3421   GLfloat p = (GLfloat) param;
3422   save_TexGenfv(coord, pname, &p);
3423}
3424
3425
3426static void GLAPIENTRY
3427save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
3428{
3429   GLfloat p[4];
3430   p[0] = (GLfloat) params[0];
3431   p[1] = (GLfloat) params[1];
3432   p[2] = (GLfloat) params[2];
3433   p[3] = (GLfloat) params[3];
3434   save_TexGenfv(coord, pname, p);
3435}
3436
3437
3438static void GLAPIENTRY
3439save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
3440{
3441   save_TexGenfv(coord, pname, &param);
3442}
3443
3444
3445static void GLAPIENTRY
3446save_TexGeni(GLenum coord, GLenum pname, GLint param)
3447{
3448   save_TexGeniv(coord, pname, &param);
3449}
3450
3451
3452static void GLAPIENTRY
3453save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
3454{
3455   GET_CURRENT_CONTEXT(ctx);
3456   Node *n;
3457   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3458   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEXPARAMETER, 6);
3459   if (n) {
3460      n[1].e = target;
3461      n[2].e = pname;
3462      n[3].f = params[0];
3463      n[4].f = params[1];
3464      n[5].f = params[2];
3465      n[6].f = params[3];
3466   }
3467   if (ctx->ExecuteFlag) {
3468      CALL_TexParameterfv(ctx->Exec, (target, pname, params));
3469   }
3470}
3471
3472
3473static void GLAPIENTRY
3474save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
3475{
3476   save_TexParameterfv(target, pname, &param);
3477}
3478
3479
3480static void GLAPIENTRY
3481save_TexParameteri(GLenum target, GLenum pname, GLint param)
3482{
3483   GLfloat fparam[4];
3484   fparam[0] = (GLfloat) param;
3485   fparam[1] = fparam[2] = fparam[3] = 0.0;
3486   save_TexParameterfv(target, pname, fparam);
3487}
3488
3489
3490static void GLAPIENTRY
3491save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
3492{
3493   GLfloat fparam[4];
3494   fparam[0] = (GLfloat) params[0];
3495   fparam[1] = fparam[2] = fparam[3] = 0.0;
3496   save_TexParameterfv(target, pname, fparam);
3497}
3498
3499
3500static void GLAPIENTRY
3501save_TexImage1D(GLenum target,
3502                GLint level, GLint components,
3503                GLsizei width, GLint border,
3504                GLenum format, GLenum type, const GLvoid * pixels)
3505{
3506   GET_CURRENT_CONTEXT(ctx);
3507   if (target == GL_PROXY_TEXTURE_1D) {
3508      /* don't compile, execute immediately */
3509      CALL_TexImage1D(ctx->Exec, (target, level, components, width,
3510                                  border, format, type, pixels));
3511   }
3512   else {
3513      GLvoid *image = unpack_image(1, width, 1, 1, format, type,
3514                                   pixels, &ctx->Unpack);
3515      Node *n;
3516      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3517      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE1D, 8);
3518      if (n) {
3519         n[1].e = target;
3520         n[2].i = level;
3521         n[3].i = components;
3522         n[4].i = (GLint) width;
3523         n[5].i = border;
3524         n[6].e = format;
3525         n[7].e = type;
3526         n[8].data = image;
3527      }
3528      else if (image) {
3529         _mesa_free(image);
3530      }
3531      if (ctx->ExecuteFlag) {
3532         CALL_TexImage1D(ctx->Exec, (target, level, components, width,
3533                                     border, format, type, pixels));
3534      }
3535   }
3536}
3537
3538
3539static void GLAPIENTRY
3540save_TexImage2D(GLenum target,
3541                GLint level, GLint components,
3542                GLsizei width, GLsizei height, GLint border,
3543                GLenum format, GLenum type, const GLvoid * pixels)
3544{
3545   GET_CURRENT_CONTEXT(ctx);
3546   if (target == GL_PROXY_TEXTURE_2D) {
3547      /* don't compile, execute immediately */
3548      CALL_TexImage2D(ctx->Exec, (target, level, components, width,
3549                                  height, border, format, type, pixels));
3550   }
3551   else {
3552      GLvoid *image = unpack_image(2, width, height, 1, format, type,
3553                                   pixels, &ctx->Unpack);
3554      Node *n;
3555      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3556      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE2D, 9);
3557      if (n) {
3558         n[1].e = target;
3559         n[2].i = level;
3560         n[3].i = components;
3561         n[4].i = (GLint) width;
3562         n[5].i = (GLint) height;
3563         n[6].i = border;
3564         n[7].e = format;
3565         n[8].e = type;
3566         n[9].data = image;
3567      }
3568      else if (image) {
3569         _mesa_free(image);
3570      }
3571      if (ctx->ExecuteFlag) {
3572         CALL_TexImage2D(ctx->Exec, (target, level, components, width,
3573                                     height, border, format, type, pixels));
3574      }
3575   }
3576}
3577
3578
3579static void GLAPIENTRY
3580save_TexImage3D(GLenum target,
3581                GLint level, GLint internalFormat,
3582                GLsizei width, GLsizei height, GLsizei depth,
3583                GLint border,
3584                GLenum format, GLenum type, const GLvoid * pixels)
3585{
3586   GET_CURRENT_CONTEXT(ctx);
3587   if (target == GL_PROXY_TEXTURE_3D) {
3588      /* don't compile, execute immediately */
3589      CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
3590                                  height, depth, border, format, type,
3591                                  pixels));
3592   }
3593   else {
3594      Node *n;
3595      GLvoid *image = unpack_image(3, width, height, depth, format, type,
3596                                   pixels, &ctx->Unpack);
3597      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3598      n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_IMAGE3D, 10);
3599      if (n) {
3600         n[1].e = target;
3601         n[2].i = level;
3602         n[3].i = (GLint) internalFormat;
3603         n[4].i = (GLint) width;
3604         n[5].i = (GLint) height;
3605         n[6].i = (GLint) depth;
3606         n[7].i = border;
3607         n[8].e = format;
3608         n[9].e = type;
3609         n[10].data = image;
3610      }
3611      else if (image) {
3612         _mesa_free(image);
3613      }
3614      if (ctx->ExecuteFlag) {
3615         CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
3616                                     height, depth, border, format, type,
3617                                     pixels));
3618      }
3619   }
3620}
3621
3622
3623static void GLAPIENTRY
3624save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
3625                   GLsizei width, GLenum format, GLenum type,
3626                   const GLvoid * pixels)
3627{
3628   GET_CURRENT_CONTEXT(ctx);
3629   Node *n;
3630   GLvoid *image = unpack_image(1, width, 1, 1, format, type,
3631                                pixels, &ctx->Unpack);
3632   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3633   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
3634   if (n) {
3635      n[1].e = target;
3636      n[2].i = level;
3637      n[3].i = xoffset;
3638      n[4].i = (GLint) width;
3639      n[5].e = format;
3640      n[6].e = type;
3641      n[7].data = image;
3642   }
3643   else if (image) {
3644      _mesa_free(image);
3645   }
3646   if (ctx->ExecuteFlag) {
3647      CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
3648                                     format, type, pixels));
3649   }
3650}
3651
3652
3653static void GLAPIENTRY
3654save_TexSubImage2D(GLenum target, GLint level,
3655                   GLint xoffset, GLint yoffset,
3656                   GLsizei width, GLsizei height,
3657                   GLenum format, GLenum type, const GLvoid * pixels)
3658{
3659   GET_CURRENT_CONTEXT(ctx);
3660   Node *n;
3661   GLvoid *image = unpack_image(2, width, height, 1, format, type,
3662                                pixels, &ctx->Unpack);
3663   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3664   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
3665   if (n) {
3666      n[1].e = target;
3667      n[2].i = level;
3668      n[3].i = xoffset;
3669      n[4].i = yoffset;
3670      n[5].i = (GLint) width;
3671      n[6].i = (GLint) height;
3672      n[7].e = format;
3673      n[8].e = type;
3674      n[9].data = image;
3675   }
3676   else if (image) {
3677      _mesa_free(image);
3678   }
3679   if (ctx->ExecuteFlag) {
3680      CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
3681                                     width, height, format, type, pixels));
3682   }
3683}
3684
3685
3686static void GLAPIENTRY
3687save_TexSubImage3D(GLenum target, GLint level,
3688                   GLint xoffset, GLint yoffset, GLint zoffset,
3689                   GLsizei width, GLsizei height, GLsizei depth,
3690                   GLenum format, GLenum type, const GLvoid * pixels)
3691{
3692   GET_CURRENT_CONTEXT(ctx);
3693   Node *n;
3694   GLvoid *image = unpack_image(3, width, height, depth, format, type,
3695                                pixels, &ctx->Unpack);
3696   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3697   n = ALLOC_INSTRUCTION(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
3698   if (n) {
3699      n[1].e = target;
3700      n[2].i = level;
3701      n[3].i = xoffset;
3702      n[4].i = yoffset;
3703      n[5].i = zoffset;
3704      n[6].i = (GLint) width;
3705      n[7].i = (GLint) height;
3706      n[8].i = (GLint) depth;
3707      n[9].e = format;
3708      n[10].e = type;
3709      n[11].data = image;
3710   }
3711   else if (image) {
3712      _mesa_free(image);
3713   }
3714   if (ctx->ExecuteFlag) {
3715      CALL_TexSubImage3D(ctx->Exec, (target, level,
3716                                     xoffset, yoffset, zoffset,
3717                                     width, height, depth, format, type,
3718                                     pixels));
3719   }
3720}
3721
3722
3723static void GLAPIENTRY
3724save_Translatef(GLfloat x, GLfloat y, GLfloat z)
3725{
3726   GET_CURRENT_CONTEXT(ctx);
3727   Node *n;
3728   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3729   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRANSLATE, 3);
3730   if (n) {
3731      n[1].f = x;
3732      n[2].f = y;
3733      n[3].f = z;
3734   }
3735   if (ctx->ExecuteFlag) {
3736      CALL_Translatef(ctx->Exec, (x, y, z));
3737   }
3738}
3739
3740
3741static void GLAPIENTRY
3742save_Translated(GLdouble x, GLdouble y, GLdouble z)
3743{
3744   save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3745}
3746
3747
3748
3749static void GLAPIENTRY
3750save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
3751{
3752   GET_CURRENT_CONTEXT(ctx);
3753   Node *n;
3754   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3755   n = ALLOC_INSTRUCTION(ctx, OPCODE_VIEWPORT, 4);
3756   if (n) {
3757      n[1].i = x;
3758      n[2].i = y;
3759      n[3].i = (GLint) width;
3760      n[4].i = (GLint) height;
3761   }
3762   if (ctx->ExecuteFlag) {
3763      CALL_Viewport(ctx->Exec, (x, y, width, height));
3764   }
3765}
3766
3767
3768static void GLAPIENTRY
3769save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3770{
3771   GET_CURRENT_CONTEXT(ctx);
3772   Node *n;
3773   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3774   n = ALLOC_INSTRUCTION(ctx, OPCODE_WINDOW_POS, 4);
3775   if (n) {
3776      n[1].f = x;
3777      n[2].f = y;
3778      n[3].f = z;
3779      n[4].f = w;
3780   }
3781   if (ctx->ExecuteFlag) {
3782      CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
3783   }
3784}
3785
3786static void GLAPIENTRY
3787save_WindowPos2dMESA(GLdouble x, GLdouble y)
3788{
3789   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3790}
3791
3792static void GLAPIENTRY
3793save_WindowPos2fMESA(GLfloat x, GLfloat y)
3794{
3795   save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3796}
3797
3798static void GLAPIENTRY
3799save_WindowPos2iMESA(GLint x, GLint y)
3800{
3801   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3802}
3803
3804static void GLAPIENTRY
3805save_WindowPos2sMESA(GLshort x, GLshort y)
3806{
3807   save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3808}
3809
3810static void GLAPIENTRY
3811save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3812{
3813   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3814}
3815
3816static void GLAPIENTRY
3817save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3818{
3819   save_WindowPos4fMESA(x, y, z, 1.0F);
3820}
3821
3822static void GLAPIENTRY
3823save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3824{
3825   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3826}
3827
3828static void GLAPIENTRY
3829save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3830{
3831   save_WindowPos4fMESA(x, y, z, 1.0F);
3832}
3833
3834static void GLAPIENTRY
3835save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3836{
3837   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3838}
3839
3840static void GLAPIENTRY
3841save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3842{
3843   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3844}
3845
3846static void GLAPIENTRY
3847save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3848{
3849   save_WindowPos4fMESA(x, y, z, w);
3850}
3851
3852static void GLAPIENTRY
3853save_WindowPos2dvMESA(const GLdouble * v)
3854{
3855   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3856}
3857
3858static void GLAPIENTRY
3859save_WindowPos2fvMESA(const GLfloat * v)
3860{
3861   save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3862}
3863
3864static void GLAPIENTRY
3865save_WindowPos2ivMESA(const GLint * v)
3866{
3867   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3868}
3869
3870static void GLAPIENTRY
3871save_WindowPos2svMESA(const GLshort * v)
3872{
3873   save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3874}
3875
3876static void GLAPIENTRY
3877save_WindowPos3dvMESA(const GLdouble * v)
3878{
3879   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3880}
3881
3882static void GLAPIENTRY
3883save_WindowPos3fvMESA(const GLfloat * v)
3884{
3885   save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3886}
3887
3888static void GLAPIENTRY
3889save_WindowPos3ivMESA(const GLint * v)
3890{
3891   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3892}
3893
3894static void GLAPIENTRY
3895save_WindowPos3svMESA(const GLshort * v)
3896{
3897   save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3898}
3899
3900static void GLAPIENTRY
3901save_WindowPos4dvMESA(const GLdouble * v)
3902{
3903   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3904                        (GLfloat) v[2], (GLfloat) v[3]);
3905}
3906
3907static void GLAPIENTRY
3908save_WindowPos4fvMESA(const GLfloat * v)
3909{
3910   save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3911}
3912
3913static void GLAPIENTRY
3914save_WindowPos4ivMESA(const GLint * v)
3915{
3916   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
3917                        (GLfloat) v[2], (GLfloat) v[3]);
3918}
3919
3920static void GLAPIENTRY
3921save_WindowPos4svMESA(const GLshort * v)
3922{
3923   save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3924}
3925
3926
3927
3928/* GL_ARB_multitexture */
3929static void GLAPIENTRY
3930save_ActiveTextureARB(GLenum target)
3931{
3932   GET_CURRENT_CONTEXT(ctx);
3933   Node *n;
3934   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3935   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_TEXTURE, 1);
3936   if (n) {
3937      n[1].e = target;
3938   }
3939   if (ctx->ExecuteFlag) {
3940      CALL_ActiveTextureARB(ctx->Exec, (target));
3941   }
3942}
3943
3944
3945/* GL_ARB_transpose_matrix */
3946
3947static void GLAPIENTRY
3948save_LoadTransposeMatrixdARB(const GLdouble m[16])
3949{
3950   GLfloat tm[16];
3951   _math_transposefd(tm, m);
3952   save_LoadMatrixf(tm);
3953}
3954
3955
3956static void GLAPIENTRY
3957save_LoadTransposeMatrixfARB(const GLfloat m[16])
3958{
3959   GLfloat tm[16];
3960   _math_transposef(tm, m);
3961   save_LoadMatrixf(tm);
3962}
3963
3964
3965static void GLAPIENTRY
3966save_MultTransposeMatrixdARB(const GLdouble m[16])
3967{
3968   GLfloat tm[16];
3969   _math_transposefd(tm, m);
3970   save_MultMatrixf(tm);
3971}
3972
3973
3974static void GLAPIENTRY
3975save_MultTransposeMatrixfARB(const GLfloat m[16])
3976{
3977   GLfloat tm[16];
3978   _math_transposef(tm, m);
3979   save_MultMatrixf(tm);
3980}
3981
3982
3983/* GL_ARB_texture_compression */
3984static void GLAPIENTRY
3985save_CompressedTexImage1DARB(GLenum target, GLint level,
3986                             GLenum internalFormat, GLsizei width,
3987                             GLint border, GLsizei imageSize,
3988                             const GLvoid * data)
3989{
3990   GET_CURRENT_CONTEXT(ctx);
3991   if (target == GL_PROXY_TEXTURE_1D) {
3992      /* don't compile, execute immediately */
3993      CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat,
3994                                               width, border, imageSize,
3995                                               data));
3996   }
3997   else {
3998      Node *n;
3999      GLvoid *image;
4000      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4001      /* make copy of image */
4002      image = _mesa_malloc(imageSize);
4003      if (!image) {
4004         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
4005         return;
4006      }
4007      MEMCPY(image, data, imageSize);
4008      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
4009      if (n) {
4010         n[1].e = target;
4011         n[2].i = level;
4012         n[3].e = internalFormat;
4013         n[4].i = (GLint) width;
4014         n[5].i = border;
4015         n[6].i = imageSize;
4016         n[7].data = image;
4017      }
4018      else if (image) {
4019         _mesa_free(image);
4020      }
4021      if (ctx->ExecuteFlag) {
4022         CALL_CompressedTexImage1DARB(ctx->Exec,
4023                                      (target, level, internalFormat, width,
4024                                       border, imageSize, data));
4025      }
4026   }
4027}
4028
4029
4030static void GLAPIENTRY
4031save_CompressedTexImage2DARB(GLenum target, GLint level,
4032                             GLenum internalFormat, GLsizei width,
4033                             GLsizei height, GLint border, GLsizei imageSize,
4034                             const GLvoid * data)
4035{
4036   GET_CURRENT_CONTEXT(ctx);
4037   if (target == GL_PROXY_TEXTURE_2D) {
4038      /* don't compile, execute immediately */
4039      CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat,
4040                                               width, height, border,
4041                                               imageSize, data));
4042   }
4043   else {
4044      Node *n;
4045      GLvoid *image;
4046      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4047      /* make copy of image */
4048      image = _mesa_malloc(imageSize);
4049      if (!image) {
4050         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
4051         return;
4052      }
4053      MEMCPY(image, data, imageSize);
4054      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
4055      if (n) {
4056         n[1].e = target;
4057         n[2].i = level;
4058         n[3].e = internalFormat;
4059         n[4].i = (GLint) width;
4060         n[5].i = (GLint) height;
4061         n[6].i = border;
4062         n[7].i = imageSize;
4063         n[8].data = image;
4064      }
4065      else if (image) {
4066         _mesa_free(image);
4067      }
4068      if (ctx->ExecuteFlag) {
4069         CALL_CompressedTexImage2DARB(ctx->Exec,
4070                                      (target, level, internalFormat, width,
4071                                       height, border, imageSize, data));
4072      }
4073   }
4074}
4075
4076
4077static void GLAPIENTRY
4078save_CompressedTexImage3DARB(GLenum target, GLint level,
4079                             GLenum internalFormat, GLsizei width,
4080                             GLsizei height, GLsizei depth, GLint border,
4081                             GLsizei imageSize, const GLvoid * data)
4082{
4083   GET_CURRENT_CONTEXT(ctx);
4084   if (target == GL_PROXY_TEXTURE_3D) {
4085      /* don't compile, execute immediately */
4086      CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat,
4087                                               width, height, depth, border,
4088                                               imageSize, data));
4089   }
4090   else {
4091      Node *n;
4092      GLvoid *image;
4093      ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4094      /* make copy of image */
4095      image = _mesa_malloc(imageSize);
4096      if (!image) {
4097         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
4098         return;
4099      }
4100      MEMCPY(image, data, imageSize);
4101      n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
4102      if (n) {
4103         n[1].e = target;
4104         n[2].i = level;
4105         n[3].e = internalFormat;
4106         n[4].i = (GLint) width;
4107         n[5].i = (GLint) height;
4108         n[6].i = (GLint) depth;
4109         n[7].i = border;
4110         n[8].i = imageSize;
4111         n[9].data = image;
4112      }
4113      else if (image) {
4114         _mesa_free(image);
4115      }
4116      if (ctx->ExecuteFlag) {
4117         CALL_CompressedTexImage3DARB(ctx->Exec,
4118                                      (target, level, internalFormat, width,
4119                                       height, depth, border, imageSize,
4120                                       data));
4121      }
4122   }
4123}
4124
4125
4126static void GLAPIENTRY
4127save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
4128                                GLsizei width, GLenum format,
4129                                GLsizei imageSize, const GLvoid * data)
4130{
4131   Node *n;
4132   GLvoid *image;
4133
4134   GET_CURRENT_CONTEXT(ctx);
4135   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4136
4137   /* make copy of image */
4138   image = _mesa_malloc(imageSize);
4139   if (!image) {
4140      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
4141      return;
4142   }
4143   MEMCPY(image, data, imageSize);
4144   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
4145   if (n) {
4146      n[1].e = target;
4147      n[2].i = level;
4148      n[3].i = xoffset;
4149      n[4].i = (GLint) width;
4150      n[5].e = format;
4151      n[6].i = imageSize;
4152      n[7].data = image;
4153   }
4154   else if (image) {
4155      _mesa_free(image);
4156   }
4157   if (ctx->ExecuteFlag) {
4158      CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset,
4159                                                  width, format, imageSize,
4160                                                  data));
4161   }
4162}
4163
4164
4165static void GLAPIENTRY
4166save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
4167                                GLint yoffset, GLsizei width, GLsizei height,
4168                                GLenum format, GLsizei imageSize,
4169                                const GLvoid * data)
4170{
4171   Node *n;
4172   GLvoid *image;
4173
4174   GET_CURRENT_CONTEXT(ctx);
4175   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4176
4177   /* make copy of image */
4178   image = _mesa_malloc(imageSize);
4179   if (!image) {
4180      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
4181      return;
4182   }
4183   MEMCPY(image, data, imageSize);
4184   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
4185   if (n) {
4186      n[1].e = target;
4187      n[2].i = level;
4188      n[3].i = xoffset;
4189      n[4].i = yoffset;
4190      n[5].i = (GLint) width;
4191      n[6].i = (GLint) height;
4192      n[7].e = format;
4193      n[8].i = imageSize;
4194      n[9].data = image;
4195   }
4196   else if (image) {
4197      _mesa_free(image);
4198   }
4199   if (ctx->ExecuteFlag) {
4200      CALL_CompressedTexSubImage2DARB(ctx->Exec,
4201                                      (target, level, xoffset, yoffset, width,
4202                                       height, format, imageSize, data));
4203   }
4204}
4205
4206
4207static void GLAPIENTRY
4208save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4209                                GLint yoffset, GLint zoffset, GLsizei width,
4210                                GLsizei height, GLsizei depth, GLenum format,
4211                                GLsizei imageSize, const GLvoid * data)
4212{
4213   Node *n;
4214   GLvoid *image;
4215
4216   GET_CURRENT_CONTEXT(ctx);
4217   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4218
4219   /* make copy of image */
4220   image = _mesa_malloc(imageSize);
4221   if (!image) {
4222      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
4223      return;
4224   }
4225   MEMCPY(image, data, imageSize);
4226   n = ALLOC_INSTRUCTION(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
4227   if (n) {
4228      n[1].e = target;
4229      n[2].i = level;
4230      n[3].i = xoffset;
4231      n[4].i = yoffset;
4232      n[5].i = zoffset;
4233      n[6].i = (GLint) width;
4234      n[7].i = (GLint) height;
4235      n[8].i = (GLint) depth;
4236      n[9].e = format;
4237      n[10].i = imageSize;
4238      n[11].data = image;
4239   }
4240   else if (image) {
4241      _mesa_free(image);
4242   }
4243   if (ctx->ExecuteFlag) {
4244      CALL_CompressedTexSubImage3DARB(ctx->Exec,
4245                                      (target, level, xoffset, yoffset,
4246                                       zoffset, width, height, depth, format,
4247                                       imageSize, data));
4248   }
4249}
4250
4251
4252/* GL_ARB_multisample */
4253static void GLAPIENTRY
4254save_SampleCoverageARB(GLclampf value, GLboolean invert)
4255{
4256   GET_CURRENT_CONTEXT(ctx);
4257   Node *n;
4258   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4259   n = ALLOC_INSTRUCTION(ctx, OPCODE_SAMPLE_COVERAGE, 2);
4260   if (n) {
4261      n[1].f = value;
4262      n[2].b = invert;
4263   }
4264   if (ctx->ExecuteFlag) {
4265      CALL_SampleCoverageARB(ctx->Exec, (value, invert));
4266   }
4267}
4268
4269
4270/*
4271 * GL_NV_vertex_program
4272 */
4273#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4274static void GLAPIENTRY
4275save_BindProgramNV(GLenum target, GLuint id)
4276{
4277   GET_CURRENT_CONTEXT(ctx);
4278   Node *n;
4279   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4280   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_PROGRAM_NV, 2);
4281   if (n) {
4282      n[1].e = target;
4283      n[2].ui = id;
4284   }
4285   if (ctx->ExecuteFlag) {
4286      CALL_BindProgramNV(ctx->Exec, (target, id));
4287   }
4288}
4289
4290static void GLAPIENTRY
4291save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4292                              GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4293{
4294   GET_CURRENT_CONTEXT(ctx);
4295   Node *n;
4296   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4297   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4298   if (n) {
4299      n[1].e = target;
4300      n[2].ui = index;
4301      n[3].f = x;
4302      n[4].f = y;
4303      n[5].f = z;
4304      n[6].f = w;
4305   }
4306   if (ctx->ExecuteFlag) {
4307      CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4308   }
4309}
4310
4311
4312static void GLAPIENTRY
4313save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4314                               const GLfloat *params)
4315{
4316   save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4317                                 params[2], params[3]);
4318}
4319
4320
4321static void GLAPIENTRY
4322save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4323				const GLfloat * params)
4324{
4325   GET_CURRENT_CONTEXT(ctx);
4326   Node *n;
4327   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4328
4329   if (count > 0) {
4330      GLint i;
4331      const GLfloat * p = params;
4332
4333      for (i = 0 ; i < count ; i++) {
4334	 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4335	 if (n) {
4336	    n[1].e = target;
4337	    n[2].ui = index;
4338	    n[3].f = p[0];
4339	    n[4].f = p[1];
4340	    n[5].f = p[2];
4341	    n[6].f = p[3];
4342	    p += 4;
4343	 }
4344      }
4345   }
4346
4347   if (ctx->ExecuteFlag) {
4348      CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
4349   }
4350}
4351
4352
4353static void GLAPIENTRY
4354save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4355                              GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4356{
4357   save_ProgramEnvParameter4fARB(target, index,
4358                                 (GLfloat) x,
4359                                 (GLfloat) y, (GLfloat) z, (GLfloat) w);
4360}
4361
4362
4363static void GLAPIENTRY
4364save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4365                               const GLdouble *params)
4366{
4367   save_ProgramEnvParameter4fARB(target, index,
4368                                 (GLfloat) params[0],
4369                                 (GLfloat) params[1],
4370                                 (GLfloat) params[2], (GLfloat) params[3]);
4371}
4372
4373#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */
4374
4375#if FEATURE_NV_vertex_program
4376static void GLAPIENTRY
4377save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
4378{
4379   GET_CURRENT_CONTEXT(ctx);
4380   Node *n;
4381   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4382   n = ALLOC_INSTRUCTION(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
4383   if (n) {
4384      n[1].e = target;
4385      n[2].ui = id;
4386      n[3].f = params[0];
4387      n[4].f = params[1];
4388      n[5].f = params[2];
4389      n[6].f = params[3];
4390   }
4391   if (ctx->ExecuteFlag) {
4392      CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
4393   }
4394}
4395
4396
4397static void GLAPIENTRY
4398save_ProgramParameters4dvNV(GLenum target, GLuint index,
4399                            GLuint num, const GLdouble *params)
4400{
4401   GLuint i;
4402   for (i = 0; i < num; i++) {
4403      save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i);
4404   }
4405}
4406
4407
4408static void GLAPIENTRY
4409save_ProgramParameters4fvNV(GLenum target, GLuint index,
4410                            GLuint num, const GLfloat *params)
4411{
4412   GLuint i;
4413   for (i = 0; i < num; i++) {
4414      save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i);
4415   }
4416}
4417
4418
4419static void GLAPIENTRY
4420save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
4421                   const GLubyte * program)
4422{
4423   GET_CURRENT_CONTEXT(ctx);
4424   Node *n;
4425   GLubyte *programCopy;
4426
4427   programCopy = (GLubyte *) _mesa_malloc(len);
4428   if (!programCopy) {
4429      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
4430      return;
4431   }
4432   _mesa_memcpy(programCopy, program, len);
4433
4434   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4435   n = ALLOC_INSTRUCTION(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
4436   if (n) {
4437      n[1].e = target;
4438      n[2].ui = id;
4439      n[3].i = len;
4440      n[4].data = programCopy;
4441   }
4442   if (ctx->ExecuteFlag) {
4443      CALL_LoadProgramNV(ctx->Exec, (target, id, len, program));
4444   }
4445}
4446
4447
4448static void GLAPIENTRY
4449save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
4450{
4451   GET_CURRENT_CONTEXT(ctx);
4452   Node *n;
4453   GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
4454   if (!idCopy) {
4455      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
4456      return;
4457   }
4458   _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
4459   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4460   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 2);
4461   if (n) {
4462      n[1].i = num;
4463      n[2].data = idCopy;
4464   }
4465   if (ctx->ExecuteFlag) {
4466      CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids));
4467   }
4468}
4469
4470
4471static void GLAPIENTRY
4472save_TrackMatrixNV(GLenum target, GLuint address,
4473                   GLenum matrix, GLenum transform)
4474{
4475   GET_CURRENT_CONTEXT(ctx);
4476   Node *n;
4477   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4478   n = ALLOC_INSTRUCTION(ctx, OPCODE_TRACK_MATRIX_NV, 4);
4479   if (n) {
4480      n[1].e = target;
4481      n[2].ui = address;
4482      n[3].e = matrix;
4483      n[4].e = transform;
4484   }
4485   if (ctx->ExecuteFlag) {
4486      CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform));
4487   }
4488}
4489#endif /* FEATURE_NV_vertex_program */
4490
4491
4492/*
4493 * GL_NV_fragment_program
4494 */
4495#if FEATURE_NV_fragment_program
4496static void GLAPIENTRY
4497save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
4498                                GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4499{
4500   GET_CURRENT_CONTEXT(ctx);
4501   Node *n;
4502   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4503   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4504   if (n) {
4505      n[1].e = target;
4506      n[2].ui = index;
4507      n[3].f = x;
4508      n[4].f = y;
4509      n[5].f = z;
4510      n[6].f = w;
4511   }
4512   if (ctx->ExecuteFlag) {
4513      CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4514   }
4515}
4516
4517
4518static void GLAPIENTRY
4519save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
4520                                 const GLfloat *params)
4521{
4522   GET_CURRENT_CONTEXT(ctx);
4523   Node *n;
4524   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4525   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4526   if (n) {
4527      n[1].e = target;
4528      n[2].ui = index;
4529      n[3].f = params[0];
4530      n[4].f = params[1];
4531      n[5].f = params[2];
4532      n[6].f = params[3];
4533   }
4534   if (ctx->ExecuteFlag) {
4535      CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
4536   }
4537}
4538
4539
4540static void GLAPIENTRY
4541save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4542				  const GLfloat *params)
4543{
4544   GET_CURRENT_CONTEXT(ctx);
4545   Node *n;
4546   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4547
4548   if (count > 0) {
4549      GLint i;
4550      const GLfloat * p = params;
4551
4552      for (i = 0 ; i < count ; i++) {
4553	 n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4554	 if (n) {
4555	    n[1].e = target;
4556	    n[2].ui = index;
4557	    n[3].f = p[0];
4558	    n[4].f = p[1];
4559	    n[5].f = p[2];
4560	    n[6].f = p[3];
4561	    p += 4;
4562	 }
4563      }
4564   }
4565
4566   if (ctx->ExecuteFlag) {
4567      CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
4568   }
4569}
4570
4571
4572static void GLAPIENTRY
4573save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
4574                                GLdouble x, GLdouble y,
4575                                GLdouble z, GLdouble w)
4576{
4577   GET_CURRENT_CONTEXT(ctx);
4578   Node *n;
4579   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4580   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4581   if (n) {
4582      n[1].e = target;
4583      n[2].ui = index;
4584      n[3].f = (GLfloat) x;
4585      n[4].f = (GLfloat) y;
4586      n[5].f = (GLfloat) z;
4587      n[6].f = (GLfloat) w;
4588   }
4589   if (ctx->ExecuteFlag) {
4590      CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
4591   }
4592}
4593
4594
4595static void GLAPIENTRY
4596save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
4597                                 const GLdouble *params)
4598{
4599   GET_CURRENT_CONTEXT(ctx);
4600   Node *n;
4601   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4602   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
4603   if (n) {
4604      n[1].e = target;
4605      n[2].ui = index;
4606      n[3].f = (GLfloat) params[0];
4607      n[4].f = (GLfloat) params[1];
4608      n[5].f = (GLfloat) params[2];
4609      n[6].f = (GLfloat) params[3];
4610   }
4611   if (ctx->ExecuteFlag) {
4612      CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
4613   }
4614}
4615
4616static void GLAPIENTRY
4617save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
4618                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4619{
4620   GET_CURRENT_CONTEXT(ctx);
4621   Node *n;
4622   GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
4623   if (!nameCopy) {
4624      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
4625      return;
4626   }
4627   _mesa_memcpy(nameCopy, name, len);
4628
4629   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4630   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
4631   if (n) {
4632      n[1].ui = id;
4633      n[2].i = len;
4634      n[3].data = nameCopy;
4635      n[4].f = x;
4636      n[5].f = y;
4637      n[6].f = z;
4638      n[7].f = w;
4639   }
4640   if (ctx->ExecuteFlag) {
4641      CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w));
4642   }
4643}
4644
4645
4646static void GLAPIENTRY
4647save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name,
4648                                const float v[])
4649{
4650   save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
4651}
4652
4653
4654static void GLAPIENTRY
4655save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name,
4656                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4657{
4658   save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
4659                                  (GLfloat) z, (GLfloat) w);
4660}
4661
4662
4663static void GLAPIENTRY
4664save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name,
4665                                const double v[])
4666{
4667   save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
4668                                  (GLfloat) v[1], (GLfloat) v[2],
4669                                  (GLfloat) v[3]);
4670}
4671
4672#endif /* FEATURE_NV_fragment_program */
4673
4674
4675
4676/* GL_EXT_stencil_two_side */
4677static void GLAPIENTRY
4678save_ActiveStencilFaceEXT(GLenum face)
4679{
4680   GET_CURRENT_CONTEXT(ctx);
4681   Node *n;
4682   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4683   n = ALLOC_INSTRUCTION(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
4684   if (n) {
4685      n[1].e = face;
4686   }
4687   if (ctx->ExecuteFlag) {
4688      CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
4689   }
4690}
4691
4692
4693/* GL_EXT_depth_bounds_test */
4694static void GLAPIENTRY
4695save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
4696{
4697   GET_CURRENT_CONTEXT(ctx);
4698   Node *n;
4699   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4700   n = ALLOC_INSTRUCTION(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
4701   if (n) {
4702      n[1].f = (GLfloat) zmin;
4703      n[2].f = (GLfloat) zmax;
4704   }
4705   if (ctx->ExecuteFlag) {
4706      CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
4707   }
4708}
4709
4710
4711
4712#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4713
4714static void GLAPIENTRY
4715save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
4716                      const GLvoid * string)
4717{
4718   GET_CURRENT_CONTEXT(ctx);
4719   Node *n;
4720   GLubyte *programCopy;
4721
4722   programCopy = (GLubyte *) _mesa_malloc(len);
4723   if (!programCopy) {
4724      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
4725      return;
4726   }
4727   _mesa_memcpy(programCopy, string, len);
4728
4729   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4730   n = ALLOC_INSTRUCTION(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
4731   if (n) {
4732      n[1].e = target;
4733      n[2].e = format;
4734      n[3].i = len;
4735      n[4].data = programCopy;
4736   }
4737   if (ctx->ExecuteFlag) {
4738      CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
4739   }
4740}
4741
4742#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
4743
4744
4745#if FEATURE_ARB_occlusion_query
4746
4747static void GLAPIENTRY
4748save_BeginQueryARB(GLenum target, GLuint id)
4749{
4750   GET_CURRENT_CONTEXT(ctx);
4751   Node *n;
4752   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4753   n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
4754   if (n) {
4755      n[1].e = target;
4756      n[2].ui = id;
4757   }
4758   if (ctx->ExecuteFlag) {
4759      CALL_BeginQueryARB(ctx->Exec, (target, id));
4760   }
4761}
4762
4763
4764static void GLAPIENTRY
4765save_EndQueryARB(GLenum target)
4766{
4767   GET_CURRENT_CONTEXT(ctx);
4768   Node *n;
4769   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4770   n = ALLOC_INSTRUCTION(ctx, OPCODE_END_QUERY_ARB, 1);
4771   if (n) {
4772      n[1].e = target;
4773   }
4774   if (ctx->ExecuteFlag) {
4775      CALL_EndQueryARB(ctx->Exec, (target));
4776   }
4777}
4778
4779#endif /* FEATURE_ARB_occlusion_query */
4780
4781
4782static void GLAPIENTRY
4783save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
4784{
4785   GET_CURRENT_CONTEXT(ctx);
4786   Node *n;
4787   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4788   n = ALLOC_INSTRUCTION(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
4789   if (n) {
4790      GLint i;
4791      n[1].i = count;
4792      if (count > MAX_DRAW_BUFFERS)
4793         count = MAX_DRAW_BUFFERS;
4794      for (i = 0; i < count; i++) {
4795         n[2 + i].e = buffers[i];
4796      }
4797   }
4798   if (ctx->ExecuteFlag) {
4799      CALL_DrawBuffersARB(ctx->Exec, (count, buffers));
4800   }
4801}
4802
4803#if FEATURE_ATI_fragment_shader
4804static void GLAPIENTRY
4805save_BindFragmentShaderATI(GLuint id)
4806{
4807   GET_CURRENT_CONTEXT(ctx);
4808   Node *n;
4809
4810   n = ALLOC_INSTRUCTION(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
4811   if (n) {
4812      n[1].ui = id;
4813   }
4814   if (ctx->ExecuteFlag) {
4815      CALL_BindFragmentShaderATI(ctx->Exec, (id));
4816   }
4817}
4818
4819static void GLAPIENTRY
4820save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
4821{
4822   GET_CURRENT_CONTEXT(ctx);
4823   Node *n;
4824
4825   n = ALLOC_INSTRUCTION(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
4826   if (n) {
4827      n[1].ui = dst;
4828      n[2].f = value[0];
4829      n[3].f = value[1];
4830      n[4].f = value[2];
4831      n[5].f = value[3];
4832   }
4833   if (ctx->ExecuteFlag) {
4834      CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
4835   }
4836}
4837#endif
4838
4839static void
4840save_Attr1fNV(GLenum attr, GLfloat x)
4841{
4842   GET_CURRENT_CONTEXT(ctx);
4843   Node *n;
4844   SAVE_FLUSH_VERTICES(ctx);
4845   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_NV, 2);
4846   if (n) {
4847      n[1].e = attr;
4848      n[2].f = x;
4849   }
4850
4851   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4852   ctx->ListState.ActiveAttribSize[attr] = 1;
4853   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
4854
4855   if (ctx->ExecuteFlag) {
4856      CALL_VertexAttrib1fNV(ctx->Exec, (attr, x));
4857   }
4858}
4859
4860static void
4861save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
4862{
4863   GET_CURRENT_CONTEXT(ctx);
4864   Node *n;
4865   SAVE_FLUSH_VERTICES(ctx);
4866   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_NV, 3);
4867   if (n) {
4868      n[1].e = attr;
4869      n[2].f = x;
4870      n[3].f = y;
4871   }
4872
4873   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4874   ctx->ListState.ActiveAttribSize[attr] = 2;
4875   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
4876
4877   if (ctx->ExecuteFlag) {
4878      CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y));
4879   }
4880}
4881
4882static void
4883save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
4884{
4885   GET_CURRENT_CONTEXT(ctx);
4886   Node *n;
4887   SAVE_FLUSH_VERTICES(ctx);
4888   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_NV, 4);
4889   if (n) {
4890      n[1].e = attr;
4891      n[2].f = x;
4892      n[3].f = y;
4893      n[4].f = z;
4894   }
4895
4896   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4897   ctx->ListState.ActiveAttribSize[attr] = 3;
4898   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
4899
4900   if (ctx->ExecuteFlag) {
4901      CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z));
4902   }
4903}
4904
4905static void
4906save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4907{
4908   GET_CURRENT_CONTEXT(ctx);
4909   Node *n;
4910   SAVE_FLUSH_VERTICES(ctx);
4911   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_NV, 5);
4912   if (n) {
4913      n[1].e = attr;
4914      n[2].f = x;
4915      n[3].f = y;
4916      n[4].f = z;
4917      n[5].f = w;
4918   }
4919
4920   ASSERT(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
4921   ctx->ListState.ActiveAttribSize[attr] = 4;
4922   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
4923
4924   if (ctx->ExecuteFlag) {
4925      CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w));
4926   }
4927}
4928
4929
4930static void
4931save_Attr1fARB(GLenum attr, GLfloat x)
4932{
4933   GET_CURRENT_CONTEXT(ctx);
4934   Node *n;
4935   SAVE_FLUSH_VERTICES(ctx);
4936   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_1F_ARB, 2);
4937   if (n) {
4938      n[1].e = attr;
4939      n[2].f = x;
4940   }
4941
4942   ASSERT(attr < MAX_VERTEX_ATTRIBS);
4943   ctx->ListState.ActiveAttribSize[attr] = 1;
4944   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
4945
4946   if (ctx->ExecuteFlag) {
4947      CALL_VertexAttrib1fARB(ctx->Exec, (attr, x));
4948   }
4949}
4950
4951static void
4952save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
4953{
4954   GET_CURRENT_CONTEXT(ctx);
4955   Node *n;
4956   SAVE_FLUSH_VERTICES(ctx);
4957   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_2F_ARB, 3);
4958   if (n) {
4959      n[1].e = attr;
4960      n[2].f = x;
4961      n[3].f = y;
4962   }
4963
4964   ASSERT(attr < MAX_VERTEX_ATTRIBS);
4965   ctx->ListState.ActiveAttribSize[attr] = 2;
4966   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
4967
4968   if (ctx->ExecuteFlag) {
4969      CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y));
4970   }
4971}
4972
4973static void
4974save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
4975{
4976   GET_CURRENT_CONTEXT(ctx);
4977   Node *n;
4978   SAVE_FLUSH_VERTICES(ctx);
4979   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_3F_ARB, 4);
4980   if (n) {
4981      n[1].e = attr;
4982      n[2].f = x;
4983      n[3].f = y;
4984      n[4].f = z;
4985   }
4986
4987   ASSERT(attr < MAX_VERTEX_ATTRIBS);
4988   ctx->ListState.ActiveAttribSize[attr] = 3;
4989   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
4990
4991   if (ctx->ExecuteFlag) {
4992      CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z));
4993   }
4994}
4995
4996static void
4997save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4998{
4999   GET_CURRENT_CONTEXT(ctx);
5000   Node *n;
5001   SAVE_FLUSH_VERTICES(ctx);
5002   n = ALLOC_INSTRUCTION(ctx, OPCODE_ATTR_4F_ARB, 5);
5003   if (n) {
5004      n[1].e = attr;
5005      n[2].f = x;
5006      n[3].f = y;
5007      n[4].f = z;
5008      n[5].f = w;
5009   }
5010
5011   ASSERT(attr < MAX_VERTEX_ATTRIBS);
5012   ctx->ListState.ActiveAttribSize[attr] = 4;
5013   ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5014
5015   if (ctx->ExecuteFlag) {
5016      CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w));
5017   }
5018}
5019
5020
5021static void GLAPIENTRY
5022save_EvalCoord1f(GLfloat x)
5023{
5024   GET_CURRENT_CONTEXT(ctx);
5025   Node *n;
5026   SAVE_FLUSH_VERTICES(ctx);
5027   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C1, 1);
5028   if (n) {
5029      n[1].f = x;
5030   }
5031   if (ctx->ExecuteFlag) {
5032      CALL_EvalCoord1f(ctx->Exec, (x));
5033   }
5034}
5035
5036static void GLAPIENTRY
5037save_EvalCoord1fv(const GLfloat * v)
5038{
5039   save_EvalCoord1f(v[0]);
5040}
5041
5042static void GLAPIENTRY
5043save_EvalCoord2f(GLfloat x, GLfloat y)
5044{
5045   GET_CURRENT_CONTEXT(ctx);
5046   Node *n;
5047   SAVE_FLUSH_VERTICES(ctx);
5048   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_C2, 2);
5049   if (n) {
5050      n[1].f = x;
5051      n[2].f = y;
5052   }
5053   if (ctx->ExecuteFlag) {
5054      CALL_EvalCoord2f(ctx->Exec, (x, y));
5055   }
5056}
5057
5058static void GLAPIENTRY
5059save_EvalCoord2fv(const GLfloat * v)
5060{
5061   save_EvalCoord2f(v[0], v[1]);
5062}
5063
5064
5065static void GLAPIENTRY
5066save_EvalPoint1(GLint x)
5067{
5068   GET_CURRENT_CONTEXT(ctx);
5069   Node *n;
5070   SAVE_FLUSH_VERTICES(ctx);
5071   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P1, 1);
5072   if (n) {
5073      n[1].i = x;
5074   }
5075   if (ctx->ExecuteFlag) {
5076      CALL_EvalPoint1(ctx->Exec, (x));
5077   }
5078}
5079
5080static void GLAPIENTRY
5081save_EvalPoint2(GLint x, GLint y)
5082{
5083   GET_CURRENT_CONTEXT(ctx);
5084   Node *n;
5085   SAVE_FLUSH_VERTICES(ctx);
5086   n = ALLOC_INSTRUCTION(ctx, OPCODE_EVAL_P2, 2);
5087   if (n) {
5088      n[1].i = x;
5089      n[2].i = y;
5090   }
5091   if (ctx->ExecuteFlag) {
5092      CALL_EvalPoint2(ctx->Exec, (x, y));
5093   }
5094}
5095
5096static void GLAPIENTRY
5097save_Indexf(GLfloat x)
5098{
5099   save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x);
5100}
5101
5102static void GLAPIENTRY
5103save_Indexfv(const GLfloat * v)
5104{
5105   save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]);
5106}
5107
5108static void GLAPIENTRY
5109save_EdgeFlag(GLboolean x)
5110{
5111   save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0);
5112}
5113
5114static void GLAPIENTRY
5115save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5116{
5117   GET_CURRENT_CONTEXT(ctx);
5118   Node *n;
5119   int args, i;
5120
5121   SAVE_FLUSH_VERTICES(ctx);
5122
5123   switch (face) {
5124   case GL_BACK:
5125   case GL_FRONT:
5126   case GL_FRONT_AND_BACK:
5127      break;
5128   default:
5129      _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)");
5130      return;
5131   }
5132
5133   switch (pname) {
5134   case GL_EMISSION:
5135   case GL_AMBIENT:
5136   case GL_DIFFUSE:
5137   case GL_SPECULAR:
5138   case GL_AMBIENT_AND_DIFFUSE:
5139      args = 4;
5140      break;
5141   case GL_SHININESS:
5142      args = 1;
5143      break;
5144   case GL_COLOR_INDEXES:
5145      args = 3;
5146      break;
5147   default:
5148      _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)");
5149      return;
5150   }
5151
5152   n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
5153   if (n) {
5154      n[1].e = face;
5155      n[2].e = pname;
5156      for (i = 0; i < args; i++)
5157         n[3 + i].f = param[i];
5158   }
5159
5160   {
5161      GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5162      for (i = 0; i < MAT_ATTRIB_MAX; i++)
5163         if (bitmask & (1 << i)) {
5164            ctx->ListState.ActiveMaterialSize[i] = args;
5165            COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5166         }
5167   }
5168
5169   if (ctx->ExecuteFlag) {
5170      CALL_Materialfv(ctx->Exec, (face, pname, param));
5171   }
5172}
5173
5174static void GLAPIENTRY
5175save_Begin(GLenum mode)
5176{
5177   GET_CURRENT_CONTEXT(ctx);
5178   Node *n;
5179   GLboolean error = GL_FALSE;
5180
5181   if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) {
5182      _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)");
5183      error = GL_TRUE;
5184   }
5185   else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
5186      /* Typically the first begin.  This may raise an error on
5187       * playback, depending on whether CallList is issued from inside
5188       * a begin/end or not.
5189       */
5190      ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
5191   }
5192   else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
5193      ctx->Driver.CurrentSavePrimitive = mode;
5194   }
5195   else {
5196      _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin");
5197      error = GL_TRUE;
5198   }
5199
5200   if (!error) {
5201      /* Give the driver an opportunity to hook in an optimized
5202       * display list compiler.
5203       */
5204      if (ctx->Driver.NotifySaveBegin(ctx, mode))
5205         return;
5206
5207      SAVE_FLUSH_VERTICES(ctx);
5208      n = ALLOC_INSTRUCTION(ctx, OPCODE_BEGIN, 1);
5209      if (n) {
5210         n[1].e = mode;
5211      }
5212   }
5213
5214   if (ctx->ExecuteFlag) {
5215      CALL_Begin(ctx->Exec, (mode));
5216   }
5217}
5218
5219static void GLAPIENTRY
5220save_End(void)
5221{
5222   GET_CURRENT_CONTEXT(ctx);
5223   SAVE_FLUSH_VERTICES(ctx);
5224   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END, 0);
5225   ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
5226   if (ctx->ExecuteFlag) {
5227      CALL_End(ctx->Exec, ());
5228   }
5229}
5230
5231static void GLAPIENTRY
5232save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d)
5233{
5234   GET_CURRENT_CONTEXT(ctx);
5235   Node *n;
5236   SAVE_FLUSH_VERTICES(ctx);
5237   n = ALLOC_INSTRUCTION(ctx, OPCODE_RECTF, 4);
5238   if (n) {
5239      n[1].f = a;
5240      n[2].f = b;
5241      n[3].f = c;
5242      n[4].f = d;
5243   }
5244   if (ctx->ExecuteFlag) {
5245      CALL_Rectf(ctx->Exec, (a, b, c, d));
5246   }
5247}
5248
5249
5250static void GLAPIENTRY
5251save_Vertex2f(GLfloat x, GLfloat y)
5252{
5253   save_Attr2fNV(VERT_ATTRIB_POS, x, y);
5254}
5255
5256static void GLAPIENTRY
5257save_Vertex2fv(const GLfloat * v)
5258{
5259   save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]);
5260}
5261
5262static void GLAPIENTRY
5263save_Vertex3f(GLfloat x, GLfloat y, GLfloat z)
5264{
5265   save_Attr3fNV(VERT_ATTRIB_POS, x, y, z);
5266}
5267
5268static void GLAPIENTRY
5269save_Vertex3fv(const GLfloat * v)
5270{
5271   save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]);
5272}
5273
5274static void GLAPIENTRY
5275save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5276{
5277   save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w);
5278}
5279
5280static void GLAPIENTRY
5281save_Vertex4fv(const GLfloat * v)
5282{
5283   save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]);
5284}
5285
5286static void GLAPIENTRY
5287save_TexCoord1f(GLfloat x)
5288{
5289   save_Attr1fNV(VERT_ATTRIB_TEX0, x);
5290}
5291
5292static void GLAPIENTRY
5293save_TexCoord1fv(const GLfloat * v)
5294{
5295   save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]);
5296}
5297
5298static void GLAPIENTRY
5299save_TexCoord2f(GLfloat x, GLfloat y)
5300{
5301   save_Attr2fNV(VERT_ATTRIB_TEX0, x, y);
5302}
5303
5304static void GLAPIENTRY
5305save_TexCoord2fv(const GLfloat * v)
5306{
5307   save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]);
5308}
5309
5310static void GLAPIENTRY
5311save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z)
5312{
5313   save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z);
5314}
5315
5316static void GLAPIENTRY
5317save_TexCoord3fv(const GLfloat * v)
5318{
5319   save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]);
5320}
5321
5322static void GLAPIENTRY
5323save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5324{
5325   save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w);
5326}
5327
5328static void GLAPIENTRY
5329save_TexCoord4fv(const GLfloat * v)
5330{
5331   save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]);
5332}
5333
5334static void GLAPIENTRY
5335save_Normal3f(GLfloat x, GLfloat y, GLfloat z)
5336{
5337   save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z);
5338}
5339
5340static void GLAPIENTRY
5341save_Normal3fv(const GLfloat * v)
5342{
5343   save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]);
5344}
5345
5346static void GLAPIENTRY
5347save_FogCoordfEXT(GLfloat x)
5348{
5349   save_Attr1fNV(VERT_ATTRIB_FOG, x);
5350}
5351
5352static void GLAPIENTRY
5353save_FogCoordfvEXT(const GLfloat * v)
5354{
5355   save_Attr1fNV(VERT_ATTRIB_FOG, v[0]);
5356}
5357
5358static void GLAPIENTRY
5359save_Color3f(GLfloat x, GLfloat y, GLfloat z)
5360{
5361   save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z);
5362}
5363
5364static void GLAPIENTRY
5365save_Color3fv(const GLfloat * v)
5366{
5367   save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]);
5368}
5369
5370static void GLAPIENTRY
5371save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5372{
5373   save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w);
5374}
5375
5376static void GLAPIENTRY
5377save_Color4fv(const GLfloat * v)
5378{
5379   save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]);
5380}
5381
5382static void GLAPIENTRY
5383save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z)
5384{
5385   save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z);
5386}
5387
5388static void GLAPIENTRY
5389save_SecondaryColor3fvEXT(const GLfloat * v)
5390{
5391   save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]);
5392}
5393
5394
5395/* Just call the respective ATTR for texcoord
5396 */
5397static void GLAPIENTRY
5398save_MultiTexCoord1f(GLenum target, GLfloat x)
5399{
5400   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5401   save_Attr1fNV(attr, x);
5402}
5403
5404static void GLAPIENTRY
5405save_MultiTexCoord1fv(GLenum target, const GLfloat * v)
5406{
5407   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5408   save_Attr1fNV(attr, v[0]);
5409}
5410
5411static void GLAPIENTRY
5412save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y)
5413{
5414   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5415   save_Attr2fNV(attr, x, y);
5416}
5417
5418static void GLAPIENTRY
5419save_MultiTexCoord2fv(GLenum target, const GLfloat * v)
5420{
5421   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5422   save_Attr2fNV(attr, v[0], v[1]);
5423}
5424
5425static void GLAPIENTRY
5426save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z)
5427{
5428   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5429   save_Attr3fNV(attr, x, y, z);
5430}
5431
5432static void GLAPIENTRY
5433save_MultiTexCoord3fv(GLenum target, const GLfloat * v)
5434{
5435   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5436   save_Attr3fNV(attr, v[0], v[1], v[2]);
5437}
5438
5439static void GLAPIENTRY
5440save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y,
5441                     GLfloat z, GLfloat w)
5442{
5443   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5444   save_Attr4fNV(attr, x, y, z, w);
5445}
5446
5447static void GLAPIENTRY
5448save_MultiTexCoord4fv(GLenum target, const GLfloat * v)
5449{
5450   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
5451   save_Attr4fNV(attr, v[0], v[1], v[2], v[3]);
5452}
5453
5454
5455/**
5456 * Record a GL_INVALID_VALUE error when a invalid vertex attribute
5457 * index is found.
5458 */
5459static void
5460index_error(void)
5461{
5462   GET_CURRENT_CONTEXT(ctx);
5463   _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)");
5464}
5465
5466
5467/* First level for NV_vertex_program:
5468 *
5469 * Check for errors at compile time?.
5470 */
5471static void GLAPIENTRY
5472save_VertexAttrib1fNV(GLuint index, GLfloat x)
5473{
5474   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5475      save_Attr1fNV(index, x);
5476   else
5477      index_error();
5478}
5479
5480static void GLAPIENTRY
5481save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
5482{
5483   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5484      save_Attr1fNV(index, v[0]);
5485   else
5486      index_error();
5487}
5488
5489static void GLAPIENTRY
5490save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
5491{
5492   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5493      save_Attr2fNV(index, x, y);
5494   else
5495      index_error();
5496}
5497
5498static void GLAPIENTRY
5499save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
5500{
5501   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5502      save_Attr2fNV(index, v[0], v[1]);
5503   else
5504      index_error();
5505}
5506
5507static void GLAPIENTRY
5508save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5509{
5510   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5511      save_Attr3fNV(index, x, y, z);
5512   else
5513      index_error();
5514}
5515
5516static void GLAPIENTRY
5517save_VertexAttrib3fvNV(GLuint index, const GLfloat * v)
5518{
5519   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5520      save_Attr3fNV(index, v[0], v[1], v[2]);
5521   else
5522      index_error();
5523}
5524
5525static void GLAPIENTRY
5526save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
5527                      GLfloat z, GLfloat w)
5528{
5529   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5530      save_Attr4fNV(index, x, y, z, w);
5531   else
5532      index_error();
5533}
5534
5535static void GLAPIENTRY
5536save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
5537{
5538   if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
5539      save_Attr4fNV(index, v[0], v[1], v[2], v[3]);
5540   else
5541      index_error();
5542}
5543
5544
5545
5546
5547static void GLAPIENTRY
5548save_VertexAttrib1fARB(GLuint index, GLfloat x)
5549{
5550   if (index < MAX_VERTEX_ATTRIBS)
5551      save_Attr1fARB(index, x);
5552   else
5553      index_error();
5554}
5555
5556static void GLAPIENTRY
5557save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
5558{
5559   if (index < MAX_VERTEX_ATTRIBS)
5560      save_Attr1fARB(index, v[0]);
5561   else
5562      index_error();
5563}
5564
5565static void GLAPIENTRY
5566save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
5567{
5568   if (index < MAX_VERTEX_ATTRIBS)
5569      save_Attr2fARB(index, x, y);
5570   else
5571      index_error();
5572}
5573
5574static void GLAPIENTRY
5575save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
5576{
5577   if (index < MAX_VERTEX_ATTRIBS)
5578      save_Attr2fARB(index, v[0], v[1]);
5579   else
5580      index_error();
5581}
5582
5583static void GLAPIENTRY
5584save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5585{
5586   if (index < MAX_VERTEX_ATTRIBS)
5587      save_Attr3fARB(index, x, y, z);
5588   else
5589      index_error();
5590}
5591
5592static void GLAPIENTRY
5593save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
5594{
5595   if (index < MAX_VERTEX_ATTRIBS)
5596      save_Attr3fARB(index, v[0], v[1], v[2]);
5597   else
5598      index_error();
5599}
5600
5601static void GLAPIENTRY
5602save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
5603                       GLfloat w)
5604{
5605   if (index < MAX_VERTEX_ATTRIBS)
5606      save_Attr4fARB(index, x, y, z, w);
5607   else
5608      index_error();
5609}
5610
5611static void GLAPIENTRY
5612save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
5613{
5614   if (index < MAX_VERTEX_ATTRIBS)
5615      save_Attr4fARB(index, v[0], v[1], v[2], v[3]);
5616   else
5617      index_error();
5618}
5619
5620
5621/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
5622
5623static void GLAPIENTRY
5624exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name)
5625{
5626   GET_CURRENT_CONTEXT(ctx);
5627   FLUSH_VERTICES(ctx, 0);
5628   CALL_BindAttribLocationARB(ctx->Exec, (program, index, name));
5629}
5630
5631static GLint GLAPIENTRY
5632exec_GetAttribLocationARB(GLuint program, const GLchar *name)
5633{
5634   GET_CURRENT_CONTEXT(ctx);
5635   FLUSH_VERTICES(ctx, 0);
5636   return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
5637}
5638/* XXX more shader functions needed here */
5639
5640
5641
5642#if FEATURE_EXT_framebuffer_blit
5643static void GLAPIENTRY
5644save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
5645                        GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
5646                        GLbitfield mask, GLenum filter)
5647{
5648   GET_CURRENT_CONTEXT(ctx);
5649   Node *n;
5650   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5651   n = ALLOC_INSTRUCTION(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
5652   if (n) {
5653      n[1].i = srcX0;
5654      n[2].i = srcY0;
5655      n[3].i = srcX1;
5656      n[4].i = srcY1;
5657      n[5].i = dstX0;
5658      n[6].i = dstY0;
5659      n[7].i = dstX1;
5660      n[8].i = dstY1;
5661      n[9].i = mask;
5662      n[10].e = filter;
5663   }
5664   if (ctx->ExecuteFlag) {
5665      CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
5666                                          dstX0, dstY0, dstX1, dstY1,
5667                                          mask, filter));
5668   }
5669}
5670#endif
5671
5672
5673/**
5674 * Save an error-generating command into display list.
5675 *
5676 * KW: Will appear in the list before the vertex buffer containing the
5677 * command that provoked the error.  I don't see this as a problem.
5678 */
5679static void
5680save_error(GLcontext *ctx, GLenum error, const char *s)
5681{
5682   Node *n;
5683   n = ALLOC_INSTRUCTION(ctx, OPCODE_ERROR, 2);
5684   if (n) {
5685      n[1].e = error;
5686      n[2].data = (void *) s;
5687   }
5688}
5689
5690
5691/**
5692 * Compile an error into current display list.
5693 */
5694void
5695_mesa_compile_error(GLcontext *ctx, GLenum error, const char *s)
5696{
5697   if (ctx->CompileFlag)
5698      save_error(ctx, error, s);
5699   if (ctx->ExecuteFlag)
5700      _mesa_error(ctx, error, s);
5701}
5702
5703
5704/**
5705 * Test if ID names a display list.
5706 */
5707static GLboolean
5708islist(GLcontext *ctx, GLuint list)
5709{
5710   if (list > 0 && lookup_list(ctx, list)) {
5711      return GL_TRUE;
5712   }
5713   else {
5714      return GL_FALSE;
5715   }
5716}
5717
5718
5719
5720/**********************************************************************/
5721/*                     Display list execution                         */
5722/**********************************************************************/
5723
5724
5725/*
5726 * Execute a display list.  Note that the ListBase offset must have already
5727 * been added before calling this function.  I.e. the list argument is
5728 * the absolute list number, not relative to ListBase.
5729 * \param list - display list number
5730 */
5731static void
5732execute_list(GLcontext *ctx, GLuint list)
5733{
5734   struct mesa_display_list *dlist;
5735   Node *n;
5736   GLboolean done;
5737
5738   if (list == 0 || !islist(ctx, list))
5739      return;
5740
5741   if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
5742      /* raise an error? */
5743      return;
5744   }
5745
5746   dlist = lookup_list(ctx, list);
5747   if (!dlist)
5748      return;
5749
5750   ctx->ListState.CallDepth++;
5751
5752   if (ctx->Driver.BeginCallList)
5753      ctx->Driver.BeginCallList(ctx, dlist);
5754
5755   n = dlist->node;
5756
5757   done = GL_FALSE;
5758   while (!done) {
5759      OpCode opcode = n[0].opcode;
5760      int i = (int) n[0].opcode - (int) OPCODE_EXT_0;
5761
5762      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
5763         /* this is a driver-extended opcode */
5764         ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
5765         n += ctx->ListExt.Opcode[i].Size;
5766      }
5767      else {
5768         switch (opcode) {
5769         case OPCODE_ERROR:
5770            _mesa_error(ctx, n[1].e, (const char *) n[2].data);
5771            break;
5772         case OPCODE_ACCUM:
5773            CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
5774            break;
5775         case OPCODE_ALPHA_FUNC:
5776            CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
5777            break;
5778         case OPCODE_BIND_TEXTURE:
5779            CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
5780            break;
5781         case OPCODE_BITMAP:
5782            {
5783               const struct gl_pixelstore_attrib save = ctx->Unpack;
5784               ctx->Unpack = ctx->DefaultPacking;
5785               CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i,
5786                                       n[3].f, n[4].f, n[5].f, n[6].f,
5787                                       (const GLubyte *) n[7].data));
5788               ctx->Unpack = save;      /* restore */
5789            }
5790            break;
5791         case OPCODE_BLEND_COLOR:
5792            CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5793            break;
5794         case OPCODE_BLEND_EQUATION:
5795            CALL_BlendEquation(ctx->Exec, (n[1].e));
5796            break;
5797         case OPCODE_BLEND_EQUATION_SEPARATE:
5798            CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e));
5799            break;
5800         case OPCODE_BLEND_FUNC_SEPARATE:
5801            CALL_BlendFuncSeparateEXT(ctx->Exec,
5802                                      (n[1].e, n[2].e, n[3].e, n[4].e));
5803            break;
5804         case OPCODE_CALL_LIST:
5805            /* Generated by glCallList(), don't add ListBase */
5806            if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5807               execute_list(ctx, n[1].ui);
5808            }
5809            break;
5810         case OPCODE_CALL_LIST_OFFSET:
5811            /* Generated by glCallLists() so we must add ListBase */
5812            if (n[2].b) {
5813               /* user specified a bad data type at compile time */
5814               _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
5815            }
5816            else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
5817               GLuint list = (GLuint) (ctx->List.ListBase + n[1].i);
5818               execute_list(ctx, list);
5819            }
5820            break;
5821         case OPCODE_CLEAR:
5822            CALL_Clear(ctx->Exec, (n[1].bf));
5823            break;
5824         case OPCODE_CLEAR_COLOR:
5825            CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5826            break;
5827         case OPCODE_CLEAR_ACCUM:
5828            CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
5829            break;
5830         case OPCODE_CLEAR_DEPTH:
5831            CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
5832            break;
5833         case OPCODE_CLEAR_INDEX:
5834            CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
5835            break;
5836         case OPCODE_CLEAR_STENCIL:
5837            CALL_ClearStencil(ctx->Exec, (n[1].i));
5838            break;
5839         case OPCODE_CLIP_PLANE:
5840            {
5841               GLdouble eq[4];
5842               eq[0] = n[2].f;
5843               eq[1] = n[3].f;
5844               eq[2] = n[4].f;
5845               eq[3] = n[5].f;
5846               CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
5847            }
5848            break;
5849         case OPCODE_COLOR_MASK:
5850            CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
5851            break;
5852         case OPCODE_COLOR_MATERIAL:
5853            CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
5854            break;
5855         case OPCODE_COLOR_TABLE:
5856            {
5857               const struct gl_pixelstore_attrib save = ctx->Unpack;
5858               ctx->Unpack = ctx->DefaultPacking;
5859               CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e,
5860                                           n[5].e, n[6].data));
5861               ctx->Unpack = save;      /* restore */
5862            }
5863            break;
5864         case OPCODE_COLOR_TABLE_PARAMETER_FV:
5865            {
5866               GLfloat params[4];
5867               params[0] = n[3].f;
5868               params[1] = n[4].f;
5869               params[2] = n[5].f;
5870               params[3] = n[6].f;
5871               CALL_ColorTableParameterfv(ctx->Exec,
5872                                          (n[1].e, n[2].e, params));
5873            }
5874            break;
5875         case OPCODE_COLOR_TABLE_PARAMETER_IV:
5876            {
5877               GLint params[4];
5878               params[0] = n[3].i;
5879               params[1] = n[4].i;
5880               params[2] = n[5].i;
5881               params[3] = n[6].i;
5882               CALL_ColorTableParameteriv(ctx->Exec,
5883                                          (n[1].e, n[2].e, params));
5884            }
5885            break;
5886         case OPCODE_COLOR_SUB_TABLE:
5887            {
5888               const struct gl_pixelstore_attrib save = ctx->Unpack;
5889               ctx->Unpack = ctx->DefaultPacking;
5890               CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5891                                              n[4].e, n[5].e, n[6].data));
5892               ctx->Unpack = save;      /* restore */
5893            }
5894            break;
5895         case OPCODE_CONVOLUTION_FILTER_1D:
5896            {
5897               const struct gl_pixelstore_attrib save = ctx->Unpack;
5898               ctx->Unpack = ctx->DefaultPacking;
5899               CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5900                                                    n[4].e, n[5].e,
5901                                                    n[6].data));
5902               ctx->Unpack = save;      /* restore */
5903            }
5904            break;
5905         case OPCODE_CONVOLUTION_FILTER_2D:
5906            {
5907               const struct gl_pixelstore_attrib save = ctx->Unpack;
5908               ctx->Unpack = ctx->DefaultPacking;
5909               CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5910                                                    n[4].i, n[5].e, n[6].e,
5911                                                    n[7].data));
5912               ctx->Unpack = save;      /* restore */
5913            }
5914            break;
5915         case OPCODE_CONVOLUTION_PARAMETER_I:
5916            CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i));
5917            break;
5918         case OPCODE_CONVOLUTION_PARAMETER_IV:
5919            {
5920               GLint params[4];
5921               params[0] = n[3].i;
5922               params[1] = n[4].i;
5923               params[2] = n[5].i;
5924               params[3] = n[6].i;
5925               CALL_ConvolutionParameteriv(ctx->Exec,
5926                                           (n[1].e, n[2].e, params));
5927            }
5928            break;
5929         case OPCODE_CONVOLUTION_PARAMETER_F:
5930            CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f));
5931            break;
5932         case OPCODE_CONVOLUTION_PARAMETER_FV:
5933            {
5934               GLfloat params[4];
5935               params[0] = n[3].f;
5936               params[1] = n[4].f;
5937               params[2] = n[5].f;
5938               params[3] = n[6].f;
5939               CALL_ConvolutionParameterfv(ctx->Exec,
5940                                           (n[1].e, n[2].e, params));
5941            }
5942            break;
5943         case OPCODE_COPY_COLOR_SUB_TABLE:
5944            CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
5945                                               n[3].i, n[4].i, n[5].i));
5946            break;
5947         case OPCODE_COPY_COLOR_TABLE:
5948            CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
5949                                               n[3].i, n[4].i, n[5].i));
5950            break;
5951         case OPCODE_COPY_PIXELS:
5952            CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
5953                                        (GLsizei) n[3].i, (GLsizei) n[4].i,
5954                                        n[5].e));
5955            break;
5956         case OPCODE_COPY_TEX_IMAGE1D:
5957            CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
5958                                            n[5].i, n[6].i, n[7].i));
5959            break;
5960         case OPCODE_COPY_TEX_IMAGE2D:
5961            CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
5962                                            n[5].i, n[6].i, n[7].i, n[8].i));
5963            break;
5964         case OPCODE_COPY_TEX_SUB_IMAGE1D:
5965            CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5966                                               n[4].i, n[5].i, n[6].i));
5967            break;
5968         case OPCODE_COPY_TEX_SUB_IMAGE2D:
5969            CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5970                                               n[4].i, n[5].i, n[6].i, n[7].i,
5971                                               n[8].i));
5972            break;
5973         case OPCODE_COPY_TEX_SUB_IMAGE3D:
5974            CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
5975                                               n[4].i, n[5].i, n[6].i, n[7].i,
5976                                               n[8].i, n[9].i));
5977            break;
5978         case OPCODE_CULL_FACE:
5979            CALL_CullFace(ctx->Exec, (n[1].e));
5980            break;
5981         case OPCODE_DEPTH_FUNC:
5982            CALL_DepthFunc(ctx->Exec, (n[1].e));
5983            break;
5984         case OPCODE_DEPTH_MASK:
5985            CALL_DepthMask(ctx->Exec, (n[1].b));
5986            break;
5987         case OPCODE_DEPTH_RANGE:
5988            CALL_DepthRange(ctx->Exec,
5989                            ((GLclampd) n[1].f, (GLclampd) n[2].f));
5990            break;
5991         case OPCODE_DISABLE:
5992            CALL_Disable(ctx->Exec, (n[1].e));
5993            break;
5994         case OPCODE_DRAW_BUFFER:
5995            CALL_DrawBuffer(ctx->Exec, (n[1].e));
5996            break;
5997         case OPCODE_DRAW_PIXELS:
5998            {
5999               const struct gl_pixelstore_attrib save = ctx->Unpack;
6000               ctx->Unpack = ctx->DefaultPacking;
6001               CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
6002                                           n[5].data));
6003               ctx->Unpack = save;      /* restore */
6004            }
6005            break;
6006         case OPCODE_ENABLE:
6007            CALL_Enable(ctx->Exec, (n[1].e));
6008            break;
6009         case OPCODE_EVALMESH1:
6010            CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
6011            break;
6012         case OPCODE_EVALMESH2:
6013            CALL_EvalMesh2(ctx->Exec,
6014                           (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
6015            break;
6016         case OPCODE_FOG:
6017            {
6018               GLfloat p[4];
6019               p[0] = n[2].f;
6020               p[1] = n[3].f;
6021               p[2] = n[4].f;
6022               p[3] = n[5].f;
6023               CALL_Fogfv(ctx->Exec, (n[1].e, p));
6024            }
6025            break;
6026         case OPCODE_FRONT_FACE:
6027            CALL_FrontFace(ctx->Exec, (n[1].e));
6028            break;
6029         case OPCODE_FRUSTUM:
6030            CALL_Frustum(ctx->Exec,
6031                         (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
6032            break;
6033         case OPCODE_HINT:
6034            CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
6035            break;
6036         case OPCODE_HISTOGRAM:
6037            CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b));
6038            break;
6039         case OPCODE_INDEX_MASK:
6040            CALL_IndexMask(ctx->Exec, (n[1].ui));
6041            break;
6042         case OPCODE_INIT_NAMES:
6043            CALL_InitNames(ctx->Exec, ());
6044            break;
6045         case OPCODE_LIGHT:
6046            {
6047               GLfloat p[4];
6048               p[0] = n[3].f;
6049               p[1] = n[4].f;
6050               p[2] = n[5].f;
6051               p[3] = n[6].f;
6052               CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
6053            }
6054            break;
6055         case OPCODE_LIGHT_MODEL:
6056            {
6057               GLfloat p[4];
6058               p[0] = n[2].f;
6059               p[1] = n[3].f;
6060               p[2] = n[4].f;
6061               p[3] = n[5].f;
6062               CALL_LightModelfv(ctx->Exec, (n[1].e, p));
6063            }
6064            break;
6065         case OPCODE_LINE_STIPPLE:
6066            CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
6067            break;
6068         case OPCODE_LINE_WIDTH:
6069            CALL_LineWidth(ctx->Exec, (n[1].f));
6070            break;
6071         case OPCODE_LIST_BASE:
6072            CALL_ListBase(ctx->Exec, (n[1].ui));
6073            break;
6074         case OPCODE_LOAD_IDENTITY:
6075            CALL_LoadIdentity(ctx->Exec, ());
6076            break;
6077         case OPCODE_LOAD_MATRIX:
6078            if (sizeof(Node) == sizeof(GLfloat)) {
6079               CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
6080            }
6081            else {
6082               GLfloat m[16];
6083               GLuint i;
6084               for (i = 0; i < 16; i++) {
6085                  m[i] = n[1 + i].f;
6086               }
6087               CALL_LoadMatrixf(ctx->Exec, (m));
6088            }
6089            break;
6090         case OPCODE_LOAD_NAME:
6091            CALL_LoadName(ctx->Exec, (n[1].ui));
6092            break;
6093         case OPCODE_LOGIC_OP:
6094            CALL_LogicOp(ctx->Exec, (n[1].e));
6095            break;
6096         case OPCODE_MAP1:
6097            {
6098               GLenum target = n[1].e;
6099               GLint ustride = _mesa_evaluator_components(target);
6100               GLint uorder = n[5].i;
6101               GLfloat u1 = n[2].f;
6102               GLfloat u2 = n[3].f;
6103               CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
6104                                      (GLfloat *) n[6].data));
6105            }
6106            break;
6107         case OPCODE_MAP2:
6108            {
6109               GLenum target = n[1].e;
6110               GLfloat u1 = n[2].f;
6111               GLfloat u2 = n[3].f;
6112               GLfloat v1 = n[4].f;
6113               GLfloat v2 = n[5].f;
6114               GLint ustride = n[6].i;
6115               GLint vstride = n[7].i;
6116               GLint uorder = n[8].i;
6117               GLint vorder = n[9].i;
6118               CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
6119                                      v1, v2, vstride, vorder,
6120                                      (GLfloat *) n[10].data));
6121            }
6122            break;
6123         case OPCODE_MAPGRID1:
6124            CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
6125            break;
6126         case OPCODE_MAPGRID2:
6127            CALL_MapGrid2f(ctx->Exec,
6128                           (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
6129            break;
6130         case OPCODE_MATRIX_MODE:
6131            CALL_MatrixMode(ctx->Exec, (n[1].e));
6132            break;
6133         case OPCODE_MIN_MAX:
6134            CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b));
6135            break;
6136         case OPCODE_MULT_MATRIX:
6137            if (sizeof(Node) == sizeof(GLfloat)) {
6138               CALL_MultMatrixf(ctx->Exec, (&n[1].f));
6139            }
6140            else {
6141               GLfloat m[16];
6142               GLuint i;
6143               for (i = 0; i < 16; i++) {
6144                  m[i] = n[1 + i].f;
6145               }
6146               CALL_MultMatrixf(ctx->Exec, (m));
6147            }
6148            break;
6149         case OPCODE_ORTHO:
6150            CALL_Ortho(ctx->Exec,
6151                       (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
6152            break;
6153         case OPCODE_PASSTHROUGH:
6154            CALL_PassThrough(ctx->Exec, (n[1].f));
6155            break;
6156         case OPCODE_PIXEL_MAP:
6157            CALL_PixelMapfv(ctx->Exec,
6158                            (n[1].e, n[2].i, (GLfloat *) n[3].data));
6159            break;
6160         case OPCODE_PIXEL_TRANSFER:
6161            CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
6162            break;
6163         case OPCODE_PIXEL_ZOOM:
6164            CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
6165            break;
6166         case OPCODE_POINT_SIZE:
6167            CALL_PointSize(ctx->Exec, (n[1].f));
6168            break;
6169         case OPCODE_POINT_PARAMETERS:
6170            {
6171               GLfloat params[3];
6172               params[0] = n[2].f;
6173               params[1] = n[3].f;
6174               params[2] = n[4].f;
6175               CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params));
6176            }
6177            break;
6178         case OPCODE_POLYGON_MODE:
6179            CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
6180            break;
6181         case OPCODE_POLYGON_STIPPLE:
6182            {
6183               const struct gl_pixelstore_attrib save = ctx->Unpack;
6184               ctx->Unpack = ctx->DefaultPacking;
6185               CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data));
6186               ctx->Unpack = save;      /* restore */
6187            }
6188            break;
6189         case OPCODE_POLYGON_OFFSET:
6190            CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
6191            break;
6192         case OPCODE_POP_ATTRIB:
6193            CALL_PopAttrib(ctx->Exec, ());
6194            break;
6195         case OPCODE_POP_MATRIX:
6196            CALL_PopMatrix(ctx->Exec, ());
6197            break;
6198         case OPCODE_POP_NAME:
6199            CALL_PopName(ctx->Exec, ());
6200            break;
6201         case OPCODE_PRIORITIZE_TEXTURE:
6202            CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
6203            break;
6204         case OPCODE_PUSH_ATTRIB:
6205            CALL_PushAttrib(ctx->Exec, (n[1].bf));
6206            break;
6207         case OPCODE_PUSH_MATRIX:
6208            CALL_PushMatrix(ctx->Exec, ());
6209            break;
6210         case OPCODE_PUSH_NAME:
6211            CALL_PushName(ctx->Exec, (n[1].ui));
6212            break;
6213         case OPCODE_RASTER_POS:
6214            CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6215            break;
6216         case OPCODE_READ_BUFFER:
6217            CALL_ReadBuffer(ctx->Exec, (n[1].e));
6218            break;
6219         case OPCODE_RESET_HISTOGRAM:
6220            CALL_ResetHistogram(ctx->Exec, (n[1].e));
6221            break;
6222         case OPCODE_RESET_MIN_MAX:
6223            CALL_ResetMinmax(ctx->Exec, (n[1].e));
6224            break;
6225         case OPCODE_ROTATE:
6226            CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6227            break;
6228         case OPCODE_SCALE:
6229            CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6230            break;
6231         case OPCODE_SCISSOR:
6232            CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
6233            break;
6234         case OPCODE_SHADE_MODEL:
6235            CALL_ShadeModel(ctx->Exec, (n[1].e));
6236            break;
6237         case OPCODE_STENCIL_FUNC:
6238            CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
6239            break;
6240         case OPCODE_STENCIL_MASK:
6241            CALL_StencilMask(ctx->Exec, (n[1].ui));
6242            break;
6243         case OPCODE_STENCIL_OP:
6244            CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
6245            break;
6246         case OPCODE_STENCIL_FUNC_SEPARATE:
6247            CALL_StencilFuncSeparate(ctx->Exec,
6248                                     (n[1].e, n[2].e, n[3].i, n[4].ui));
6249            break;
6250         case OPCODE_STENCIL_MASK_SEPARATE:
6251            CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
6252            break;
6253         case OPCODE_STENCIL_OP_SEPARATE:
6254            CALL_StencilOpSeparate(ctx->Exec,
6255                                   (n[1].e, n[2].e, n[3].e, n[4].e));
6256            break;
6257         case OPCODE_TEXENV:
6258            {
6259               GLfloat params[4];
6260               params[0] = n[3].f;
6261               params[1] = n[4].f;
6262               params[2] = n[5].f;
6263               params[3] = n[6].f;
6264               CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
6265            }
6266            break;
6267         case OPCODE_TEXGEN:
6268            {
6269               GLfloat params[4];
6270               params[0] = n[3].f;
6271               params[1] = n[4].f;
6272               params[2] = n[5].f;
6273               params[3] = n[6].f;
6274               CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
6275            }
6276            break;
6277         case OPCODE_TEXPARAMETER:
6278            {
6279               GLfloat params[4];
6280               params[0] = n[3].f;
6281               params[1] = n[4].f;
6282               params[2] = n[5].f;
6283               params[3] = n[6].f;
6284               CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
6285            }
6286            break;
6287         case OPCODE_TEX_IMAGE1D:
6288            {
6289               const struct gl_pixelstore_attrib save = ctx->Unpack;
6290               ctx->Unpack = ctx->DefaultPacking;
6291               CALL_TexImage1D(ctx->Exec, (n[1].e,      /* target */
6292                                           n[2].i,      /* level */
6293                                           n[3].i,      /* components */
6294                                           n[4].i,      /* width */
6295                                           n[5].e,      /* border */
6296                                           n[6].e,      /* format */
6297                                           n[7].e,      /* type */
6298                                           n[8].data));
6299               ctx->Unpack = save;      /* restore */
6300            }
6301            break;
6302         case OPCODE_TEX_IMAGE2D:
6303            {
6304               const struct gl_pixelstore_attrib save = ctx->Unpack;
6305               ctx->Unpack = ctx->DefaultPacking;
6306               CALL_TexImage2D(ctx->Exec, (n[1].e,      /* target */
6307                                           n[2].i,      /* level */
6308                                           n[3].i,      /* components */
6309                                           n[4].i,      /* width */
6310                                           n[5].i,      /* height */
6311                                           n[6].e,      /* border */
6312                                           n[7].e,      /* format */
6313                                           n[8].e,      /* type */
6314                                           n[9].data));
6315               ctx->Unpack = save;      /* restore */
6316            }
6317            break;
6318         case OPCODE_TEX_IMAGE3D:
6319            {
6320               const struct gl_pixelstore_attrib save = ctx->Unpack;
6321               ctx->Unpack = ctx->DefaultPacking;
6322               CALL_TexImage3D(ctx->Exec, (n[1].e,      /* target */
6323                                           n[2].i,      /* level */
6324                                           n[3].i,      /* components */
6325                                           n[4].i,      /* width */
6326                                           n[5].i,      /* height */
6327                                           n[6].i,      /* depth  */
6328                                           n[7].e,      /* border */
6329                                           n[8].e,      /* format */
6330                                           n[9].e,      /* type */
6331                                           n[10].data));
6332               ctx->Unpack = save;      /* restore */
6333            }
6334            break;
6335         case OPCODE_TEX_SUB_IMAGE1D:
6336            {
6337               const struct gl_pixelstore_attrib save = ctx->Unpack;
6338               ctx->Unpack = ctx->DefaultPacking;
6339               CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6340                                              n[4].i, n[5].e,
6341                                              n[6].e, n[7].data));
6342               ctx->Unpack = save;      /* restore */
6343            }
6344            break;
6345         case OPCODE_TEX_SUB_IMAGE2D:
6346            {
6347               const struct gl_pixelstore_attrib save = ctx->Unpack;
6348               ctx->Unpack = ctx->DefaultPacking;
6349               CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6350                                              n[4].i, n[5].e,
6351                                              n[6].i, n[7].e, n[8].e,
6352                                              n[9].data));
6353               ctx->Unpack = save;      /* restore */
6354            }
6355            break;
6356         case OPCODE_TEX_SUB_IMAGE3D:
6357            {
6358               const struct gl_pixelstore_attrib save = ctx->Unpack;
6359               ctx->Unpack = ctx->DefaultPacking;
6360               CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
6361                                              n[4].i, n[5].i, n[6].i, n[7].i,
6362                                              n[8].i, n[9].e, n[10].e,
6363                                              n[11].data));
6364               ctx->Unpack = save;      /* restore */
6365            }
6366            break;
6367         case OPCODE_TRANSLATE:
6368            CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6369            break;
6370         case OPCODE_VIEWPORT:
6371            CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
6372                                      (GLsizei) n[3].i, (GLsizei) n[4].i));
6373            break;
6374         case OPCODE_WINDOW_POS:
6375            CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6376            break;
6377         case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
6378            CALL_ActiveTextureARB(ctx->Exec, (n[1].e));
6379            break;
6380         case OPCODE_COMPRESSED_TEX_IMAGE_1D:  /* GL_ARB_texture_compression */
6381            CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6382                                                     n[4].i, n[5].i, n[6].i,
6383                                                     n[7].data));
6384            break;
6385         case OPCODE_COMPRESSED_TEX_IMAGE_2D:  /* GL_ARB_texture_compression */
6386            CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6387                                                     n[4].i, n[5].i, n[6].i,
6388                                                     n[7].i, n[8].data));
6389            break;
6390         case OPCODE_COMPRESSED_TEX_IMAGE_3D:  /* GL_ARB_texture_compression */
6391            CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
6392                                                     n[4].i, n[5].i, n[6].i,
6393                                                     n[7].i, n[8].i,
6394                                                     n[9].data));
6395            break;
6396         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:      /* GL_ARB_texture_compress */
6397            CALL_CompressedTexSubImage1DARB(ctx->Exec,
6398                                            (n[1].e, n[2].i, n[3].i, n[4].i,
6399                                             n[5].e, n[6].i, n[7].data));
6400            break;
6401         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:      /* GL_ARB_texture_compress */
6402            CALL_CompressedTexSubImage2DARB(ctx->Exec,
6403                                            (n[1].e, n[2].i, n[3].i, n[4].i,
6404                                             n[5].i, n[6].i, n[7].e, n[8].i,
6405                                             n[9].data));
6406            break;
6407         case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:      /* GL_ARB_texture_compress */
6408            CALL_CompressedTexSubImage3DARB(ctx->Exec,
6409                                            (n[1].e, n[2].i, n[3].i, n[4].i,
6410                                             n[5].i, n[6].i, n[7].i, n[8].i,
6411                                             n[9].e, n[10].i, n[11].data));
6412            break;
6413         case OPCODE_SAMPLE_COVERAGE:  /* GL_ARB_multisample */
6414            CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b));
6415            break;
6416         case OPCODE_WINDOW_POS_ARB:   /* GL_ARB_window_pos */
6417            CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f));
6418            break;
6419#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
6420         case OPCODE_BIND_PROGRAM_NV:  /* GL_NV_vertex_program */
6421            CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui));
6422            break;
6423#endif
6424#if FEATURE_NV_vertex_program
6425         case OPCODE_EXECUTE_PROGRAM_NV:
6426            {
6427               GLfloat v[4];
6428               v[0] = n[3].f;
6429               v[1] = n[4].f;
6430               v[2] = n[5].f;
6431               v[3] = n[6].f;
6432               CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v));
6433            }
6434            break;
6435         case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
6436            CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui,
6437                                                       (GLuint *) n[2].data));
6438            break;
6439         case OPCODE_LOAD_PROGRAM_NV:
6440            CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
6441                                           (const GLubyte *) n[4].data));
6442            break;
6443         case OPCODE_TRACK_MATRIX_NV:
6444            CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
6445            break;
6446#endif
6447
6448#if FEATURE_NV_fragment_program
6449         case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
6450            CALL_ProgramLocalParameter4fARB(ctx->Exec,
6451                                            (n[1].e, n[2].ui, n[3].f, n[4].f,
6452                                             n[5].f, n[6].f));
6453            break;
6454         case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
6455            CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i,
6456                                                       (const GLubyte *) n[3].
6457                                                       data, n[4].f, n[5].f,
6458                                                       n[6].f, n[7].f));
6459            break;
6460#endif
6461
6462         case OPCODE_ACTIVE_STENCIL_FACE_EXT:
6463            CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
6464            break;
6465         case OPCODE_DEPTH_BOUNDS_EXT:
6466            CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
6467            break;
6468#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
6469         case OPCODE_PROGRAM_STRING_ARB:
6470            CALL_ProgramStringARB(ctx->Exec,
6471                                  (n[1].e, n[2].e, n[3].i, n[4].data));
6472            break;
6473#endif
6474#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program
6475         case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
6476            CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
6477                                                      n[4].f, n[5].f,
6478                                                      n[6].f));
6479            break;
6480#endif
6481#if FEATURE_ARB_occlusion_query
6482         case OPCODE_BEGIN_QUERY_ARB:
6483            CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui));
6484            break;
6485         case OPCODE_END_QUERY_ARB:
6486            CALL_EndQueryARB(ctx->Exec, (n[1].e));
6487            break;
6488#endif
6489         case OPCODE_DRAW_BUFFERS_ARB:
6490            {
6491               GLenum buffers[MAX_DRAW_BUFFERS];
6492               GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
6493               for (i = 0; i < count; i++)
6494                  buffers[i] = n[2 + i].e;
6495               CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers));
6496            }
6497            break;
6498#if FEATURE_EXT_framebuffer_blit
6499	 case OPCODE_BLIT_FRAMEBUFFER:
6500	    CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
6501                                                n[5].i, n[6].i, n[7].i, n[8].i,
6502                                                n[9].i, n[10].e));
6503	    break;
6504#endif
6505#if FEATURE_ATI_fragment_shader
6506         case OPCODE_BIND_FRAGMENT_SHADER_ATI:
6507            CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
6508            break;
6509         case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
6510            {
6511               GLfloat values[4];
6512               GLuint i, dst = n[1].ui;
6513
6514               for (i = 0; i < 4; i++)
6515                  values[i] = n[1 + i].f;
6516               CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values));
6517            }
6518            break;
6519#endif
6520         case OPCODE_ATTR_1F_NV:
6521            CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
6522            break;
6523         case OPCODE_ATTR_2F_NV:
6524            /* Really shouldn't have to do this - the Node structure
6525             * is convenient, but it would be better to store the data
6526             * packed appropriately so that it can be sent directly
6527             * on.  With x86_64 becoming common, this will start to
6528             * matter more.
6529             */
6530            if (sizeof(Node) == sizeof(GLfloat))
6531               CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
6532            else
6533               CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f));
6534            break;
6535         case OPCODE_ATTR_3F_NV:
6536            if (sizeof(Node) == sizeof(GLfloat))
6537               CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
6538            else
6539               CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6540                                                 n[4].f));
6541            break;
6542         case OPCODE_ATTR_4F_NV:
6543            if (sizeof(Node) == sizeof(GLfloat))
6544               CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
6545            else
6546               CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6547                                                 n[4].f, n[5].f));
6548            break;
6549         case OPCODE_ATTR_1F_ARB:
6550            CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
6551            break;
6552         case OPCODE_ATTR_2F_ARB:
6553            /* Really shouldn't have to do this - the Node structure
6554             * is convenient, but it would be better to store the data
6555             * packed appropriately so that it can be sent directly
6556             * on.  With x86_64 becoming common, this will start to
6557             * matter more.
6558             */
6559            if (sizeof(Node) == sizeof(GLfloat))
6560               CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
6561            else
6562               CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f));
6563            break;
6564         case OPCODE_ATTR_3F_ARB:
6565            if (sizeof(Node) == sizeof(GLfloat))
6566               CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
6567            else
6568               CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6569                                                  n[4].f));
6570            break;
6571         case OPCODE_ATTR_4F_ARB:
6572            if (sizeof(Node) == sizeof(GLfloat))
6573               CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
6574            else
6575               CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
6576                                                  n[4].f, n[5].f));
6577            break;
6578         case OPCODE_MATERIAL:
6579            if (sizeof(Node) == sizeof(GLfloat))
6580               CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
6581            else {
6582               GLfloat f[4];
6583               f[0] = n[3].f;
6584               f[1] = n[4].f;
6585               f[2] = n[5].f;
6586               f[3] = n[6].f;
6587               CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f));
6588            }
6589            break;
6590         case OPCODE_BEGIN:
6591            CALL_Begin(ctx->Exec, (n[1].e));
6592            break;
6593         case OPCODE_END:
6594            CALL_End(ctx->Exec, ());
6595            break;
6596         case OPCODE_RECTF:
6597            CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
6598            break;
6599         case OPCODE_EVAL_C1:
6600            CALL_EvalCoord1f(ctx->Exec, (n[1].f));
6601            break;
6602         case OPCODE_EVAL_C2:
6603            CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
6604            break;
6605         case OPCODE_EVAL_P1:
6606            CALL_EvalPoint1(ctx->Exec, (n[1].i));
6607            break;
6608         case OPCODE_EVAL_P2:
6609            CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
6610            break;
6611
6612         case OPCODE_CONTINUE:
6613            n = (Node *) n[1].next;
6614            break;
6615         case OPCODE_END_OF_LIST:
6616            done = GL_TRUE;
6617            break;
6618         default:
6619            {
6620               char msg[1000];
6621               _mesa_sprintf(msg, "Error in execute_list: opcode=%d",
6622                             (int) opcode);
6623               _mesa_problem(ctx, msg);
6624            }
6625            done = GL_TRUE;
6626         }
6627
6628         /* increment n to point to next compiled command */
6629         if (opcode != OPCODE_CONTINUE) {
6630            n += InstSize[opcode];
6631         }
6632      }
6633   }
6634
6635   if (ctx->Driver.EndCallList)
6636      ctx->Driver.EndCallList(ctx);
6637
6638   ctx->ListState.CallDepth--;
6639}
6640
6641
6642
6643/**********************************************************************/
6644/*                           GL functions                             */
6645/**********************************************************************/
6646
6647/**
6648 * Test if a display list number is valid.
6649 */
6650GLboolean GLAPIENTRY
6651_mesa_IsList(GLuint list)
6652{
6653   GET_CURRENT_CONTEXT(ctx);
6654   FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
6655   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
6656   return islist(ctx, list);
6657}
6658
6659
6660/**
6661 * Delete a sequence of consecutive display lists.
6662 */
6663void GLAPIENTRY
6664_mesa_DeleteLists(GLuint list, GLsizei range)
6665{
6666   GET_CURRENT_CONTEXT(ctx);
6667   GLuint i;
6668   FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
6669   ASSERT_OUTSIDE_BEGIN_END(ctx);
6670
6671   if (range < 0) {
6672      _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
6673      return;
6674   }
6675   for (i = list; i < list + range; i++) {
6676      destroy_list(ctx, i);
6677   }
6678}
6679
6680
6681/**
6682 * Return a display list number, n, such that lists n through n+range-1
6683 * are free.
6684 */
6685GLuint GLAPIENTRY
6686_mesa_GenLists(GLsizei range)
6687{
6688   GET_CURRENT_CONTEXT(ctx);
6689   GLuint base;
6690   FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
6691   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
6692
6693   if (range < 0) {
6694      _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
6695      return 0;
6696   }
6697   if (range == 0) {
6698      return 0;
6699   }
6700
6701   /*
6702    * Make this an atomic operation
6703    */
6704   _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
6705
6706   base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
6707   if (base) {
6708      /* reserve the list IDs by with empty/dummy lists */
6709      GLint i;
6710      for (i = 0; i < range; i++) {
6711         _mesa_HashInsert(ctx->Shared->DisplayList, base + i,
6712                          make_list(base + i, 1));
6713      }
6714   }
6715
6716   _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
6717
6718   return base;
6719}
6720
6721
6722/**
6723 * Begin a new display list.
6724 */
6725void GLAPIENTRY
6726_mesa_NewList(GLuint list, GLenum mode)
6727{
6728   GET_CURRENT_CONTEXT(ctx);
6729   GLint i;
6730
6731   FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
6732   ASSERT_OUTSIDE_BEGIN_END(ctx);
6733
6734   if (MESA_VERBOSE & VERBOSE_API)
6735      _mesa_debug(ctx, "glNewList %u %s\n", list,
6736                  _mesa_lookup_enum_by_nr(mode));
6737
6738   if (list == 0) {
6739      _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
6740      return;
6741   }
6742
6743   if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
6744      _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
6745      return;
6746   }
6747
6748   if (ctx->ListState.CurrentListPtr) {
6749      /* already compiling a display list */
6750      _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
6751      return;
6752   }
6753
6754   ctx->CompileFlag = GL_TRUE;
6755   ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
6756
6757   /* Allocate new display list */
6758   ctx->ListState.CurrentListNum = list;
6759   ctx->ListState.CurrentList = make_list(list, BLOCK_SIZE);
6760   ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->node;
6761   ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
6762   ctx->ListState.CurrentPos = 0;
6763
6764   /* Reset acumulated list state:
6765    */
6766   for (i = 0; i < VERT_ATTRIB_MAX; i++)
6767      ctx->ListState.ActiveAttribSize[i] = 0;
6768
6769   for (i = 0; i < MAT_ATTRIB_MAX; i++)
6770      ctx->ListState.ActiveMaterialSize[i] = 0;
6771
6772   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
6773   ctx->Driver.NewList(ctx, list, mode);
6774
6775   ctx->CurrentDispatch = ctx->Save;
6776   _glapi_set_dispatch(ctx->CurrentDispatch);
6777}
6778
6779
6780/**
6781 * End definition of current display list.
6782 */
6783void GLAPIENTRY
6784_mesa_EndList(void)
6785{
6786   GET_CURRENT_CONTEXT(ctx);
6787   SAVE_FLUSH_VERTICES(ctx);
6788   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
6789
6790   if (MESA_VERBOSE & VERBOSE_API)
6791      _mesa_debug(ctx, "glEndList\n");
6792
6793   /* Check that a list is under construction */
6794   if (!ctx->ListState.CurrentListPtr) {
6795      _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
6796      return;
6797   }
6798
6799   /* Call before emitting END_OF_LIST, in case the driver wants to
6800    * emit opcodes itself.
6801    */
6802   ctx->Driver.EndList(ctx);
6803
6804   (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
6805
6806   /* Destroy old list, if any */
6807   destroy_list(ctx, ctx->ListState.CurrentListNum);
6808   /* Install the list */
6809   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum,
6810                    ctx->ListState.CurrentList);
6811
6812
6813   if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
6814      mesa_print_display_list(ctx->ListState.CurrentListNum);
6815
6816   ctx->ListState.CurrentList = NULL;
6817   ctx->ListState.CurrentListNum = 0;
6818   ctx->ListState.CurrentListPtr = NULL;
6819   ctx->ExecuteFlag = GL_TRUE;
6820   ctx->CompileFlag = GL_FALSE;
6821
6822   ctx->CurrentDispatch = ctx->Exec;
6823   _glapi_set_dispatch(ctx->CurrentDispatch);
6824}
6825
6826
6827void GLAPIENTRY
6828_mesa_CallList(GLuint list)
6829{
6830   GLboolean save_compile_flag;
6831   GET_CURRENT_CONTEXT(ctx);
6832   FLUSH_CURRENT(ctx, 0);
6833   /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
6834   /* execute the display list, and restore the CompileFlag. */
6835
6836   if (MESA_VERBOSE & VERBOSE_API)
6837      _mesa_debug(ctx, "glCallList %d\n", list);
6838
6839   if (list == 0) {
6840      _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
6841      return;
6842   }
6843
6844/*     mesa_print_display_list( list ); */
6845
6846   save_compile_flag = ctx->CompileFlag;
6847   if (save_compile_flag) {
6848      ctx->CompileFlag = GL_FALSE;
6849   }
6850
6851   execute_list(ctx, list);
6852   ctx->CompileFlag = save_compile_flag;
6853
6854   /* also restore API function pointers to point to "save" versions */
6855   if (save_compile_flag) {
6856      ctx->CurrentDispatch = ctx->Save;
6857      _glapi_set_dispatch(ctx->CurrentDispatch);
6858   }
6859}
6860
6861
6862/**
6863 * Execute glCallLists:  call multiple display lists.
6864 */
6865void GLAPIENTRY
6866_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
6867{
6868   GET_CURRENT_CONTEXT(ctx);
6869   GLint i;
6870   GLboolean save_compile_flag;
6871
6872   if (MESA_VERBOSE & VERBOSE_API)
6873      _mesa_debug(ctx, "glCallLists %d\n", n);
6874
6875   switch (type) {
6876   case GL_BYTE:
6877   case GL_UNSIGNED_BYTE:
6878   case GL_SHORT:
6879   case GL_UNSIGNED_SHORT:
6880   case GL_INT:
6881   case GL_UNSIGNED_INT:
6882   case GL_FLOAT:
6883   case GL_2_BYTES:
6884   case GL_3_BYTES:
6885   case GL_4_BYTES:
6886      /* OK */
6887      break;
6888   default:
6889      _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
6890      return;
6891   }
6892
6893   /* Save the CompileFlag status, turn it off, execute display list,
6894    * and restore the CompileFlag.
6895    */
6896   save_compile_flag = ctx->CompileFlag;
6897   ctx->CompileFlag = GL_FALSE;
6898
6899   for (i = 0; i < n; i++) {
6900      GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
6901      execute_list(ctx, list);
6902   }
6903
6904   ctx->CompileFlag = save_compile_flag;
6905
6906   /* also restore API function pointers to point to "save" versions */
6907   if (save_compile_flag) {
6908      ctx->CurrentDispatch = ctx->Save;
6909      _glapi_set_dispatch(ctx->CurrentDispatch);
6910   }
6911}
6912
6913
6914/**
6915 * Set the offset added to list numbers in glCallLists.
6916 */
6917void GLAPIENTRY
6918_mesa_ListBase(GLuint base)
6919{
6920   GET_CURRENT_CONTEXT(ctx);
6921   FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
6922   ASSERT_OUTSIDE_BEGIN_END(ctx);
6923   ctx->List.ListBase = base;
6924}
6925
6926
6927/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
6928 */
6929static void GLAPIENTRY
6930exec_Finish(void)
6931{
6932   GET_CURRENT_CONTEXT(ctx);
6933   FLUSH_VERTICES(ctx, 0);
6934   CALL_Finish(ctx->Exec, ());
6935}
6936
6937static void GLAPIENTRY
6938exec_Flush(void)
6939{
6940   GET_CURRENT_CONTEXT(ctx);
6941   FLUSH_VERTICES(ctx, 0);
6942   CALL_Flush(ctx->Exec, ());
6943}
6944
6945static void GLAPIENTRY
6946exec_GetBooleanv(GLenum pname, GLboolean *params)
6947{
6948   GET_CURRENT_CONTEXT(ctx);
6949   FLUSH_VERTICES(ctx, 0);
6950   CALL_GetBooleanv(ctx->Exec, (pname, params));
6951}
6952
6953static void GLAPIENTRY
6954exec_GetClipPlane(GLenum plane, GLdouble * equation)
6955{
6956   GET_CURRENT_CONTEXT(ctx);
6957   FLUSH_VERTICES(ctx, 0);
6958   CALL_GetClipPlane(ctx->Exec, (plane, equation));
6959}
6960
6961static void GLAPIENTRY
6962exec_GetDoublev(GLenum pname, GLdouble *params)
6963{
6964   GET_CURRENT_CONTEXT(ctx);
6965   FLUSH_VERTICES(ctx, 0);
6966   CALL_GetDoublev(ctx->Exec, (pname, params));
6967}
6968
6969static GLenum GLAPIENTRY
6970exec_GetError(void)
6971{
6972   GET_CURRENT_CONTEXT(ctx);
6973   FLUSH_VERTICES(ctx, 0);
6974   return CALL_GetError(ctx->Exec, ());
6975}
6976
6977static void GLAPIENTRY
6978exec_GetFloatv(GLenum pname, GLfloat *params)
6979{
6980   GET_CURRENT_CONTEXT(ctx);
6981   FLUSH_VERTICES(ctx, 0);
6982   CALL_GetFloatv(ctx->Exec, (pname, params));
6983}
6984
6985static void GLAPIENTRY
6986exec_GetIntegerv(GLenum pname, GLint *params)
6987{
6988   GET_CURRENT_CONTEXT(ctx);
6989   FLUSH_VERTICES(ctx, 0);
6990   CALL_GetIntegerv(ctx->Exec, (pname, params));
6991}
6992
6993static void GLAPIENTRY
6994exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params)
6995{
6996   GET_CURRENT_CONTEXT(ctx);
6997   FLUSH_VERTICES(ctx, 0);
6998   CALL_GetLightfv(ctx->Exec, (light, pname, params));
6999}
7000
7001static void GLAPIENTRY
7002exec_GetLightiv(GLenum light, GLenum pname, GLint *params)
7003{
7004   GET_CURRENT_CONTEXT(ctx);
7005   FLUSH_VERTICES(ctx, 0);
7006   CALL_GetLightiv(ctx->Exec, (light, pname, params));
7007}
7008
7009static void GLAPIENTRY
7010exec_GetMapdv(GLenum target, GLenum query, GLdouble * v)
7011{
7012   GET_CURRENT_CONTEXT(ctx);
7013   FLUSH_VERTICES(ctx, 0);
7014   CALL_GetMapdv(ctx->Exec, (target, query, v));
7015}
7016
7017static void GLAPIENTRY
7018exec_GetMapfv(GLenum target, GLenum query, GLfloat * v)
7019{
7020   GET_CURRENT_CONTEXT(ctx);
7021   FLUSH_VERTICES(ctx, 0);
7022   CALL_GetMapfv(ctx->Exec, (target, query, v));
7023}
7024
7025static void GLAPIENTRY
7026exec_GetMapiv(GLenum target, GLenum query, GLint * v)
7027{
7028   GET_CURRENT_CONTEXT(ctx);
7029   FLUSH_VERTICES(ctx, 0);
7030   CALL_GetMapiv(ctx->Exec, (target, query, v));
7031}
7032
7033static void GLAPIENTRY
7034exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
7035{
7036   GET_CURRENT_CONTEXT(ctx);
7037   FLUSH_VERTICES(ctx, 0);
7038   CALL_GetMaterialfv(ctx->Exec, (face, pname, params));
7039}
7040
7041static void GLAPIENTRY
7042exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params)
7043{
7044   GET_CURRENT_CONTEXT(ctx);
7045   FLUSH_VERTICES(ctx, 0);
7046   CALL_GetMaterialiv(ctx->Exec, (face, pname, params));
7047}
7048
7049static void GLAPIENTRY
7050exec_GetPixelMapfv(GLenum map, GLfloat *values)
7051{
7052   GET_CURRENT_CONTEXT(ctx);
7053   FLUSH_VERTICES(ctx, 0);
7054   CALL_GetPixelMapfv(ctx->Exec, (map, values));
7055}
7056
7057static void GLAPIENTRY
7058exec_GetPixelMapuiv(GLenum map, GLuint *values)
7059{
7060   GET_CURRENT_CONTEXT(ctx);
7061   FLUSH_VERTICES(ctx, 0);
7062   CALL_GetPixelMapuiv(ctx->Exec, (map, values));
7063}
7064
7065static void GLAPIENTRY
7066exec_GetPixelMapusv(GLenum map, GLushort *values)
7067{
7068   GET_CURRENT_CONTEXT(ctx);
7069   FLUSH_VERTICES(ctx, 0);
7070   CALL_GetPixelMapusv(ctx->Exec, (map, values));
7071}
7072
7073static void GLAPIENTRY
7074exec_GetPolygonStipple(GLubyte * dest)
7075{
7076   GET_CURRENT_CONTEXT(ctx);
7077   FLUSH_VERTICES(ctx, 0);
7078   CALL_GetPolygonStipple(ctx->Exec, (dest));
7079}
7080
7081static const GLubyte *GLAPIENTRY
7082exec_GetString(GLenum name)
7083{
7084   GET_CURRENT_CONTEXT(ctx);
7085   FLUSH_VERTICES(ctx, 0);
7086   return CALL_GetString(ctx->Exec, (name));
7087}
7088
7089static void GLAPIENTRY
7090exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
7091{
7092   GET_CURRENT_CONTEXT(ctx);
7093   FLUSH_VERTICES(ctx, 0);
7094   CALL_GetTexEnvfv(ctx->Exec, (target, pname, params));
7095}
7096
7097static void GLAPIENTRY
7098exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params)
7099{
7100   GET_CURRENT_CONTEXT(ctx);
7101   FLUSH_VERTICES(ctx, 0);
7102   CALL_GetTexEnviv(ctx->Exec, (target, pname, params));
7103}
7104
7105static void GLAPIENTRY
7106exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
7107{
7108   GET_CURRENT_CONTEXT(ctx);
7109   FLUSH_VERTICES(ctx, 0);
7110   CALL_GetTexGendv(ctx->Exec, (coord, pname, params));
7111}
7112
7113static void GLAPIENTRY
7114exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
7115{
7116   GET_CURRENT_CONTEXT(ctx);
7117   FLUSH_VERTICES(ctx, 0);
7118   CALL_GetTexGenfv(ctx->Exec, (coord, pname, params));
7119}
7120
7121static void GLAPIENTRY
7122exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params)
7123{
7124   GET_CURRENT_CONTEXT(ctx);
7125   FLUSH_VERTICES(ctx, 0);
7126   CALL_GetTexGeniv(ctx->Exec, (coord, pname, params));
7127}
7128
7129static void GLAPIENTRY
7130exec_GetTexImage(GLenum target, GLint level, GLenum format,
7131                 GLenum type, GLvoid * pixels)
7132{
7133   GET_CURRENT_CONTEXT(ctx);
7134   FLUSH_VERTICES(ctx, 0);
7135   CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels));
7136}
7137
7138static void GLAPIENTRY
7139exec_GetTexLevelParameterfv(GLenum target, GLint level,
7140                            GLenum pname, GLfloat *params)
7141{
7142   GET_CURRENT_CONTEXT(ctx);
7143   FLUSH_VERTICES(ctx, 0);
7144   CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params));
7145}
7146
7147static void GLAPIENTRY
7148exec_GetTexLevelParameteriv(GLenum target, GLint level,
7149                            GLenum pname, GLint *params)
7150{
7151   GET_CURRENT_CONTEXT(ctx);
7152   FLUSH_VERTICES(ctx, 0);
7153   CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params));
7154}
7155
7156static void GLAPIENTRY
7157exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
7158{
7159   GET_CURRENT_CONTEXT(ctx);
7160   FLUSH_VERTICES(ctx, 0);
7161   CALL_GetTexParameterfv(ctx->Exec, (target, pname, params));
7162}
7163
7164static void GLAPIENTRY
7165exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
7166{
7167   GET_CURRENT_CONTEXT(ctx);
7168   FLUSH_VERTICES(ctx, 0);
7169   CALL_GetTexParameteriv(ctx->Exec, (target, pname, params));
7170}
7171
7172static GLboolean GLAPIENTRY
7173exec_IsEnabled(GLenum cap)
7174{
7175   GET_CURRENT_CONTEXT(ctx);
7176   FLUSH_VERTICES(ctx, 0);
7177   return CALL_IsEnabled(ctx->Exec, (cap));
7178}
7179
7180static void GLAPIENTRY
7181exec_PixelStoref(GLenum pname, GLfloat param)
7182{
7183   GET_CURRENT_CONTEXT(ctx);
7184   FLUSH_VERTICES(ctx, 0);
7185   CALL_PixelStoref(ctx->Exec, (pname, param));
7186}
7187
7188static void GLAPIENTRY
7189exec_PixelStorei(GLenum pname, GLint param)
7190{
7191   GET_CURRENT_CONTEXT(ctx);
7192   FLUSH_VERTICES(ctx, 0);
7193   CALL_PixelStorei(ctx->Exec, (pname, param));
7194}
7195
7196static void GLAPIENTRY
7197exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
7198                GLenum format, GLenum type, GLvoid * pixels)
7199{
7200   GET_CURRENT_CONTEXT(ctx);
7201   FLUSH_VERTICES(ctx, 0);
7202   CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels));
7203}
7204
7205static GLint GLAPIENTRY
7206exec_RenderMode(GLenum mode)
7207{
7208   GET_CURRENT_CONTEXT(ctx);
7209   FLUSH_VERTICES(ctx, 0);
7210   return CALL_RenderMode(ctx->Exec, (mode));
7211}
7212
7213static void GLAPIENTRY
7214exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
7215{
7216   GET_CURRENT_CONTEXT(ctx);
7217   FLUSH_VERTICES(ctx, 0);
7218   CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer));
7219}
7220
7221static void GLAPIENTRY
7222exec_SelectBuffer(GLsizei size, GLuint * buffer)
7223{
7224   GET_CURRENT_CONTEXT(ctx);
7225   FLUSH_VERTICES(ctx, 0);
7226   CALL_SelectBuffer(ctx->Exec, (size, buffer));
7227}
7228
7229static GLboolean GLAPIENTRY
7230exec_AreTexturesResident(GLsizei n, const GLuint * texName,
7231                         GLboolean * residences)
7232{
7233   GET_CURRENT_CONTEXT(ctx);
7234   FLUSH_VERTICES(ctx, 0);
7235   return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences));
7236}
7237
7238static void GLAPIENTRY
7239exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
7240{
7241   GET_CURRENT_CONTEXT(ctx);
7242   FLUSH_VERTICES(ctx, 0);
7243   CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr));
7244}
7245
7246static void GLAPIENTRY
7247exec_DeleteTextures(GLsizei n, const GLuint * texName)
7248{
7249   GET_CURRENT_CONTEXT(ctx);
7250   FLUSH_VERTICES(ctx, 0);
7251   CALL_DeleteTextures(ctx->Exec, (n, texName));
7252}
7253
7254static void GLAPIENTRY
7255exec_DisableClientState(GLenum cap)
7256{
7257   GET_CURRENT_CONTEXT(ctx);
7258   FLUSH_VERTICES(ctx, 0);
7259   CALL_DisableClientState(ctx->Exec, (cap));
7260}
7261
7262static void GLAPIENTRY
7263exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr)
7264{
7265   GET_CURRENT_CONTEXT(ctx);
7266   FLUSH_VERTICES(ctx, 0);
7267   CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr));
7268}
7269
7270static void GLAPIENTRY
7271exec_EnableClientState(GLenum cap)
7272{
7273   GET_CURRENT_CONTEXT(ctx);
7274   FLUSH_VERTICES(ctx, 0);
7275   CALL_EnableClientState(ctx->Exec, (cap));
7276}
7277
7278static void GLAPIENTRY
7279exec_GenTextures(GLsizei n, GLuint * texName)
7280{
7281   GET_CURRENT_CONTEXT(ctx);
7282   FLUSH_VERTICES(ctx, 0);
7283   CALL_GenTextures(ctx->Exec, (n, texName));
7284}
7285
7286static void GLAPIENTRY
7287exec_GetPointerv(GLenum pname, GLvoid **params)
7288{
7289   GET_CURRENT_CONTEXT(ctx);
7290   FLUSH_VERTICES(ctx, 0);
7291   CALL_GetPointerv(ctx->Exec, (pname, params));
7292}
7293
7294static void GLAPIENTRY
7295exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
7296{
7297   GET_CURRENT_CONTEXT(ctx);
7298   FLUSH_VERTICES(ctx, 0);
7299   CALL_IndexPointer(ctx->Exec, (type, stride, ptr));
7300}
7301
7302static void GLAPIENTRY
7303exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer)
7304{
7305   GET_CURRENT_CONTEXT(ctx);
7306   FLUSH_VERTICES(ctx, 0);
7307   CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer));
7308}
7309
7310static GLboolean GLAPIENTRY
7311exec_IsTexture(GLuint texture)
7312{
7313   GET_CURRENT_CONTEXT(ctx);
7314   FLUSH_VERTICES(ctx, 0);
7315   return CALL_IsTexture(ctx->Exec, (texture));
7316}
7317
7318static void GLAPIENTRY
7319exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
7320{
7321   GET_CURRENT_CONTEXT(ctx);
7322   FLUSH_VERTICES(ctx, 0);
7323   CALL_NormalPointer(ctx->Exec, (type, stride, ptr));
7324}
7325
7326static void GLAPIENTRY
7327exec_PopClientAttrib(void)
7328{
7329   GET_CURRENT_CONTEXT(ctx);
7330   FLUSH_VERTICES(ctx, 0);
7331   CALL_PopClientAttrib(ctx->Exec, ());
7332}
7333
7334static void GLAPIENTRY
7335exec_PushClientAttrib(GLbitfield mask)
7336{
7337   GET_CURRENT_CONTEXT(ctx);
7338   FLUSH_VERTICES(ctx, 0);
7339   CALL_PushClientAttrib(ctx->Exec, (mask));
7340}
7341
7342static void GLAPIENTRY
7343exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
7344                     const GLvoid *ptr)
7345{
7346   GET_CURRENT_CONTEXT(ctx);
7347   FLUSH_VERTICES(ctx, 0);
7348   CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr));
7349}
7350
7351static void GLAPIENTRY
7352exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img)
7353{
7354   GET_CURRENT_CONTEXT(ctx);
7355   FLUSH_VERTICES(ctx, 0);
7356   CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img));
7357}
7358
7359static void GLAPIENTRY
7360exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
7361                   const GLvoid *ptr)
7362{
7363   GET_CURRENT_CONTEXT(ctx);
7364   FLUSH_VERTICES(ctx, 0);
7365   CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr));
7366}
7367
7368static void GLAPIENTRY
7369exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
7370                             GLint x, GLint y, GLsizei width)
7371{
7372   GET_CURRENT_CONTEXT(ctx);
7373   FLUSH_VERTICES(ctx, 0);
7374   CALL_CopyConvolutionFilter1D(ctx->Exec,
7375                                (target, internalFormat, x, y, width));
7376}
7377
7378static void GLAPIENTRY
7379exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
7380                             GLint x, GLint y, GLsizei width, GLsizei height)
7381{
7382   GET_CURRENT_CONTEXT(ctx);
7383   FLUSH_VERTICES(ctx, 0);
7384   CALL_CopyConvolutionFilter2D(ctx->Exec,
7385                                (target, internalFormat, x, y, width,
7386                                 height));
7387}
7388
7389static void GLAPIENTRY
7390exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data)
7391{
7392   GET_CURRENT_CONTEXT(ctx);
7393   FLUSH_VERTICES(ctx, 0);
7394   CALL_GetColorTable(ctx->Exec, (target, format, type, data));
7395}
7396
7397static void GLAPIENTRY
7398exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params)
7399{
7400   GET_CURRENT_CONTEXT(ctx);
7401   FLUSH_VERTICES(ctx, 0);
7402   CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params));
7403}
7404
7405static void GLAPIENTRY
7406exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params)
7407{
7408   GET_CURRENT_CONTEXT(ctx);
7409   FLUSH_VERTICES(ctx, 0);
7410   CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params));
7411}
7412
7413static void GLAPIENTRY
7414exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
7415                          GLvoid * image)
7416{
7417   GET_CURRENT_CONTEXT(ctx);
7418   FLUSH_VERTICES(ctx, 0);
7419   CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image));
7420}
7421
7422static void GLAPIENTRY
7423exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
7424{
7425   GET_CURRENT_CONTEXT(ctx);
7426   FLUSH_VERTICES(ctx, 0);
7427   CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params));
7428}
7429
7430static void GLAPIENTRY
7431exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
7432{
7433   GET_CURRENT_CONTEXT(ctx);
7434   FLUSH_VERTICES(ctx, 0);
7435   CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params));
7436}
7437
7438static void GLAPIENTRY
7439exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
7440                  GLenum type, GLvoid *values)
7441{
7442   GET_CURRENT_CONTEXT(ctx);
7443   FLUSH_VERTICES(ctx, 0);
7444   CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values));
7445}
7446
7447static void GLAPIENTRY
7448exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params)
7449{
7450   GET_CURRENT_CONTEXT(ctx);
7451   FLUSH_VERTICES(ctx, 0);
7452   CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params));
7453}
7454
7455static void GLAPIENTRY
7456exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params)
7457{
7458   GET_CURRENT_CONTEXT(ctx);
7459   FLUSH_VERTICES(ctx, 0);
7460   CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params));
7461}
7462
7463static void GLAPIENTRY
7464exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
7465               GLenum type, GLvoid *values)
7466{
7467   GET_CURRENT_CONTEXT(ctx);
7468   FLUSH_VERTICES(ctx, 0);
7469   CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values));
7470}
7471
7472static void GLAPIENTRY
7473exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params)
7474{
7475   GET_CURRENT_CONTEXT(ctx);
7476   FLUSH_VERTICES(ctx, 0);
7477   CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params));
7478}
7479
7480static void GLAPIENTRY
7481exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params)
7482{
7483   GET_CURRENT_CONTEXT(ctx);
7484   FLUSH_VERTICES(ctx, 0);
7485   CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params));
7486}
7487
7488static void GLAPIENTRY
7489exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
7490                        GLvoid *row, GLvoid *column, GLvoid *span)
7491{
7492   GET_CURRENT_CONTEXT(ctx);
7493   FLUSH_VERTICES(ctx, 0);
7494   CALL_GetSeparableFilter(ctx->Exec,
7495                           (target, format, type, row, column, span));
7496}
7497
7498static void GLAPIENTRY
7499exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
7500                       GLsizei width, GLsizei height, GLenum format,
7501                       GLenum type, const GLvoid *row, const GLvoid *column)
7502{
7503   GET_CURRENT_CONTEXT(ctx);
7504   FLUSH_VERTICES(ctx, 0);
7505   CALL_SeparableFilter2D(ctx->Exec,
7506                          (target, internalFormat, width, height, format,
7507                           type, row, column));
7508}
7509
7510static void GLAPIENTRY
7511exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
7512                     GLsizei count, const GLvoid *ptr)
7513{
7514   GET_CURRENT_CONTEXT(ctx);
7515   FLUSH_VERTICES(ctx, 0);
7516   CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7517}
7518
7519static void GLAPIENTRY
7520exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
7521{
7522   GET_CURRENT_CONTEXT(ctx);
7523   FLUSH_VERTICES(ctx, 0);
7524   CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr));
7525}
7526
7527static void GLAPIENTRY
7528exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
7529                     const GLvoid *ptr)
7530{
7531   GET_CURRENT_CONTEXT(ctx);
7532   FLUSH_VERTICES(ctx, 0);
7533   CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr));
7534}
7535
7536static void GLAPIENTRY
7537exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
7538                      const GLvoid *ptr)
7539{
7540   GET_CURRENT_CONTEXT(ctx);
7541   FLUSH_VERTICES(ctx, 0);
7542   CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr));
7543}
7544
7545static void GLAPIENTRY
7546exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
7547                        GLsizei count, const GLvoid *ptr)
7548{
7549   GET_CURRENT_CONTEXT(ctx);
7550   FLUSH_VERTICES(ctx, 0);
7551   CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7552}
7553
7554static void GLAPIENTRY
7555exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
7556                      GLsizei count, const GLvoid *ptr)
7557{
7558   GET_CURRENT_CONTEXT(ctx);
7559   FLUSH_VERTICES(ctx, 0);
7560   CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
7561}
7562
7563static void GLAPIENTRY
7564exec_LockArraysEXT(GLint first, GLsizei count)
7565{
7566   GET_CURRENT_CONTEXT(ctx);
7567   FLUSH_VERTICES(ctx, 0);
7568   CALL_LockArraysEXT(ctx->Exec, (first, count));
7569}
7570
7571static void GLAPIENTRY
7572exec_UnlockArraysEXT(void)
7573{
7574   GET_CURRENT_CONTEXT(ctx);
7575   FLUSH_VERTICES(ctx, 0);
7576   CALL_UnlockArraysEXT(ctx->Exec, ());
7577}
7578
7579static void GLAPIENTRY
7580exec_ClientActiveTextureARB(GLenum target)
7581{
7582   GET_CURRENT_CONTEXT(ctx);
7583   FLUSH_VERTICES(ctx, 0);
7584   CALL_ClientActiveTextureARB(ctx->Exec, (target));
7585}
7586
7587static void GLAPIENTRY
7588exec_SecondaryColorPointerEXT(GLint size, GLenum type,
7589                              GLsizei stride, const GLvoid *ptr)
7590{
7591   GET_CURRENT_CONTEXT(ctx);
7592   FLUSH_VERTICES(ctx, 0);
7593   CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr));
7594}
7595
7596static void GLAPIENTRY
7597exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
7598{
7599   GET_CURRENT_CONTEXT(ctx);
7600   FLUSH_VERTICES(ctx, 0);
7601   CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr));
7602}
7603
7604/* GL_EXT_multi_draw_arrays */
7605static void GLAPIENTRY
7606exec_MultiDrawArraysEXT(GLenum mode, GLint * first,
7607                        GLsizei * count, GLsizei primcount)
7608{
7609   GET_CURRENT_CONTEXT(ctx);
7610   FLUSH_VERTICES(ctx, 0);
7611   CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount));
7612}
7613
7614/* GL_EXT_multi_draw_arrays */
7615static void GLAPIENTRY
7616exec_MultiDrawElementsEXT(GLenum mode, const GLsizei * count,
7617                          GLenum type, const GLvoid ** indices,
7618                          GLsizei primcount)
7619{
7620   GET_CURRENT_CONTEXT(ctx);
7621   FLUSH_VERTICES(ctx, 0);
7622   CALL_MultiDrawElementsEXT(ctx->Exec,
7623                             (mode, count, type, indices, primcount));
7624}
7625
7626/* GL_IBM_multimode_draw_arrays */
7627static void GLAPIENTRY
7628exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first,
7629                            const GLsizei * count, GLsizei primcount,
7630                            GLint modestride)
7631{
7632   GET_CURRENT_CONTEXT(ctx);
7633   FLUSH_VERTICES(ctx, 0);
7634   CALL_MultiModeDrawArraysIBM(ctx->Exec,
7635                               (mode, first, count, primcount, modestride));
7636}
7637
7638/* GL_IBM_multimode_draw_arrays */
7639static void GLAPIENTRY
7640exec_MultiModeDrawElementsIBM(const GLenum * mode,
7641                              const GLsizei * count,
7642                              GLenum type,
7643                              const GLvoid * const *indices,
7644                              GLsizei primcount, GLint modestride)
7645{
7646   GET_CURRENT_CONTEXT(ctx);
7647   FLUSH_VERTICES(ctx, 0);
7648   CALL_MultiModeDrawElementsIBM(ctx->Exec,
7649                                 (mode, count, type, indices, primcount,
7650                                  modestride));
7651}
7652
7653
7654
7655/**
7656 * Setup the given dispatch table to point to Mesa's display list
7657 * building functions.
7658 *
7659 * This does not include any of the tnl functions - they are
7660 * initialized from _mesa_init_api_defaults and from the active vtxfmt
7661 * struct.
7662 */
7663void
7664_mesa_init_dlist_table(struct _glapi_table *table)
7665{
7666   _mesa_loopback_init_api_table(table);
7667
7668   /* GL 1.0 */
7669   SET_Accum(table, save_Accum);
7670   SET_AlphaFunc(table, save_AlphaFunc);
7671   SET_Bitmap(table, save_Bitmap);
7672   SET_BlendFunc(table, save_BlendFunc);
7673   SET_CallList(table, _mesa_save_CallList);
7674   SET_CallLists(table, _mesa_save_CallLists);
7675   SET_Clear(table, save_Clear);
7676   SET_ClearAccum(table, save_ClearAccum);
7677   SET_ClearColor(table, save_ClearColor);
7678   SET_ClearDepth(table, save_ClearDepth);
7679   SET_ClearIndex(table, save_ClearIndex);
7680   SET_ClearStencil(table, save_ClearStencil);
7681   SET_ClipPlane(table, save_ClipPlane);
7682   SET_ColorMask(table, save_ColorMask);
7683   SET_ColorMaterial(table, save_ColorMaterial);
7684   SET_CopyPixels(table, save_CopyPixels);
7685   SET_CullFace(table, save_CullFace);
7686   SET_DeleteLists(table, _mesa_DeleteLists);
7687   SET_DepthFunc(table, save_DepthFunc);
7688   SET_DepthMask(table, save_DepthMask);
7689   SET_DepthRange(table, save_DepthRange);
7690   SET_Disable(table, save_Disable);
7691   SET_DrawBuffer(table, save_DrawBuffer);
7692   SET_DrawPixels(table, save_DrawPixels);
7693   SET_Enable(table, save_Enable);
7694   SET_EndList(table, _mesa_EndList);
7695   SET_EvalMesh1(table, _mesa_save_EvalMesh1);
7696   SET_EvalMesh2(table, _mesa_save_EvalMesh2);
7697   SET_Finish(table, exec_Finish);
7698   SET_Flush(table, exec_Flush);
7699   SET_Fogf(table, save_Fogf);
7700   SET_Fogfv(table, save_Fogfv);
7701   SET_Fogi(table, save_Fogi);
7702   SET_Fogiv(table, save_Fogiv);
7703   SET_FrontFace(table, save_FrontFace);
7704   SET_Frustum(table, save_Frustum);
7705   SET_GenLists(table, _mesa_GenLists);
7706   SET_GetBooleanv(table, exec_GetBooleanv);
7707   SET_GetClipPlane(table, exec_GetClipPlane);
7708   SET_GetDoublev(table, exec_GetDoublev);
7709   SET_GetError(table, exec_GetError);
7710   SET_GetFloatv(table, exec_GetFloatv);
7711   SET_GetIntegerv(table, exec_GetIntegerv);
7712   SET_GetLightfv(table, exec_GetLightfv);
7713   SET_GetLightiv(table, exec_GetLightiv);
7714   SET_GetMapdv(table, exec_GetMapdv);
7715   SET_GetMapfv(table, exec_GetMapfv);
7716   SET_GetMapiv(table, exec_GetMapiv);
7717   SET_GetMaterialfv(table, exec_GetMaterialfv);
7718   SET_GetMaterialiv(table, exec_GetMaterialiv);
7719   SET_GetPixelMapfv(table, exec_GetPixelMapfv);
7720   SET_GetPixelMapuiv(table, exec_GetPixelMapuiv);
7721   SET_GetPixelMapusv(table, exec_GetPixelMapusv);
7722   SET_GetPolygonStipple(table, exec_GetPolygonStipple);
7723   SET_GetString(table, exec_GetString);
7724   SET_GetTexEnvfv(table, exec_GetTexEnvfv);
7725   SET_GetTexEnviv(table, exec_GetTexEnviv);
7726   SET_GetTexGendv(table, exec_GetTexGendv);
7727   SET_GetTexGenfv(table, exec_GetTexGenfv);
7728   SET_GetTexGeniv(table, exec_GetTexGeniv);
7729   SET_GetTexImage(table, exec_GetTexImage);
7730   SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv);
7731   SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv);
7732   SET_GetTexParameterfv(table, exec_GetTexParameterfv);
7733   SET_GetTexParameteriv(table, exec_GetTexParameteriv);
7734   SET_Hint(table, save_Hint);
7735   SET_IndexMask(table, save_IndexMask);
7736   SET_InitNames(table, save_InitNames);
7737   SET_IsEnabled(table, exec_IsEnabled);
7738   SET_IsList(table, _mesa_IsList);
7739   SET_LightModelf(table, save_LightModelf);
7740   SET_LightModelfv(table, save_LightModelfv);
7741   SET_LightModeli(table, save_LightModeli);
7742   SET_LightModeliv(table, save_LightModeliv);
7743   SET_Lightf(table, save_Lightf);
7744   SET_Lightfv(table, save_Lightfv);
7745   SET_Lighti(table, save_Lighti);
7746   SET_Lightiv(table, save_Lightiv);
7747   SET_LineStipple(table, save_LineStipple);
7748   SET_LineWidth(table, save_LineWidth);
7749   SET_ListBase(table, save_ListBase);
7750   SET_LoadIdentity(table, save_LoadIdentity);
7751   SET_LoadMatrixd(table, save_LoadMatrixd);
7752   SET_LoadMatrixf(table, save_LoadMatrixf);
7753   SET_LoadName(table, save_LoadName);
7754   SET_LogicOp(table, save_LogicOp);
7755   SET_Map1d(table, save_Map1d);
7756   SET_Map1f(table, save_Map1f);
7757   SET_Map2d(table, save_Map2d);
7758   SET_Map2f(table, save_Map2f);
7759   SET_MapGrid1d(table, save_MapGrid1d);
7760   SET_MapGrid1f(table, save_MapGrid1f);
7761   SET_MapGrid2d(table, save_MapGrid2d);
7762   SET_MapGrid2f(table, save_MapGrid2f);
7763   SET_MatrixMode(table, save_MatrixMode);
7764   SET_MultMatrixd(table, save_MultMatrixd);
7765   SET_MultMatrixf(table, save_MultMatrixf);
7766   SET_NewList(table, save_NewList);
7767   SET_Ortho(table, save_Ortho);
7768   SET_PassThrough(table, save_PassThrough);
7769   SET_PixelMapfv(table, save_PixelMapfv);
7770   SET_PixelMapuiv(table, save_PixelMapuiv);
7771   SET_PixelMapusv(table, save_PixelMapusv);
7772   SET_PixelStoref(table, exec_PixelStoref);
7773   SET_PixelStorei(table, exec_PixelStorei);
7774   SET_PixelTransferf(table, save_PixelTransferf);
7775   SET_PixelTransferi(table, save_PixelTransferi);
7776   SET_PixelZoom(table, save_PixelZoom);
7777   SET_PointSize(table, save_PointSize);
7778   SET_PolygonMode(table, save_PolygonMode);
7779   SET_PolygonOffset(table, save_PolygonOffset);
7780   SET_PolygonStipple(table, save_PolygonStipple);
7781   SET_PopAttrib(table, save_PopAttrib);
7782   SET_PopMatrix(table, save_PopMatrix);
7783   SET_PopName(table, save_PopName);
7784   SET_PushAttrib(table, save_PushAttrib);
7785   SET_PushMatrix(table, save_PushMatrix);
7786   SET_PushName(table, save_PushName);
7787   SET_RasterPos2d(table, save_RasterPos2d);
7788   SET_RasterPos2dv(table, save_RasterPos2dv);
7789   SET_RasterPos2f(table, save_RasterPos2f);
7790   SET_RasterPos2fv(table, save_RasterPos2fv);
7791   SET_RasterPos2i(table, save_RasterPos2i);
7792   SET_RasterPos2iv(table, save_RasterPos2iv);
7793   SET_RasterPos2s(table, save_RasterPos2s);
7794   SET_RasterPos2sv(table, save_RasterPos2sv);
7795   SET_RasterPos3d(table, save_RasterPos3d);
7796   SET_RasterPos3dv(table, save_RasterPos3dv);
7797   SET_RasterPos3f(table, save_RasterPos3f);
7798   SET_RasterPos3fv(table, save_RasterPos3fv);
7799   SET_RasterPos3i(table, save_RasterPos3i);
7800   SET_RasterPos3iv(table, save_RasterPos3iv);
7801   SET_RasterPos3s(table, save_RasterPos3s);
7802   SET_RasterPos3sv(table, save_RasterPos3sv);
7803   SET_RasterPos4d(table, save_RasterPos4d);
7804   SET_RasterPos4dv(table, save_RasterPos4dv);
7805   SET_RasterPos4f(table, save_RasterPos4f);
7806   SET_RasterPos4fv(table, save_RasterPos4fv);
7807   SET_RasterPos4i(table, save_RasterPos4i);
7808   SET_RasterPos4iv(table, save_RasterPos4iv);
7809   SET_RasterPos4s(table, save_RasterPos4s);
7810   SET_RasterPos4sv(table, save_RasterPos4sv);
7811   SET_ReadBuffer(table, save_ReadBuffer);
7812   SET_ReadPixels(table, exec_ReadPixels);
7813   SET_RenderMode(table, exec_RenderMode);
7814   SET_Rotated(table, save_Rotated);
7815   SET_Rotatef(table, save_Rotatef);
7816   SET_Scaled(table, save_Scaled);
7817   SET_Scalef(table, save_Scalef);
7818   SET_Scissor(table, save_Scissor);
7819   SET_FeedbackBuffer(table, exec_FeedbackBuffer);
7820   SET_SelectBuffer(table, exec_SelectBuffer);
7821   SET_ShadeModel(table, save_ShadeModel);
7822   SET_StencilFunc(table, save_StencilFunc);
7823   SET_StencilMask(table, save_StencilMask);
7824   SET_StencilOp(table, save_StencilOp);
7825   SET_TexEnvf(table, save_TexEnvf);
7826   SET_TexEnvfv(table, save_TexEnvfv);
7827   SET_TexEnvi(table, save_TexEnvi);
7828   SET_TexEnviv(table, save_TexEnviv);
7829   SET_TexGend(table, save_TexGend);
7830   SET_TexGendv(table, save_TexGendv);
7831   SET_TexGenf(table, save_TexGenf);
7832   SET_TexGenfv(table, save_TexGenfv);
7833   SET_TexGeni(table, save_TexGeni);
7834   SET_TexGeniv(table, save_TexGeniv);
7835   SET_TexImage1D(table, save_TexImage1D);
7836   SET_TexImage2D(table, save_TexImage2D);
7837   SET_TexParameterf(table, save_TexParameterf);
7838   SET_TexParameterfv(table, save_TexParameterfv);
7839   SET_TexParameteri(table, save_TexParameteri);
7840   SET_TexParameteriv(table, save_TexParameteriv);
7841   SET_Translated(table, save_Translated);
7842   SET_Translatef(table, save_Translatef);
7843   SET_Viewport(table, save_Viewport);
7844
7845   /* GL 1.1 */
7846   SET_AreTexturesResident(table, exec_AreTexturesResident);
7847   SET_BindTexture(table, save_BindTexture);
7848   SET_ColorPointer(table, exec_ColorPointer);
7849   SET_CopyTexImage1D(table, save_CopyTexImage1D);
7850   SET_CopyTexImage2D(table, save_CopyTexImage2D);
7851   SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
7852   SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
7853   SET_DeleteTextures(table, exec_DeleteTextures);
7854   SET_DisableClientState(table, exec_DisableClientState);
7855   SET_EdgeFlagPointer(table, exec_EdgeFlagPointer);
7856   SET_EnableClientState(table, exec_EnableClientState);
7857   SET_GenTextures(table, exec_GenTextures);
7858   SET_GetPointerv(table, exec_GetPointerv);
7859   SET_IndexPointer(table, exec_IndexPointer);
7860   SET_InterleavedArrays(table, exec_InterleavedArrays);
7861   SET_IsTexture(table, exec_IsTexture);
7862   SET_NormalPointer(table, exec_NormalPointer);
7863   SET_PopClientAttrib(table, exec_PopClientAttrib);
7864   SET_PrioritizeTextures(table, save_PrioritizeTextures);
7865   SET_PushClientAttrib(table, exec_PushClientAttrib);
7866   SET_TexCoordPointer(table, exec_TexCoordPointer);
7867   SET_TexSubImage1D(table, save_TexSubImage1D);
7868   SET_TexSubImage2D(table, save_TexSubImage2D);
7869   SET_VertexPointer(table, exec_VertexPointer);
7870
7871   /* GL 1.2 */
7872   SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
7873   SET_TexImage3D(table, save_TexImage3D);
7874   SET_TexSubImage3D(table, save_TexSubImage3D);
7875
7876   /* GL 2.0 */
7877   SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
7878   SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
7879   SET_StencilOpSeparate(table, save_StencilOpSeparate);
7880
7881   /* ATI_separate_stencil */
7882   SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
7883
7884   /* GL_ARB_imaging */
7885   /* Not all are supported */
7886   SET_BlendColor(table, save_BlendColor);
7887   SET_BlendEquation(table, save_BlendEquation);
7888   SET_ColorSubTable(table, save_ColorSubTable);
7889   SET_ColorTable(table, save_ColorTable);
7890   SET_ColorTableParameterfv(table, save_ColorTableParameterfv);
7891   SET_ColorTableParameteriv(table, save_ColorTableParameteriv);
7892   SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D);
7893   SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D);
7894   SET_ConvolutionParameterf(table, save_ConvolutionParameterf);
7895   SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv);
7896   SET_ConvolutionParameteri(table, save_ConvolutionParameteri);
7897   SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv);
7898   SET_CopyColorSubTable(table, save_CopyColorSubTable);
7899   SET_CopyColorTable(table, save_CopyColorTable);
7900   SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D);
7901   SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D);
7902   SET_GetColorTable(table, exec_GetColorTable);
7903   SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv);
7904   SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv);
7905   SET_GetConvolutionFilter(table, exec_GetConvolutionFilter);
7906   SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv);
7907   SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv);
7908   SET_GetHistogram(table, exec_GetHistogram);
7909   SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv);
7910   SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv);
7911   SET_GetMinmax(table, exec_GetMinmax);
7912   SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv);
7913   SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv);
7914   SET_GetSeparableFilter(table, exec_GetSeparableFilter);
7915   SET_Histogram(table, save_Histogram);
7916   SET_Minmax(table, save_Minmax);
7917   SET_ResetHistogram(table, save_ResetHistogram);
7918   SET_ResetMinmax(table, save_ResetMinmax);
7919   SET_SeparableFilter2D(table, exec_SeparableFilter2D);
7920
7921   /* 2. GL_EXT_blend_color */
7922#if 0
7923   SET_BlendColorEXT(table, save_BlendColorEXT);
7924#endif
7925
7926   /* 3. GL_EXT_polygon_offset */
7927   SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT);
7928
7929   /* 6. GL_EXT_texture3d */
7930#if 0
7931   SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
7932   SET_TexImage3DEXT(table, save_TexImage3DEXT);
7933   SET_TexSubImage3DEXT(table, save_TexSubImage3D);
7934#endif
7935
7936   /* 14. GL_SGI_color_table */
7937#if 0
7938   SET_ColorTableSGI(table, save_ColorTable);
7939   SET_ColorSubTableSGI(table, save_ColorSubTable);
7940   SET_GetColorTableSGI(table, exec_GetColorTable);
7941   SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv);
7942   SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv);
7943#endif
7944
7945   /* 30. GL_EXT_vertex_array */
7946   SET_ColorPointerEXT(table, exec_ColorPointerEXT);
7947   SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT);
7948   SET_IndexPointerEXT(table, exec_IndexPointerEXT);
7949   SET_NormalPointerEXT(table, exec_NormalPointerEXT);
7950   SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT);
7951   SET_VertexPointerEXT(table, exec_VertexPointerEXT);
7952
7953   /* 37. GL_EXT_blend_minmax */
7954#if 0
7955   SET_BlendEquationEXT(table, save_BlendEquationEXT);
7956#endif
7957
7958   /* 54. GL_EXT_point_parameters */
7959   SET_PointParameterfEXT(table, save_PointParameterfEXT);
7960   SET_PointParameterfvEXT(table, save_PointParameterfvEXT);
7961
7962   /* 97. GL_EXT_compiled_vertex_array */
7963   SET_LockArraysEXT(table, exec_LockArraysEXT);
7964   SET_UnlockArraysEXT(table, exec_UnlockArraysEXT);
7965
7966   /* 145. GL_EXT_secondary_color */
7967   SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT);
7968
7969   /* 148. GL_EXT_multi_draw_arrays */
7970   SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT);
7971   SET_MultiDrawElementsEXT(table, exec_MultiDrawElementsEXT);
7972
7973   /* 149. GL_EXT_fog_coord */
7974   SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT);
7975
7976   /* 173. GL_EXT_blend_func_separate */
7977   SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT);
7978
7979   /* 196. GL_MESA_resize_buffers */
7980   SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA);
7981
7982   /* 197. GL_MESA_window_pos */
7983   SET_WindowPos2dMESA(table, save_WindowPos2dMESA);
7984   SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA);
7985   SET_WindowPos2fMESA(table, save_WindowPos2fMESA);
7986   SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA);
7987   SET_WindowPos2iMESA(table, save_WindowPos2iMESA);
7988   SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA);
7989   SET_WindowPos2sMESA(table, save_WindowPos2sMESA);
7990   SET_WindowPos2svMESA(table, save_WindowPos2svMESA);
7991   SET_WindowPos3dMESA(table, save_WindowPos3dMESA);
7992   SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA);
7993   SET_WindowPos3fMESA(table, save_WindowPos3fMESA);
7994   SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA);
7995   SET_WindowPos3iMESA(table, save_WindowPos3iMESA);
7996   SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA);
7997   SET_WindowPos3sMESA(table, save_WindowPos3sMESA);
7998   SET_WindowPos3svMESA(table, save_WindowPos3svMESA);
7999   SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
8000   SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
8001   SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
8002   SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
8003   SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
8004   SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
8005   SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
8006   SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
8007
8008   /* 200. GL_IBM_multimode_draw_arrays */
8009   SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM);
8010   SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM);
8011
8012#if FEATURE_NV_vertex_program
8013   /* 233. GL_NV_vertex_program */
8014   /* The following commands DO NOT go into display lists:
8015    * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
8016    * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
8017    */
8018   SET_BindProgramNV(table, save_BindProgramNV);
8019   SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
8020   SET_ExecuteProgramNV(table, save_ExecuteProgramNV);
8021   SET_GenProgramsNV(table, _mesa_GenPrograms);
8022   SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV);
8023   SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV);
8024   SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV);
8025   SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV);
8026   SET_GetProgramivNV(table, _mesa_GetProgramivNV);
8027   SET_GetProgramStringNV(table, _mesa_GetProgramStringNV);
8028   SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV);
8029   SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
8030   SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
8031   SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
8032   SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
8033   SET_IsProgramNV(table, _mesa_IsProgramARB);
8034   SET_LoadProgramNV(table, save_LoadProgramNV);
8035   SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
8036   SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
8037   SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
8038   SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
8039   SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
8040   SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
8041   SET_TrackMatrixNV(table, save_TrackMatrixNV);
8042   SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV);
8043#endif
8044
8045   /* 245. GL_ATI_fragment_shader */
8046#if FEATURE_ATI_fragment_shader
8047   SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
8048   SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
8049#endif
8050
8051   /* 282. GL_NV_fragment_program */
8052#if FEATURE_NV_fragment_program
8053   SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV);
8054   SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV);
8055   SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV);
8056   SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV);
8057   SET_GetProgramNamedParameterfvNV(table,
8058                                    _mesa_GetProgramNamedParameterfvNV);
8059   SET_GetProgramNamedParameterdvNV(table,
8060                                    _mesa_GetProgramNamedParameterdvNV);
8061   SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
8062   SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
8063   SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
8064   SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
8065   SET_GetProgramLocalParameterdvARB(table,
8066                                     _mesa_GetProgramLocalParameterdvARB);
8067   SET_GetProgramLocalParameterfvARB(table,
8068                                     _mesa_GetProgramLocalParameterfvARB);
8069#endif
8070
8071   /* 262. GL_NV_point_sprite */
8072   SET_PointParameteriNV(table, save_PointParameteriNV);
8073   SET_PointParameterivNV(table, save_PointParameterivNV);
8074
8075   /* 268. GL_EXT_stencil_two_side */
8076   SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
8077
8078   /* 273. GL_APPLE_vertex_array_object */
8079   SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE);
8080   SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE);
8081   SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE);
8082   SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE);
8083
8084   /* ???. GL_EXT_depth_bounds_test */
8085   SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
8086
8087   /* ARB 1. GL_ARB_multitexture */
8088   SET_ActiveTextureARB(table, save_ActiveTextureARB);
8089   SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB);
8090
8091   /* ARB 3. GL_ARB_transpose_matrix */
8092   SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB);
8093   SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB);
8094   SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB);
8095   SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB);
8096
8097   /* ARB 5. GL_ARB_multisample */
8098   SET_SampleCoverageARB(table, save_SampleCoverageARB);
8099
8100   /* ARB 12. GL_ARB_texture_compression */
8101   SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB);
8102   SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB);
8103   SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB);
8104   SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB);
8105   SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB);
8106   SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB);
8107   SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB);
8108
8109   /* ARB 14. GL_ARB_point_parameters */
8110   /* aliased with EXT_point_parameters functions */
8111
8112   /* ARB 25. GL_ARB_window_pos */
8113   /* aliased with MESA_window_pos functions */
8114
8115   /* ARB 26. GL_ARB_vertex_program */
8116   /* ARB 27. GL_ARB_fragment_program */
8117#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8118   /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
8119   SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB);
8120   SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB);
8121   SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB);
8122   SET_ProgramStringARB(table, save_ProgramStringARB);
8123   SET_BindProgramNV(table, save_BindProgramNV);
8124   SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
8125   SET_GenProgramsNV(table, _mesa_GenPrograms);
8126   SET_IsProgramNV(table, _mesa_IsProgramARB);
8127   SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
8128   SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
8129   SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
8130   SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
8131   SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
8132   SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
8133   SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
8134   SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
8135   SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
8136   SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
8137   SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
8138   SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
8139   SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB);
8140   SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB);
8141   SET_GetProgramLocalParameterdvARB(table,
8142                                     _mesa_GetProgramLocalParameterdvARB);
8143   SET_GetProgramLocalParameterfvARB(table,
8144                                     _mesa_GetProgramLocalParameterfvARB);
8145   SET_GetProgramivARB(table, _mesa_GetProgramivARB);
8146   SET_GetProgramStringARB(table, _mesa_GetProgramStringARB);
8147#endif
8148
8149   /* ARB 28. GL_ARB_vertex_buffer_object */
8150#if FEATURE_ARB_vertex_buffer_object
8151   /* None of the extension's functions get compiled */
8152   SET_BindBufferARB(table, _mesa_BindBufferARB);
8153   SET_BufferDataARB(table, _mesa_BufferDataARB);
8154   SET_BufferSubDataARB(table, _mesa_BufferSubDataARB);
8155   SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB);
8156   SET_GenBuffersARB(table, _mesa_GenBuffersARB);
8157   SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB);
8158   SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB);
8159   SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB);
8160   SET_IsBufferARB(table, _mesa_IsBufferARB);
8161   SET_MapBufferARB(table, _mesa_MapBufferARB);
8162   SET_UnmapBufferARB(table, _mesa_UnmapBufferARB);
8163#endif
8164
8165#if FEATURE_ARB_occlusion_query
8166   SET_BeginQueryARB(table, save_BeginQueryARB);
8167   SET_EndQueryARB(table, save_EndQueryARB);
8168   SET_GenQueriesARB(table, _mesa_GenQueriesARB);
8169   SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB);
8170   SET_IsQueryARB(table, _mesa_IsQueryARB);
8171   SET_GetQueryivARB(table, _mesa_GetQueryivARB);
8172   SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB);
8173   SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB);
8174#endif
8175   SET_DrawBuffersARB(table, save_DrawBuffersARB);
8176
8177#if FEATURE_EXT_framebuffer_blit
8178   SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
8179#endif
8180
8181   /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
8182   SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
8183   SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
8184   /* XXX additional functions need to be implemented here! */
8185
8186   /* 299. GL_EXT_blend_equation_separate */
8187   SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
8188
8189   /* GL_EXT_gpu_program_parmaeters */
8190#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8191   SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
8192   SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
8193#endif
8194}
8195
8196
8197
8198static const char *
8199enum_string(GLenum k)
8200{
8201   return _mesa_lookup_enum_by_nr(k);
8202}
8203
8204
8205/**
8206 * Print the commands in a display list.  For debugging only.
8207 * TODO: many commands aren't handled yet.
8208 */
8209static void GLAPIENTRY
8210print_list(GLcontext *ctx, GLuint list)
8211{
8212   struct mesa_display_list *dlist;
8213   Node *n;
8214   GLboolean done;
8215
8216   if (!islist(ctx, list)) {
8217      _mesa_printf("%u is not a display list ID\n", list);
8218      return;
8219   }
8220
8221   dlist = lookup_list(ctx, list);
8222   if (!dlist)
8223      return;
8224
8225   n = dlist->node;
8226
8227   _mesa_printf("START-LIST %u, address %p\n", list, (void *) n);
8228
8229   done = n ? GL_FALSE : GL_TRUE;
8230   while (!done) {
8231      OpCode opcode = n[0].opcode;
8232      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
8233
8234      if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
8235         /* this is a driver-extended opcode */
8236         ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
8237         n += ctx->ListExt.Opcode[i].Size;
8238      }
8239      else {
8240         switch (opcode) {
8241         case OPCODE_ACCUM:
8242            _mesa_printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
8243            break;
8244         case OPCODE_BITMAP:
8245            _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
8246                         n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data);
8247            break;
8248         case OPCODE_CALL_LIST:
8249            _mesa_printf("CallList %d\n", (int) n[1].ui);
8250            break;
8251         case OPCODE_CALL_LIST_OFFSET:
8252            _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
8253                         ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
8254            break;
8255         case OPCODE_COLOR_TABLE_PARAMETER_FV:
8256            _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
8257                         enum_string(n[1].e), enum_string(n[2].e),
8258                         n[3].f, n[4].f, n[5].f, n[6].f);
8259            break;
8260         case OPCODE_COLOR_TABLE_PARAMETER_IV:
8261            _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
8262                         enum_string(n[1].e), enum_string(n[2].e),
8263                         n[3].i, n[4].i, n[5].i, n[6].i);
8264            break;
8265         case OPCODE_DISABLE:
8266            _mesa_printf("Disable %s\n", enum_string(n[1].e));
8267            break;
8268         case OPCODE_ENABLE:
8269            _mesa_printf("Enable %s\n", enum_string(n[1].e));
8270            break;
8271         case OPCODE_FRUSTUM:
8272            _mesa_printf("Frustum %g %g %g %g %g %g\n",
8273                         n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
8274            break;
8275         case OPCODE_LINE_STIPPLE:
8276            _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us);
8277            break;
8278         case OPCODE_LOAD_IDENTITY:
8279            _mesa_printf("LoadIdentity\n");
8280            break;
8281         case OPCODE_LOAD_MATRIX:
8282            _mesa_printf("LoadMatrix\n");
8283            _mesa_printf("  %8f %8f %8f %8f\n",
8284                         n[1].f, n[5].f, n[9].f, n[13].f);
8285            _mesa_printf("  %8f %8f %8f %8f\n",
8286                         n[2].f, n[6].f, n[10].f, n[14].f);
8287            _mesa_printf("  %8f %8f %8f %8f\n",
8288                         n[3].f, n[7].f, n[11].f, n[15].f);
8289            _mesa_printf("  %8f %8f %8f %8f\n",
8290                         n[4].f, n[8].f, n[12].f, n[16].f);
8291            break;
8292         case OPCODE_MULT_MATRIX:
8293            _mesa_printf("MultMatrix (or Rotate)\n");
8294            _mesa_printf("  %8f %8f %8f %8f\n",
8295                         n[1].f, n[5].f, n[9].f, n[13].f);
8296            _mesa_printf("  %8f %8f %8f %8f\n",
8297                         n[2].f, n[6].f, n[10].f, n[14].f);
8298            _mesa_printf("  %8f %8f %8f %8f\n",
8299                         n[3].f, n[7].f, n[11].f, n[15].f);
8300            _mesa_printf("  %8f %8f %8f %8f\n",
8301                         n[4].f, n[8].f, n[12].f, n[16].f);
8302            break;
8303         case OPCODE_ORTHO:
8304            _mesa_printf("Ortho %g %g %g %g %g %g\n",
8305                         n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
8306            break;
8307         case OPCODE_POP_ATTRIB:
8308            _mesa_printf("PopAttrib\n");
8309            break;
8310         case OPCODE_POP_MATRIX:
8311            _mesa_printf("PopMatrix\n");
8312            break;
8313         case OPCODE_POP_NAME:
8314            _mesa_printf("PopName\n");
8315            break;
8316         case OPCODE_PUSH_ATTRIB:
8317            _mesa_printf("PushAttrib %x\n", n[1].bf);
8318            break;
8319         case OPCODE_PUSH_MATRIX:
8320            _mesa_printf("PushMatrix\n");
8321            break;
8322         case OPCODE_PUSH_NAME:
8323            _mesa_printf("PushName %d\n", (int) n[1].ui);
8324            break;
8325         case OPCODE_RASTER_POS:
8326            _mesa_printf("RasterPos %g %g %g %g\n",
8327                         n[1].f, n[2].f, n[3].f, n[4].f);
8328            break;
8329         case OPCODE_ROTATE:
8330            _mesa_printf("Rotate %g %g %g %g\n",
8331                         n[1].f, n[2].f, n[3].f, n[4].f);
8332            break;
8333         case OPCODE_SCALE:
8334            _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
8335            break;
8336         case OPCODE_TRANSLATE:
8337            _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
8338            break;
8339         case OPCODE_BIND_TEXTURE:
8340            _mesa_printf("BindTexture %s %d\n",
8341                         _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
8342            break;
8343         case OPCODE_SHADE_MODEL:
8344            _mesa_printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
8345            break;
8346         case OPCODE_MAP1:
8347            _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
8348                         _mesa_lookup_enum_by_nr(n[1].ui),
8349                         n[2].f, n[3].f, n[4].i, n[5].i);
8350            break;
8351         case OPCODE_MAP2:
8352            _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
8353                         _mesa_lookup_enum_by_nr(n[1].ui),
8354                         n[2].f, n[3].f, n[4].f, n[5].f,
8355                         n[6].i, n[7].i, n[8].i, n[9].i);
8356            break;
8357         case OPCODE_MAPGRID1:
8358            _mesa_printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
8359            break;
8360         case OPCODE_MAPGRID2:
8361            _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
8362                         n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
8363            break;
8364         case OPCODE_EVALMESH1:
8365            _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
8366            break;
8367         case OPCODE_EVALMESH2:
8368            _mesa_printf("EvalMesh2 %d %d %d %d\n",
8369                         n[1].i, n[2].i, n[3].i, n[4].i);
8370            break;
8371
8372         case OPCODE_ATTR_1F_NV:
8373            _mesa_printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
8374            break;
8375         case OPCODE_ATTR_2F_NV:
8376            _mesa_printf("ATTR_2F_NV attr %d: %f %f\n",
8377                         n[1].i, n[2].f, n[3].f);
8378            break;
8379         case OPCODE_ATTR_3F_NV:
8380            _mesa_printf("ATTR_3F_NV attr %d: %f %f %f\n",
8381                         n[1].i, n[2].f, n[3].f, n[4].f);
8382            break;
8383         case OPCODE_ATTR_4F_NV:
8384            _mesa_printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
8385                         n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
8386            break;
8387         case OPCODE_ATTR_1F_ARB:
8388            _mesa_printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
8389            break;
8390         case OPCODE_ATTR_2F_ARB:
8391            _mesa_printf("ATTR_2F_ARB attr %d: %f %f\n",
8392                         n[1].i, n[2].f, n[3].f);
8393            break;
8394         case OPCODE_ATTR_3F_ARB:
8395            _mesa_printf("ATTR_3F_ARB attr %d: %f %f %f\n",
8396                         n[1].i, n[2].f, n[3].f, n[4].f);
8397            break;
8398         case OPCODE_ATTR_4F_ARB:
8399            _mesa_printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
8400                         n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
8401            break;
8402
8403         case OPCODE_MATERIAL:
8404            _mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
8405                         n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
8406            break;
8407         case OPCODE_BEGIN:
8408            _mesa_printf("BEGIN %x\n", n[1].i);
8409            break;
8410         case OPCODE_END:
8411            _mesa_printf("END\n");
8412            break;
8413         case OPCODE_RECTF:
8414            _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f,
8415                         n[4].f);
8416            break;
8417         case OPCODE_EVAL_C1:
8418            _mesa_printf("EVAL_C1 %f\n", n[1].f);
8419            break;
8420         case OPCODE_EVAL_C2:
8421            _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
8422            break;
8423         case OPCODE_EVAL_P1:
8424            _mesa_printf("EVAL_P1 %d\n", n[1].i);
8425            break;
8426         case OPCODE_EVAL_P2:
8427            _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
8428            break;
8429
8430            /*
8431             * meta opcodes/commands
8432             */
8433         case OPCODE_ERROR:
8434            _mesa_printf("Error: %s %s\n",
8435                         enum_string(n[1].e), (const char *) n[2].data);
8436            break;
8437         case OPCODE_CONTINUE:
8438            _mesa_printf("DISPLAY-LIST-CONTINUE\n");
8439            n = (Node *) n[1].next;
8440            break;
8441         case OPCODE_END_OF_LIST:
8442            _mesa_printf("END-LIST %u\n", list);
8443            done = GL_TRUE;
8444            break;
8445         default:
8446            if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
8447               _mesa_printf
8448                  ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
8449                   opcode, (void *) n);
8450               return;
8451            }
8452            else {
8453               _mesa_printf("command %d, %u operands\n", opcode,
8454                            InstSize[opcode]);
8455            }
8456         }
8457         /* increment n to point to next compiled command */
8458         if (opcode != OPCODE_CONTINUE) {
8459            n += InstSize[opcode];
8460         }
8461      }
8462   }
8463}
8464
8465
8466
8467/**
8468 * Clients may call this function to help debug display list problems.
8469 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
8470 * changed, or break in the future without notice.
8471 */
8472void
8473mesa_print_display_list(GLuint list)
8474{
8475   GET_CURRENT_CONTEXT(ctx);
8476   print_list(ctx, list);
8477}
8478
8479
8480/**********************************************************************/
8481/*****                      Initialization                        *****/
8482/**********************************************************************/
8483
8484void
8485_mesa_save_vtxfmt_init(GLvertexformat * vfmt)
8486{
8487   vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
8488   vfmt->Begin = save_Begin;
8489   vfmt->CallList = _mesa_save_CallList;
8490   vfmt->CallLists = _mesa_save_CallLists;
8491   vfmt->Color3f = save_Color3f;
8492   vfmt->Color3fv = save_Color3fv;
8493   vfmt->Color4f = save_Color4f;
8494   vfmt->Color4fv = save_Color4fv;
8495   vfmt->EdgeFlag = save_EdgeFlag;
8496   vfmt->End = save_End;
8497   vfmt->EvalCoord1f = save_EvalCoord1f;
8498   vfmt->EvalCoord1fv = save_EvalCoord1fv;
8499   vfmt->EvalCoord2f = save_EvalCoord2f;
8500   vfmt->EvalCoord2fv = save_EvalCoord2fv;
8501   vfmt->EvalPoint1 = save_EvalPoint1;
8502   vfmt->EvalPoint2 = save_EvalPoint2;
8503   vfmt->FogCoordfEXT = save_FogCoordfEXT;
8504   vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
8505   vfmt->Indexf = save_Indexf;
8506   vfmt->Indexfv = save_Indexfv;
8507   vfmt->Materialfv = save_Materialfv;
8508   vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
8509   vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
8510   vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
8511   vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
8512   vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
8513   vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
8514   vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
8515   vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
8516   vfmt->Normal3f = save_Normal3f;
8517   vfmt->Normal3fv = save_Normal3fv;
8518   vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
8519   vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
8520   vfmt->TexCoord1f = save_TexCoord1f;
8521   vfmt->TexCoord1fv = save_TexCoord1fv;
8522   vfmt->TexCoord2f = save_TexCoord2f;
8523   vfmt->TexCoord2fv = save_TexCoord2fv;
8524   vfmt->TexCoord3f = save_TexCoord3f;
8525   vfmt->TexCoord3fv = save_TexCoord3fv;
8526   vfmt->TexCoord4f = save_TexCoord4f;
8527   vfmt->TexCoord4fv = save_TexCoord4fv;
8528   vfmt->Vertex2f = save_Vertex2f;
8529   vfmt->Vertex2fv = save_Vertex2fv;
8530   vfmt->Vertex3f = save_Vertex3f;
8531   vfmt->Vertex3fv = save_Vertex3fv;
8532   vfmt->Vertex4f = save_Vertex4f;
8533   vfmt->Vertex4fv = save_Vertex4fv;
8534   vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
8535   vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
8536   vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
8537   vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
8538   vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
8539   vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
8540   vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
8541   vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
8542   vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
8543   vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
8544   vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
8545   vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
8546   vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
8547   vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
8548   vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
8549   vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
8550
8551   vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
8552   vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
8553   vfmt->Rectf = save_Rectf;
8554
8555   /* The driver is required to implement these as
8556    * 1) They can probably do a better job.
8557    * 2) A lot of new mechanisms would have to be added to this module
8558    *     to support it.  That code would probably never get used,
8559    *     because of (1).
8560    */
8561#if 0
8562   vfmt->DrawArrays = 0;
8563   vfmt->DrawElements = 0;
8564   vfmt->DrawRangeElements = 0;
8565#endif
8566}
8567
8568
8569/**
8570 * Initialize display list state for given context.
8571 */
8572void
8573_mesa_init_display_list(GLcontext *ctx)
8574{
8575   static GLboolean tableInitialized = GL_FALSE;
8576
8577   /* zero-out the instruction size table, just once */
8578   if (!tableInitialized) {
8579      _mesa_bzero(InstSize, sizeof(InstSize));
8580      tableInitialized = GL_TRUE;
8581   }
8582
8583   /* Display list */
8584   ctx->ListState.CallDepth = 0;
8585   ctx->ExecuteFlag = GL_TRUE;
8586   ctx->CompileFlag = GL_FALSE;
8587   ctx->ListState.CurrentListPtr = NULL;
8588   ctx->ListState.CurrentBlock = NULL;
8589   ctx->ListState.CurrentListNum = 0;
8590   ctx->ListState.CurrentPos = 0;
8591
8592   /* Display List group */
8593   ctx->List.ListBase = 0;
8594
8595   _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
8596}
8597