OSDN Git Service

mesa: implement display list support for indexed query functions
[android-x86/external-mesa.git] / src / mesa / main / dlist.c
1 /*
2  * Mesa 3-D graphics library
3  * Version:  7.7
4  *
5  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
6  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26
27 /**
28  * \file dlist.c
29  * Display lists management functions.
30  */
31
32 #include "glheader.h"
33 #include "imports.h"
34 #include "api_arrayelt.h"
35 #include "api_exec.h"
36 #include "api_loopback.h"
37 #include "api_validate.h"
38 #if FEATURE_ATI_fragment_shader
39 #include "atifragshader.h"
40 #endif
41 #include "config.h"
42 #include "mfeatures.h"
43 #include "bufferobj.h"
44 #include "arrayobj.h"
45 #include "context.h"
46 #include "dlist.h"
47 #include "enums.h"
48 #include "eval.h"
49 #if FEATURE_EXT_framebuffer_object
50 #include "fbobject.h"
51 #endif
52 #include "framebuffer.h"
53 #include "glapi/glapi.h"
54 #include "hash.h"
55 #include "image.h"
56 #include "light.h"
57 #include "macros.h"
58 #include "pack.h"
59 #include "pbo.h"
60 #include "queryobj.h"
61 #include "samplerobj.h"
62 #include "shaderapi.h"
63 #include "syncobj.h"
64 #include "teximage.h"
65 #include "texstorage.h"
66 #include "mtypes.h"
67 #include "varray.h"
68 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
69 #include "arbprogram.h"
70 #endif
71 #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
72 #include "nvprogram.h"
73 #endif
74 #if FEATURE_EXT_transform_feedback
75 #include "transformfeedback.h"
76 #endif
77
78 #include "math/m_matrix.h"
79
80 #include "main/dispatch.h"
81
82
83
84 /**
85  * Other parts of Mesa (such as the VBO module) can plug into the display
86  * list system.  This structure describes new display list instructions.
87  */
88 struct gl_list_instruction
89 {
90    GLuint Size;
91    void (*Execute)( struct gl_context *ctx, void *data );
92    void (*Destroy)( struct gl_context *ctx, void *data );
93    void (*Print)( struct gl_context *ctx, void *data );
94 };
95
96
97 #define MAX_DLIST_EXT_OPCODES 16
98
99 /**
100  * Used by device drivers to hook new commands into display lists.
101  */
102 struct gl_list_extensions
103 {
104    struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
105    GLuint NumOpcodes;
106 };
107
108
109
110 /**
111  * Flush vertices.
112  *
113  * \param ctx GL context.
114  *
115  * Checks if dd_function_table::SaveNeedFlush is marked to flush
116  * stored (save) vertices, and calls
117  * dd_function_table::SaveFlushVertices if so.
118  */
119 #define SAVE_FLUSH_VERTICES(ctx)                \
120 do {                                            \
121    if (ctx->Driver.SaveNeedFlush)               \
122       ctx->Driver.SaveFlushVertices(ctx);       \
123 } while (0)
124
125
126 /**
127  * Macro to assert that the API call was made outside the
128  * glBegin()/glEnd() pair, with return value.
129  * 
130  * \param ctx GL context.
131  * \param retval value to return value in case the assertion fails.
132  */
133 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)          \
134 do {                                                                    \
135    if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||                \
136        ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) {  \
137       _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" );  \
138       return retval;                                                    \
139    }                                                                    \
140 } while (0)
141
142 /**
143  * Macro to assert that the API call was made outside the
144  * glBegin()/glEnd() pair.
145  * 
146  * \param ctx GL context.
147  */
148 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)                              \
149 do {                                                                    \
150    if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||                \
151        ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) {  \
152       _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" );  \
153       return;                                                           \
154    }                                                                    \
155 } while (0)
156
157 /**
158  * Macro to assert that the API call was made outside the
159  * glBegin()/glEnd() pair and flush the vertices.
160  * 
161  * \param ctx GL context.
162  */
163 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                    \
164 do {                                                                    \
165    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                                  \
166    SAVE_FLUSH_VERTICES(ctx);                                            \
167 } while (0)
168
169 /**
170  * Macro to assert that the API call was made outside the
171  * glBegin()/glEnd() pair and flush the vertices, with return value.
172  * 
173  * \param ctx GL context.
174  * \param retval value to return value in case the assertion fails.
175  */
176 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
177 do {                                                                    \
178    ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);              \
179    SAVE_FLUSH_VERTICES(ctx);                                            \
180 } while (0)
181
182
183
184 /**
185  * Display list opcodes.
186  *
187  * The fact that these identifiers are assigned consecutive
188  * integer values starting at 0 is very important, see InstSize array usage)
189  */
190 typedef enum
191 {
192    OPCODE_INVALID = -1,         /* Force signed enum */
193    OPCODE_ACCUM,
194    OPCODE_ALPHA_FUNC,
195    OPCODE_BIND_TEXTURE,
196    OPCODE_BITMAP,
197    OPCODE_BLEND_COLOR,
198    OPCODE_BLEND_EQUATION,
199    OPCODE_BLEND_EQUATION_SEPARATE,
200    OPCODE_BLEND_FUNC_SEPARATE,
201
202    OPCODE_BLEND_EQUATION_I,
203    OPCODE_BLEND_EQUATION_SEPARATE_I,
204    OPCODE_BLEND_FUNC_I,
205    OPCODE_BLEND_FUNC_SEPARATE_I,
206
207    OPCODE_CALL_LIST,
208    OPCODE_CALL_LIST_OFFSET,
209    OPCODE_CLEAR,
210    OPCODE_CLEAR_ACCUM,
211    OPCODE_CLEAR_COLOR,
212    OPCODE_CLEAR_DEPTH,
213    OPCODE_CLEAR_INDEX,
214    OPCODE_CLEAR_STENCIL,
215    OPCODE_CLEAR_BUFFER_IV,
216    OPCODE_CLEAR_BUFFER_UIV,
217    OPCODE_CLEAR_BUFFER_FV,
218    OPCODE_CLEAR_BUFFER_FI,
219    OPCODE_CLIP_PLANE,
220    OPCODE_COLOR_MASK,
221    OPCODE_COLOR_MASK_INDEXED,
222    OPCODE_COLOR_MATERIAL,
223    OPCODE_COLOR_TABLE,
224    OPCODE_COLOR_TABLE_PARAMETER_FV,
225    OPCODE_COLOR_TABLE_PARAMETER_IV,
226    OPCODE_COLOR_SUB_TABLE,
227    OPCODE_CONVOLUTION_FILTER_1D,
228    OPCODE_CONVOLUTION_FILTER_2D,
229    OPCODE_CONVOLUTION_PARAMETER_I,
230    OPCODE_CONVOLUTION_PARAMETER_IV,
231    OPCODE_CONVOLUTION_PARAMETER_F,
232    OPCODE_CONVOLUTION_PARAMETER_FV,
233    OPCODE_COPY_COLOR_SUB_TABLE,
234    OPCODE_COPY_COLOR_TABLE,
235    OPCODE_COPY_PIXELS,
236    OPCODE_COPY_TEX_IMAGE1D,
237    OPCODE_COPY_TEX_IMAGE2D,
238    OPCODE_COPY_TEX_SUB_IMAGE1D,
239    OPCODE_COPY_TEX_SUB_IMAGE2D,
240    OPCODE_COPY_TEX_SUB_IMAGE3D,
241    OPCODE_CULL_FACE,
242    OPCODE_DEPTH_FUNC,
243    OPCODE_DEPTH_MASK,
244    OPCODE_DEPTH_RANGE,
245    OPCODE_DISABLE,
246    OPCODE_DISABLE_INDEXED,
247    OPCODE_DRAW_BUFFER,
248    OPCODE_DRAW_PIXELS,
249    OPCODE_ENABLE,
250    OPCODE_ENABLE_INDEXED,
251    OPCODE_EVALMESH1,
252    OPCODE_EVALMESH2,
253    OPCODE_FOG,
254    OPCODE_FRONT_FACE,
255    OPCODE_FRUSTUM,
256    OPCODE_HINT,
257    OPCODE_HISTOGRAM,
258    OPCODE_INDEX_MASK,
259    OPCODE_INIT_NAMES,
260    OPCODE_LIGHT,
261    OPCODE_LIGHT_MODEL,
262    OPCODE_LINE_STIPPLE,
263    OPCODE_LINE_WIDTH,
264    OPCODE_LIST_BASE,
265    OPCODE_LOAD_IDENTITY,
266    OPCODE_LOAD_MATRIX,
267    OPCODE_LOAD_NAME,
268    OPCODE_LOGIC_OP,
269    OPCODE_MAP1,
270    OPCODE_MAP2,
271    OPCODE_MAPGRID1,
272    OPCODE_MAPGRID2,
273    OPCODE_MATRIX_MODE,
274    OPCODE_MIN_MAX,
275    OPCODE_MULT_MATRIX,
276    OPCODE_ORTHO,
277    OPCODE_PASSTHROUGH,
278    OPCODE_PIXEL_MAP,
279    OPCODE_PIXEL_TRANSFER,
280    OPCODE_PIXEL_ZOOM,
281    OPCODE_POINT_SIZE,
282    OPCODE_POINT_PARAMETERS,
283    OPCODE_POLYGON_MODE,
284    OPCODE_POLYGON_STIPPLE,
285    OPCODE_POLYGON_OFFSET,
286    OPCODE_POP_ATTRIB,
287    OPCODE_POP_MATRIX,
288    OPCODE_POP_NAME,
289    OPCODE_PRIORITIZE_TEXTURE,
290    OPCODE_PUSH_ATTRIB,
291    OPCODE_PUSH_MATRIX,
292    OPCODE_PUSH_NAME,
293    OPCODE_RASTER_POS,
294    OPCODE_READ_BUFFER,
295    OPCODE_RESET_HISTOGRAM,
296    OPCODE_RESET_MIN_MAX,
297    OPCODE_ROTATE,
298    OPCODE_SCALE,
299    OPCODE_SCISSOR,
300    OPCODE_SELECT_TEXTURE_SGIS,
301    OPCODE_SELECT_TEXTURE_COORD_SET,
302    OPCODE_SHADE_MODEL,
303    OPCODE_STENCIL_FUNC,
304    OPCODE_STENCIL_MASK,
305    OPCODE_STENCIL_OP,
306    OPCODE_TEXENV,
307    OPCODE_TEXGEN,
308    OPCODE_TEXPARAMETER,
309    OPCODE_TEX_IMAGE1D,
310    OPCODE_TEX_IMAGE2D,
311    OPCODE_TEX_IMAGE3D,
312    OPCODE_TEX_SUB_IMAGE1D,
313    OPCODE_TEX_SUB_IMAGE2D,
314    OPCODE_TEX_SUB_IMAGE3D,
315    OPCODE_TRANSLATE,
316    OPCODE_VIEWPORT,
317    OPCODE_WINDOW_POS,
318    /* GL_ARB_multitexture */
319    OPCODE_ACTIVE_TEXTURE,
320    /* GL_ARB_texture_compression */
321    OPCODE_COMPRESSED_TEX_IMAGE_1D,
322    OPCODE_COMPRESSED_TEX_IMAGE_2D,
323    OPCODE_COMPRESSED_TEX_IMAGE_3D,
324    OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
325    OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
326    OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
327    /* GL_ARB_multisample */
328    OPCODE_SAMPLE_COVERAGE,
329    /* GL_ARB_window_pos */
330    OPCODE_WINDOW_POS_ARB,
331    /* GL_NV_vertex_program */
332    OPCODE_BIND_PROGRAM_NV,
333    OPCODE_EXECUTE_PROGRAM_NV,
334    OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
335    OPCODE_LOAD_PROGRAM_NV,
336    OPCODE_TRACK_MATRIX_NV,
337    /* GL_NV_fragment_program */
338    OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
339    OPCODE_PROGRAM_NAMED_PARAMETER_NV,
340    /* GL_EXT_stencil_two_side */
341    OPCODE_ACTIVE_STENCIL_FACE_EXT,
342    /* GL_EXT_depth_bounds_test */
343    OPCODE_DEPTH_BOUNDS_EXT,
344    /* GL_ARB_vertex/fragment_program */
345    OPCODE_PROGRAM_STRING_ARB,
346    OPCODE_PROGRAM_ENV_PARAMETER_ARB,
347    /* GL_ARB_occlusion_query */
348    OPCODE_BEGIN_QUERY_ARB,
349    OPCODE_END_QUERY_ARB,
350    /* GL_ARB_draw_buffers */
351    OPCODE_DRAW_BUFFERS_ARB,
352    /* GL_ATI_fragment_shader */
353    OPCODE_TEX_BUMP_PARAMETER_ATI,
354    /* GL_ATI_fragment_shader */
355    OPCODE_BIND_FRAGMENT_SHADER_ATI,
356    OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
357    /* OpenGL 2.0 */
358    OPCODE_STENCIL_FUNC_SEPARATE,
359    OPCODE_STENCIL_OP_SEPARATE,
360    OPCODE_STENCIL_MASK_SEPARATE,
361
362    /* GL_ARB_shader_objects */
363    OPCODE_USE_PROGRAM,
364    OPCODE_UNIFORM_1F,
365    OPCODE_UNIFORM_2F,
366    OPCODE_UNIFORM_3F,
367    OPCODE_UNIFORM_4F,
368    OPCODE_UNIFORM_1FV,
369    OPCODE_UNIFORM_2FV,
370    OPCODE_UNIFORM_3FV,
371    OPCODE_UNIFORM_4FV,
372    OPCODE_UNIFORM_1I,
373    OPCODE_UNIFORM_2I,
374    OPCODE_UNIFORM_3I,
375    OPCODE_UNIFORM_4I,
376    OPCODE_UNIFORM_1IV,
377    OPCODE_UNIFORM_2IV,
378    OPCODE_UNIFORM_3IV,
379    OPCODE_UNIFORM_4IV,
380    OPCODE_UNIFORM_MATRIX22,
381    OPCODE_UNIFORM_MATRIX33,
382    OPCODE_UNIFORM_MATRIX44,
383    OPCODE_UNIFORM_MATRIX23,
384    OPCODE_UNIFORM_MATRIX32,
385    OPCODE_UNIFORM_MATRIX24,
386    OPCODE_UNIFORM_MATRIX42,
387    OPCODE_UNIFORM_MATRIX34,
388    OPCODE_UNIFORM_MATRIX43,
389
390    /* OpenGL 3.0 */
391    OPCODE_UNIFORM_1UI,
392    OPCODE_UNIFORM_2UI,
393    OPCODE_UNIFORM_3UI,
394    OPCODE_UNIFORM_4UI,
395    OPCODE_UNIFORM_1UIV,
396    OPCODE_UNIFORM_2UIV,
397    OPCODE_UNIFORM_3UIV,
398    OPCODE_UNIFORM_4UIV,
399
400    /* GL_ARB_color_buffer_float */
401    OPCODE_CLAMP_COLOR,
402
403    /* GL_EXT_framebuffer_blit */
404    OPCODE_BLIT_FRAMEBUFFER,
405
406    /* Vertex attributes -- fallback for when optimized display
407     * list build isn't active.
408     */
409    OPCODE_ATTR_1F_NV,
410    OPCODE_ATTR_2F_NV,
411    OPCODE_ATTR_3F_NV,
412    OPCODE_ATTR_4F_NV,
413    OPCODE_ATTR_1F_ARB,
414    OPCODE_ATTR_2F_ARB,
415    OPCODE_ATTR_3F_ARB,
416    OPCODE_ATTR_4F_ARB,
417    OPCODE_MATERIAL,
418    OPCODE_BEGIN,
419    OPCODE_END,
420    OPCODE_RECTF,
421    OPCODE_EVAL_C1,
422    OPCODE_EVAL_C2,
423    OPCODE_EVAL_P1,
424    OPCODE_EVAL_P2,
425
426    /* GL_EXT_provoking_vertex */
427    OPCODE_PROVOKING_VERTEX,
428
429    /* GL_EXT_transform_feedback */
430    OPCODE_BEGIN_TRANSFORM_FEEDBACK,
431    OPCODE_END_TRANSFORM_FEEDBACK,
432    OPCODE_BIND_TRANSFORM_FEEDBACK,
433    OPCODE_PAUSE_TRANSFORM_FEEDBACK,
434    OPCODE_RESUME_TRANSFORM_FEEDBACK,
435    OPCODE_DRAW_TRANSFORM_FEEDBACK,
436
437    /* GL_EXT_texture_integer */
438    OPCODE_CLEARCOLOR_I,
439    OPCODE_CLEARCOLOR_UI,
440    OPCODE_TEXPARAMETER_I,
441    OPCODE_TEXPARAMETER_UI,
442
443    /* GL_EXT_separate_shader_objects */
444    OPCODE_ACTIVE_PROGRAM_EXT,
445    OPCODE_USE_SHADER_PROGRAM_EXT,
446
447    /* GL_ARB_instanced_arrays */
448    OPCODE_VERTEX_ATTRIB_DIVISOR,
449
450    /* GL_NV_texture_barrier */
451    OPCODE_TEXTURE_BARRIER_NV,
452
453    /* GL_ARB_sampler_object */
454    OPCODE_BIND_SAMPLER,
455    OPCODE_SAMPLER_PARAMETERIV,
456    OPCODE_SAMPLER_PARAMETERFV,
457    OPCODE_SAMPLER_PARAMETERIIV,
458    OPCODE_SAMPLER_PARAMETERUIV,
459
460    /* GL_ARB_geometry_shader4 */
461    OPCODE_PROGRAM_PARAMETERI,
462    OPCODE_FRAMEBUFFER_TEXTURE,
463    OPCODE_FRAMEBUFFER_TEXTURE_FACE,
464
465    /* GL_ARB_sync */
466    OPCODE_WAIT_SYNC,
467
468    /* GL_NV_conditional_render */
469    OPCODE_BEGIN_CONDITIONAL_RENDER,
470    OPCODE_END_CONDITIONAL_RENDER,
471
472    /* ARB_timer_query */
473    OPCODE_QUERY_COUNTER,
474
475    /* ARB_transform_feedback3 */
476    OPCODE_BEGIN_QUERY_INDEXED,
477    OPCODE_END_QUERY_INDEXED,
478
479    /* The following three are meta instructions */
480    OPCODE_ERROR,                /* raise compiled-in error */
481    OPCODE_CONTINUE,
482    OPCODE_END_OF_LIST,
483    OPCODE_EXT_0
484 } OpCode;
485
486
487
488 /**
489  * Display list node.
490  *
491  * Display list instructions are stored as sequences of "nodes".  Nodes
492  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
493  * are linked together with a pointer.
494  *
495  * Each instruction in the display list is stored as a sequence of
496  * contiguous nodes in memory.
497  * Each node is the union of a variety of data types.
498  */
499 union gl_dlist_node
500 {
501    OpCode opcode;
502    GLboolean b;
503    GLbitfield bf;
504    GLubyte ub;
505    GLshort s;
506    GLushort us;
507    GLint i;
508    GLuint ui;
509    GLenum e;
510    GLfloat f;
511    GLvoid *data;
512    void *next;                  /* If prev node's opcode==OPCODE_CONTINUE */
513 };
514
515
516 typedef union gl_dlist_node Node;
517
518
519 /**
520  * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit
521  * environment.  In 64-bit env, sizeof(Node)==8 anyway.
522  */
523 union uint64_pair
524 {
525    GLuint64 uint64;
526    GLuint uint32[2];
527 };
528
529
530 /**
531  * How many nodes to allocate at a time.
532  *
533  * \note Reduced now that we hold vertices etc. elsewhere.
534  */
535 #define BLOCK_SIZE 256
536
537
538
539 /**
540  * Number of nodes of storage needed for each instruction.
541  * Sizes for dynamically allocated opcodes are stored in the context struct.
542  */
543 static GLuint InstSize[OPCODE_END_OF_LIST + 1];
544
545
546 #if FEATURE_dlist
547
548
549 void mesa_print_display_list(GLuint list);
550
551
552 /**********************************************************************/
553 /*****                           Private                          *****/
554 /**********************************************************************/
555
556
557 /**
558  * Make an empty display list.  This is used by glGenLists() to
559  * reserve display list IDs.
560  */
561 static struct gl_display_list *
562 make_list(GLuint name, GLuint count)
563 {
564    struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
565    dlist->Name = name;
566    dlist->Head = (Node *) malloc(sizeof(Node) * count);
567    dlist->Head[0].opcode = OPCODE_END_OF_LIST;
568    return dlist;
569 }
570
571
572 /**
573  * Lookup function to just encapsulate casting.
574  */
575 static inline struct gl_display_list *
576 lookup_list(struct gl_context *ctx, GLuint list)
577 {
578    return (struct gl_display_list *)
579       _mesa_HashLookup(ctx->Shared->DisplayList, list);
580 }
581
582
583 /** Is the given opcode an extension code? */
584 static inline GLboolean
585 is_ext_opcode(OpCode opcode)
586 {
587    return (opcode >= OPCODE_EXT_0);
588 }
589
590
591 /** Destroy an extended opcode instruction */
592 static GLint
593 ext_opcode_destroy(struct gl_context *ctx, Node *node)
594 {
595    const GLint i = node[0].opcode - OPCODE_EXT_0;
596    GLint step;
597    ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]);
598    step = ctx->ListExt->Opcode[i].Size;
599    return step;
600 }
601
602
603 /** Execute an extended opcode instruction */
604 static GLint
605 ext_opcode_execute(struct gl_context *ctx, Node *node)
606 {
607    const GLint i = node[0].opcode - OPCODE_EXT_0;
608    GLint step;
609    ctx->ListExt->Opcode[i].Execute(ctx, &node[1]);
610    step = ctx->ListExt->Opcode[i].Size;
611    return step;
612 }
613
614
615 /** Print an extended opcode instruction */
616 static GLint
617 ext_opcode_print(struct gl_context *ctx, Node *node)
618 {
619    const GLint i = node[0].opcode - OPCODE_EXT_0;
620    GLint step;
621    ctx->ListExt->Opcode[i].Print(ctx, &node[1]);
622    step = ctx->ListExt->Opcode[i].Size;
623    return step;
624 }
625
626
627 /**
628  * Delete the named display list, but don't remove from hash table.
629  * \param dlist - display list pointer
630  */
631 void
632 _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
633 {
634    Node *n, *block;
635    GLboolean done;
636
637    n = block = dlist->Head;
638
639    done = block ? GL_FALSE : GL_TRUE;
640    while (!done) {
641       const OpCode opcode = n[0].opcode;
642
643       /* check for extension opcodes first */
644       if (is_ext_opcode(opcode)) {
645          n += ext_opcode_destroy(ctx, n);
646       }
647       else {
648          switch (opcode) {
649             /* for some commands, we need to free malloc'd memory */
650          case OPCODE_MAP1:
651             free(n[6].data);
652             n += InstSize[n[0].opcode];
653             break;
654          case OPCODE_MAP2:
655             free(n[10].data);
656             n += InstSize[n[0].opcode];
657             break;
658          case OPCODE_DRAW_PIXELS:
659             free(n[5].data);
660             n += InstSize[n[0].opcode];
661             break;
662          case OPCODE_BITMAP:
663             free(n[7].data);
664             n += InstSize[n[0].opcode];
665             break;
666          case OPCODE_COLOR_TABLE:
667             free(n[6].data);
668             n += InstSize[n[0].opcode];
669             break;
670          case OPCODE_COLOR_SUB_TABLE:
671             free(n[6].data);
672             n += InstSize[n[0].opcode];
673             break;
674          case OPCODE_CONVOLUTION_FILTER_1D:
675             free(n[6].data);
676             n += InstSize[n[0].opcode];
677             break;
678          case OPCODE_CONVOLUTION_FILTER_2D:
679             free(n[7].data);
680             n += InstSize[n[0].opcode];
681             break;
682          case OPCODE_POLYGON_STIPPLE:
683             free(n[1].data);
684             n += InstSize[n[0].opcode];
685             break;
686          case OPCODE_TEX_IMAGE1D:
687             free(n[8].data);
688             n += InstSize[n[0].opcode];
689             break;
690          case OPCODE_TEX_IMAGE2D:
691             free(n[9].data);
692             n += InstSize[n[0].opcode];
693             break;
694          case OPCODE_TEX_IMAGE3D:
695             free(n[10].data);
696             n += InstSize[n[0].opcode];
697             break;
698          case OPCODE_TEX_SUB_IMAGE1D:
699             free(n[7].data);
700             n += InstSize[n[0].opcode];
701             break;
702          case OPCODE_TEX_SUB_IMAGE2D:
703             free(n[9].data);
704             n += InstSize[n[0].opcode];
705             break;
706          case OPCODE_TEX_SUB_IMAGE3D:
707             free(n[11].data);
708             n += InstSize[n[0].opcode];
709             break;
710          case OPCODE_COMPRESSED_TEX_IMAGE_1D:
711             free(n[7].data);
712             n += InstSize[n[0].opcode];
713             break;
714          case OPCODE_COMPRESSED_TEX_IMAGE_2D:
715             free(n[8].data);
716             n += InstSize[n[0].opcode];
717             break;
718          case OPCODE_COMPRESSED_TEX_IMAGE_3D:
719             free(n[9].data);
720             n += InstSize[n[0].opcode];
721             break;
722          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
723             free(n[7].data);
724             n += InstSize[n[0].opcode];
725             break;
726          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
727             free(n[9].data);
728             n += InstSize[n[0].opcode];
729             break;
730          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
731             free(n[11].data);
732             n += InstSize[n[0].opcode];
733             break;
734 #if FEATURE_NV_vertex_program
735          case OPCODE_LOAD_PROGRAM_NV:
736             free(n[4].data);      /* program string */
737             n += InstSize[n[0].opcode];
738             break;
739          case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
740             free(n[2].data);      /* array of program ids */
741             n += InstSize[n[0].opcode];
742             break;
743 #endif
744 #if FEATURE_NV_fragment_program
745          case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
746             free(n[3].data);      /* parameter name */
747             n += InstSize[n[0].opcode];
748             break;
749 #endif
750 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
751          case OPCODE_PROGRAM_STRING_ARB:
752             free(n[4].data);      /* program string */
753             n += InstSize[n[0].opcode];
754             break;
755 #endif
756          case OPCODE_UNIFORM_1FV:
757          case OPCODE_UNIFORM_2FV:
758          case OPCODE_UNIFORM_3FV:
759          case OPCODE_UNIFORM_4FV:
760          case OPCODE_UNIFORM_1IV:
761          case OPCODE_UNIFORM_2IV:
762          case OPCODE_UNIFORM_3IV:
763          case OPCODE_UNIFORM_4IV:
764          case OPCODE_UNIFORM_1UIV:
765          case OPCODE_UNIFORM_2UIV:
766          case OPCODE_UNIFORM_3UIV:
767          case OPCODE_UNIFORM_4UIV:
768             free(n[3].data);
769             n += InstSize[n[0].opcode];
770             break;
771          case OPCODE_UNIFORM_MATRIX22:
772          case OPCODE_UNIFORM_MATRIX33:
773          case OPCODE_UNIFORM_MATRIX44:
774          case OPCODE_UNIFORM_MATRIX24:
775          case OPCODE_UNIFORM_MATRIX42:
776          case OPCODE_UNIFORM_MATRIX23:
777          case OPCODE_UNIFORM_MATRIX32:
778          case OPCODE_UNIFORM_MATRIX34:
779          case OPCODE_UNIFORM_MATRIX43:
780             free(n[4].data);
781             n += InstSize[n[0].opcode];
782             break;
783
784          case OPCODE_CONTINUE:
785             n = (Node *) n[1].next;
786             free(block);
787             block = n;
788             break;
789          case OPCODE_END_OF_LIST:
790             free(block);
791             done = GL_TRUE;
792             break;
793          default:
794             /* Most frequent case */
795             n += InstSize[n[0].opcode];
796             break;
797          }
798       }
799    }
800
801    free(dlist);
802 }
803
804
805 /**
806  * Destroy a display list and remove from hash table.
807  * \param list - display list number
808  */
809 static void
810 destroy_list(struct gl_context *ctx, GLuint list)
811 {
812    struct gl_display_list *dlist;
813
814    if (list == 0)
815       return;
816
817    dlist = lookup_list(ctx, list);
818    if (!dlist)
819       return;
820
821    _mesa_delete_list(ctx, dlist);
822    _mesa_HashRemove(ctx->Shared->DisplayList, list);
823 }
824
825
826 /*
827  * Translate the nth element of list from <type> to GLint.
828  */
829 static GLint
830 translate_id(GLsizei n, GLenum type, const GLvoid * list)
831 {
832    GLbyte *bptr;
833    GLubyte *ubptr;
834    GLshort *sptr;
835    GLushort *usptr;
836    GLint *iptr;
837    GLuint *uiptr;
838    GLfloat *fptr;
839
840    switch (type) {
841    case GL_BYTE:
842       bptr = (GLbyte *) list;
843       return (GLint) bptr[n];
844    case GL_UNSIGNED_BYTE:
845       ubptr = (GLubyte *) list;
846       return (GLint) ubptr[n];
847    case GL_SHORT:
848       sptr = (GLshort *) list;
849       return (GLint) sptr[n];
850    case GL_UNSIGNED_SHORT:
851       usptr = (GLushort *) list;
852       return (GLint) usptr[n];
853    case GL_INT:
854       iptr = (GLint *) list;
855       return iptr[n];
856    case GL_UNSIGNED_INT:
857       uiptr = (GLuint *) list;
858       return (GLint) uiptr[n];
859    case GL_FLOAT:
860       fptr = (GLfloat *) list;
861       return (GLint) FLOORF(fptr[n]);
862    case GL_2_BYTES:
863       ubptr = ((GLubyte *) list) + 2 * n;
864       return (GLint) ubptr[0] * 256
865            + (GLint) ubptr[1];
866    case GL_3_BYTES:
867       ubptr = ((GLubyte *) list) + 3 * n;
868       return (GLint) ubptr[0] * 65536
869            + (GLint) ubptr[1] * 256
870            + (GLint) ubptr[2];
871    case GL_4_BYTES:
872       ubptr = ((GLubyte *) list) + 4 * n;
873       return (GLint) ubptr[0] * 16777216
874            + (GLint) ubptr[1] * 65536
875            + (GLint) ubptr[2] * 256
876            + (GLint) ubptr[3];
877    default:
878       return 0;
879    }
880 }
881
882
883
884
885 /**********************************************************************/
886 /*****                        Public                              *****/
887 /**********************************************************************/
888
889 /**
890  * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects.
891  * If width < 0 or height < 0 or format or type are invalid we'll just
892  * return NULL.  We will not generate an error since OpenGL command
893  * arguments aren't error-checked until the command is actually executed
894  * (not when they're compiled).
895  * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded.
896  */
897 static GLvoid *
898 unpack_image(struct gl_context *ctx, GLuint dimensions,
899              GLsizei width, GLsizei height, GLsizei depth,
900              GLenum format, GLenum type, const GLvoid * pixels,
901              const struct gl_pixelstore_attrib *unpack)
902 {
903    if (width <= 0 || height <= 0) {
904       return NULL;
905    }
906
907    if (_mesa_bytes_per_pixel(format, type) < 0) {
908       /* bad format and/or type */
909       return NULL;
910    }
911
912    if (!_mesa_is_bufferobj(unpack->BufferObj)) {
913       /* no PBO */
914       GLvoid *image;
915
916       if (type == GL_BITMAP)
917          image = _mesa_unpack_bitmap(width, height, pixels, unpack);
918       else
919          image = _mesa_unpack_image(dimensions, width, height, depth,
920                                     format, type, pixels, unpack);
921       if (pixels && !image) {
922          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
923       }
924       return image;
925    }
926    else if (_mesa_validate_pbo_access(dimensions, unpack, width, height,
927                                       depth, format, type, INT_MAX, pixels)) {
928       const GLubyte *map, *src;
929       GLvoid *image;
930
931       map = (GLubyte *)
932          ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
933                                     GL_MAP_READ_BIT, unpack->BufferObj);
934       if (!map) {
935          /* unable to map src buffer! */
936          _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
937          return NULL;
938       }
939
940       src = ADD_POINTERS(map, pixels);
941       if (type == GL_BITMAP)
942          image = _mesa_unpack_bitmap(width, height, src, unpack);
943       else
944          image = _mesa_unpack_image(dimensions, width, height, depth,
945                                     format, type, src, unpack);
946
947       ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
948
949       if (!image) {
950          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
951       }
952       return image;
953    }
954
955    /* bad access! */
956    _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access");
957    return NULL;
958 }
959
960 /**
961  * Allocate space for a display list instruction (opcode + payload space).
962  * \param opcode  the instruction opcode (OPCODE_* value)
963  * \param bytes   instruction payload size (not counting opcode)
964  * \return pointer to allocated memory (the opcode space)
965  */
966 static Node *
967 dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes)
968 {
969    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
970    Node *n;
971
972    if (opcode < (GLuint) OPCODE_EXT_0) {
973       if (InstSize[opcode] == 0) {
974          /* save instruction size now */
975          InstSize[opcode] = numNodes;
976       }
977       else {
978          /* make sure instruction size agrees */
979          ASSERT(numNodes == InstSize[opcode]);
980       }
981    }
982
983    if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) {
984       /* This block is full.  Allocate a new block and chain to it */
985       Node *newblock;
986       n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
987       n[0].opcode = OPCODE_CONTINUE;
988       newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE);
989       if (!newblock) {
990          _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
991          return NULL;
992       }
993       n[1].next = (Node *) newblock;
994       ctx->ListState.CurrentBlock = newblock;
995       ctx->ListState.CurrentPos = 0;
996    }
997
998    n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
999    ctx->ListState.CurrentPos += numNodes;
1000
1001    n[0].opcode = opcode;
1002
1003    return n;
1004 }
1005
1006
1007
1008 /**
1009  * Allocate space for a display list instruction.  Used by callers outside
1010  * this file for things like VBO vertex data.
1011  *
1012  * \param opcode  the instruction opcode (OPCODE_* value)
1013  * \param bytes   instruction size in bytes, not counting opcode.
1014  * \return pointer to the usable data area (not including the internal
1015  *         opcode).
1016  */
1017 void *
1018 _mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes)
1019 {
1020    Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes);
1021    if (n)
1022       return n + 1;  /* return pointer to payload area, after opcode */
1023    else
1024       return NULL;
1025 }
1026
1027
1028 /**
1029  * This function allows modules and drivers to get their own opcodes
1030  * for extending display list functionality.
1031  * \param ctx  the rendering context
1032  * \param size  number of bytes for storing the new display list command
1033  * \param execute  function to execute the new display list command
1034  * \param destroy  function to destroy the new display list command
1035  * \param print  function to print the new display list command
1036  * \return  the new opcode number or -1 if error
1037  */
1038 GLint
1039 _mesa_dlist_alloc_opcode(struct gl_context *ctx,
1040                          GLuint size,
1041                          void (*execute) (struct gl_context *, void *),
1042                          void (*destroy) (struct gl_context *, void *),
1043                          void (*print) (struct gl_context *, void *))
1044 {
1045    if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
1046       const GLuint i = ctx->ListExt->NumOpcodes++;
1047       ctx->ListExt->Opcode[i].Size =
1048          1 + (size + sizeof(Node) - 1) / sizeof(Node);
1049       ctx->ListExt->Opcode[i].Execute = execute;
1050       ctx->ListExt->Opcode[i].Destroy = destroy;
1051       ctx->ListExt->Opcode[i].Print = print;
1052       return i + OPCODE_EXT_0;
1053    }
1054    return -1;
1055 }
1056
1057
1058 /**
1059  * Allocate space for a display list instruction.  The space is basically
1060  * an array of Nodes where node[0] holds the opcode, node[1] is the first
1061  * function parameter, node[2] is the second parameter, etc.
1062  *
1063  * \param opcode  one of OPCODE_x
1064  * \param nparams  number of function parameters
1065  * \return  pointer to start of instruction space
1066  */
1067 static inline Node *
1068 alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams)
1069 {
1070    return dlist_alloc(ctx, opcode, nparams * sizeof(Node));
1071 }
1072
1073
1074
1075 /*
1076  * Display List compilation functions
1077  */
1078 static void GLAPIENTRY
1079 save_Accum(GLenum op, GLfloat value)
1080 {
1081    GET_CURRENT_CONTEXT(ctx);
1082    Node *n;
1083    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1084    n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
1085    if (n) {
1086       n[1].e = op;
1087       n[2].f = value;
1088    }
1089    if (ctx->ExecuteFlag) {
1090       CALL_Accum(ctx->Exec, (op, value));
1091    }
1092 }
1093
1094
1095 static void GLAPIENTRY
1096 save_AlphaFunc(GLenum func, GLclampf ref)
1097 {
1098    GET_CURRENT_CONTEXT(ctx);
1099    Node *n;
1100    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1101    n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
1102    if (n) {
1103       n[1].e = func;
1104       n[2].f = (GLfloat) ref;
1105    }
1106    if (ctx->ExecuteFlag) {
1107       CALL_AlphaFunc(ctx->Exec, (func, ref));
1108    }
1109 }
1110
1111
1112 static void GLAPIENTRY
1113 save_BindTexture(GLenum target, GLuint texture)
1114 {
1115    GET_CURRENT_CONTEXT(ctx);
1116    Node *n;
1117    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1118    n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
1119    if (n) {
1120       n[1].e = target;
1121       n[2].ui = texture;
1122    }
1123    if (ctx->ExecuteFlag) {
1124       CALL_BindTexture(ctx->Exec, (target, texture));
1125    }
1126 }
1127
1128
1129 static void GLAPIENTRY
1130 save_Bitmap(GLsizei width, GLsizei height,
1131             GLfloat xorig, GLfloat yorig,
1132             GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
1133 {
1134    GET_CURRENT_CONTEXT(ctx);
1135    Node *n;
1136    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1137    n = alloc_instruction(ctx, OPCODE_BITMAP, 7);
1138    if (n) {
1139       n[1].i = (GLint) width;
1140       n[2].i = (GLint) height;
1141       n[3].f = xorig;
1142       n[4].f = yorig;
1143       n[5].f = xmove;
1144       n[6].f = ymove;
1145       n[7].data = unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX,
1146                                GL_BITMAP, pixels, &ctx->Unpack);
1147    }
1148    if (ctx->ExecuteFlag) {
1149       CALL_Bitmap(ctx->Exec, (width, height,
1150                               xorig, yorig, xmove, ymove, pixels));
1151    }
1152 }
1153
1154
1155 static void GLAPIENTRY
1156 save_BlendEquation(GLenum mode)
1157 {
1158    GET_CURRENT_CONTEXT(ctx);
1159    Node *n;
1160    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1161    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
1162    if (n) {
1163       n[1].e = mode;
1164    }
1165    if (ctx->ExecuteFlag) {
1166       CALL_BlendEquation(ctx->Exec, (mode));
1167    }
1168 }
1169
1170
1171 static void GLAPIENTRY
1172 save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
1173 {
1174    GET_CURRENT_CONTEXT(ctx);
1175    Node *n;
1176    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1177    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
1178    if (n) {
1179       n[1].e = modeRGB;
1180       n[2].e = modeA;
1181    }
1182    if (ctx->ExecuteFlag) {
1183       CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA));
1184    }
1185 }
1186
1187
1188 static void GLAPIENTRY
1189 save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
1190                           GLenum sfactorA, GLenum dfactorA)
1191 {
1192    GET_CURRENT_CONTEXT(ctx);
1193    Node *n;
1194    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1195    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
1196    if (n) {
1197       n[1].e = sfactorRGB;
1198       n[2].e = dfactorRGB;
1199       n[3].e = sfactorA;
1200       n[4].e = dfactorA;
1201    }
1202    if (ctx->ExecuteFlag) {
1203       CALL_BlendFuncSeparateEXT(ctx->Exec,
1204                                 (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
1205    }
1206 }
1207
1208
1209 static void GLAPIENTRY
1210 save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
1211 {
1212    save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
1213 }
1214
1215
1216 static void GLAPIENTRY
1217 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1218 {
1219    GET_CURRENT_CONTEXT(ctx);
1220    Node *n;
1221    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1222    n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
1223    if (n) {
1224       n[1].f = red;
1225       n[2].f = green;
1226       n[3].f = blue;
1227       n[4].f = alpha;
1228    }
1229    if (ctx->ExecuteFlag) {
1230       CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
1231    }
1232 }
1233
1234 /* GL_ARB_draw_buffers_blend */
1235 static void GLAPIENTRY
1236 save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
1237                         GLenum sfactorA, GLenum dfactorA)
1238 {
1239    GET_CURRENT_CONTEXT(ctx);
1240    Node *n;
1241    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1242    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
1243    if (n) {
1244       n[1].ui = buf;
1245       n[2].e = sfactorRGB;
1246       n[3].e = dfactorRGB;
1247       n[4].e = sfactorA;
1248       n[5].e = dfactorA;
1249    }
1250    if (ctx->ExecuteFlag) {
1251       CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
1252                                              sfactorA, dfactorA));
1253    }
1254 }
1255
1256 /* GL_ARB_draw_buffers_blend */
1257 static void GLAPIENTRY
1258 save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
1259 {
1260    GET_CURRENT_CONTEXT(ctx);
1261    Node *n;
1262    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1263    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3);
1264    if (n) {
1265       n[1].ui = buf;
1266       n[2].e = sfactor;
1267       n[3].e = dfactor;
1268    }
1269    if (ctx->ExecuteFlag) {
1270       CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
1271    }
1272 }
1273
1274 /* GL_ARB_draw_buffers_blend */
1275 static void GLAPIENTRY
1276 save_BlendEquationi(GLuint buf, GLenum mode)
1277 {
1278    GET_CURRENT_CONTEXT(ctx);
1279    Node *n;
1280    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1281    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
1282    if (n) {
1283       n[1].ui = buf;
1284       n[2].e = mode;
1285    }
1286    if (ctx->ExecuteFlag) {
1287       CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
1288    }
1289 }
1290
1291 /* GL_ARB_draw_buffers_blend */
1292 static void GLAPIENTRY
1293 save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
1294 {
1295    GET_CURRENT_CONTEXT(ctx);
1296    Node *n;
1297    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1298    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
1299    if (n) {
1300       n[1].ui = buf;
1301       n[2].e = modeRGB;
1302       n[3].e = modeA;
1303    }
1304    if (ctx->ExecuteFlag) {
1305       CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
1306    }
1307 }
1308
1309
1310 /* GL_ARB_draw_instanced. */
1311 static void GLAPIENTRY
1312 save_DrawArraysInstancedARB(GLenum mode,
1313                             GLint first,
1314                             GLsizei count,
1315                             GLsizei primcount)
1316 {
1317    GET_CURRENT_CONTEXT(ctx);
1318    _mesa_error(ctx, GL_INVALID_OPERATION,
1319                "glDrawArraysInstanced() during display list compile");
1320 }
1321
1322 static void GLAPIENTRY
1323 save_DrawElementsInstancedARB(GLenum mode,
1324                               GLsizei count,
1325                               GLenum type,
1326                               const GLvoid *indices,
1327                               GLsizei primcount)
1328 {
1329    GET_CURRENT_CONTEXT(ctx);
1330    _mesa_error(ctx, GL_INVALID_OPERATION,
1331                "glDrawElementsInstanced() during display list compile");
1332 }
1333
1334 static void GLAPIENTRY
1335 save_DrawElementsInstancedBaseVertexARB(GLenum mode,
1336                                         GLsizei count,
1337                                         GLenum type,
1338                                         const GLvoid *indices,
1339                                         GLsizei primcount,
1340                                         GLint basevertex)
1341 {
1342    GET_CURRENT_CONTEXT(ctx);
1343    _mesa_error(ctx, GL_INVALID_OPERATION,
1344                "glDrawElementsInstancedBaseVertex() during display list compile");
1345 }
1346
1347 /* GL_ARB_base_instance. */
1348 static void GLAPIENTRY
1349 save_DrawArraysInstancedBaseInstance(GLenum mode,
1350                                      GLint first,
1351                                      GLsizei count,
1352                                      GLsizei primcount,
1353                                      GLuint baseinstance)
1354 {
1355    GET_CURRENT_CONTEXT(ctx);
1356    _mesa_error(ctx, GL_INVALID_OPERATION,
1357                "glDrawArraysInstancedBaseInstance() during display list compile");
1358 }
1359
1360 static void APIENTRY
1361 save_DrawElementsInstancedBaseInstance(GLenum mode,
1362                                        GLsizei count,
1363                                        GLenum type,
1364                                        const void *indices,
1365                                        GLsizei primcount,
1366                                        GLuint baseinstance)
1367 {
1368    GET_CURRENT_CONTEXT(ctx);
1369    _mesa_error(ctx, GL_INVALID_OPERATION,
1370                "glDrawElementsInstancedBaseInstance() during display list compile");
1371 }
1372
1373 static void APIENTRY
1374 save_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
1375                                                  GLsizei count,
1376                                                  GLenum type,
1377                                                  const void *indices,
1378                                                  GLsizei primcount,
1379                                                  GLint basevertex,
1380                                                  GLuint baseinstance)
1381 {
1382    GET_CURRENT_CONTEXT(ctx);
1383    _mesa_error(ctx, GL_INVALID_OPERATION,
1384                "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile");
1385 }
1386
1387 static void invalidate_saved_current_state( struct gl_context *ctx )
1388 {
1389    GLint i;
1390
1391    for (i = 0; i < VERT_ATTRIB_MAX; i++)
1392       ctx->ListState.ActiveAttribSize[i] = 0;
1393
1394    for (i = 0; i < MAT_ATTRIB_MAX; i++)
1395       ctx->ListState.ActiveMaterialSize[i] = 0;
1396
1397    memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
1398
1399    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1400 }
1401
1402 static void GLAPIENTRY
1403 save_CallList(GLuint list)
1404 {
1405    GET_CURRENT_CONTEXT(ctx);
1406    Node *n;
1407    SAVE_FLUSH_VERTICES(ctx);
1408
1409    n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
1410    if (n) {
1411       n[1].ui = list;
1412    }
1413
1414    /* After this, we don't know what state we're in.  Invalidate all
1415     * cached information previously gathered:
1416     */
1417    invalidate_saved_current_state( ctx );
1418
1419    if (ctx->ExecuteFlag) {
1420       _mesa_CallList(list);
1421    }
1422 }
1423
1424
1425 static void GLAPIENTRY
1426 save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
1427 {
1428    GET_CURRENT_CONTEXT(ctx);
1429    GLint i;
1430    GLboolean typeErrorFlag;
1431
1432    SAVE_FLUSH_VERTICES(ctx);
1433
1434    switch (type) {
1435    case GL_BYTE:
1436    case GL_UNSIGNED_BYTE:
1437    case GL_SHORT:
1438    case GL_UNSIGNED_SHORT:
1439    case GL_INT:
1440    case GL_UNSIGNED_INT:
1441    case GL_FLOAT:
1442    case GL_2_BYTES:
1443    case GL_3_BYTES:
1444    case GL_4_BYTES:
1445       typeErrorFlag = GL_FALSE;
1446       break;
1447    default:
1448       typeErrorFlag = GL_TRUE;
1449    }
1450
1451    for (i = 0; i < num; i++) {
1452       GLint list = translate_id(i, type, lists);
1453       Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2);
1454       if (n) {
1455          n[1].i = list;
1456          n[2].b = typeErrorFlag;
1457       }
1458    }
1459
1460    /* After this, we don't know what state we're in.  Invalidate all
1461     * cached information previously gathered:
1462     */
1463    invalidate_saved_current_state( ctx );
1464
1465    if (ctx->ExecuteFlag) {
1466       CALL_CallLists(ctx->Exec, (num, type, lists));
1467    }
1468 }
1469
1470
1471 static void GLAPIENTRY
1472 save_Clear(GLbitfield mask)
1473 {
1474    GET_CURRENT_CONTEXT(ctx);
1475    Node *n;
1476    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1477    n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
1478    if (n) {
1479       n[1].bf = mask;
1480    }
1481    if (ctx->ExecuteFlag) {
1482       CALL_Clear(ctx->Exec, (mask));
1483    }
1484 }
1485
1486
1487 static void GLAPIENTRY
1488 save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
1489 {
1490    GET_CURRENT_CONTEXT(ctx);
1491    Node *n;
1492    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1493    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
1494    if (n) {
1495       n[1].e = buffer;
1496       n[2].i = drawbuffer;
1497       n[3].i = value[0];
1498       if (buffer == GL_COLOR) {
1499          n[4].i = value[1];
1500          n[5].i = value[2];
1501          n[6].i = value[3];
1502       }
1503       else {
1504          n[4].i = 0;
1505          n[5].i = 0;
1506          n[6].i = 0;
1507       }
1508    }
1509    if (ctx->ExecuteFlag) {
1510       CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));
1511    }
1512 }
1513
1514
1515 static void GLAPIENTRY
1516 save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
1517 {
1518    GET_CURRENT_CONTEXT(ctx);
1519    Node *n;
1520    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1521    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
1522    if (n) {
1523       n[1].e = buffer;
1524       n[2].i = drawbuffer;
1525       n[3].ui = value[0];
1526       if (buffer == GL_COLOR) {
1527          n[4].ui = value[1];
1528          n[5].ui = value[2];
1529          n[6].ui = value[3];
1530       }
1531       else {
1532          n[4].ui = 0;
1533          n[5].ui = 0;
1534          n[6].ui = 0;
1535       }
1536    }
1537    if (ctx->ExecuteFlag) {
1538       CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));
1539    }
1540 }
1541
1542
1543 static void GLAPIENTRY
1544 save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
1545 {
1546    GET_CURRENT_CONTEXT(ctx);
1547    Node *n;
1548    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1549    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
1550    if (n) {
1551       n[1].e = buffer;
1552       n[2].i = drawbuffer;
1553       n[3].f = value[0];
1554       if (buffer == GL_COLOR) {
1555          n[4].f = value[1];
1556          n[5].f = value[2];
1557          n[6].f = value[3];
1558       }
1559       else {
1560          n[4].f = 0.0F;
1561          n[5].f = 0.0F;
1562          n[6].f = 0.0F;
1563       }
1564    }
1565    if (ctx->ExecuteFlag) {
1566       CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value));
1567    }
1568 }
1569
1570
1571 static void GLAPIENTRY
1572 save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
1573                    GLfloat depth, GLint stencil)
1574 {
1575    GET_CURRENT_CONTEXT(ctx);
1576    Node *n;
1577    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1578    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
1579    if (n) {
1580       n[1].e = buffer;
1581       n[2].i = drawbuffer;
1582       n[3].f = depth;
1583       n[4].i = stencil;
1584    }
1585    if (ctx->ExecuteFlag) {
1586       CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));
1587    }
1588 }
1589
1590
1591 static void GLAPIENTRY
1592 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1593 {
1594    GET_CURRENT_CONTEXT(ctx);
1595    Node *n;
1596    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1597    n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
1598    if (n) {
1599       n[1].f = red;
1600       n[2].f = green;
1601       n[3].f = blue;
1602       n[4].f = alpha;
1603    }
1604    if (ctx->ExecuteFlag) {
1605       CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
1606    }
1607 }
1608
1609
1610 static void GLAPIENTRY
1611 save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1612 {
1613    GET_CURRENT_CONTEXT(ctx);
1614    Node *n;
1615    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1616    n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
1617    if (n) {
1618       n[1].f = red;
1619       n[2].f = green;
1620       n[3].f = blue;
1621       n[4].f = alpha;
1622    }
1623    if (ctx->ExecuteFlag) {
1624       CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
1625    }
1626 }
1627
1628
1629 static void GLAPIENTRY
1630 save_ClearDepth(GLclampd depth)
1631 {
1632    GET_CURRENT_CONTEXT(ctx);
1633    Node *n;
1634    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1635    n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
1636    if (n) {
1637       n[1].f = (GLfloat) depth;
1638    }
1639    if (ctx->ExecuteFlag) {
1640       CALL_ClearDepth(ctx->Exec, (depth));
1641    }
1642 }
1643
1644
1645 static void GLAPIENTRY
1646 save_ClearIndex(GLfloat c)
1647 {
1648    GET_CURRENT_CONTEXT(ctx);
1649    Node *n;
1650    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1651    n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
1652    if (n) {
1653       n[1].f = c;
1654    }
1655    if (ctx->ExecuteFlag) {
1656       CALL_ClearIndex(ctx->Exec, (c));
1657    }
1658 }
1659
1660
1661 static void GLAPIENTRY
1662 save_ClearStencil(GLint s)
1663 {
1664    GET_CURRENT_CONTEXT(ctx);
1665    Node *n;
1666    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1667    n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
1668    if (n) {
1669       n[1].i = s;
1670    }
1671    if (ctx->ExecuteFlag) {
1672       CALL_ClearStencil(ctx->Exec, (s));
1673    }
1674 }
1675
1676
1677 static void GLAPIENTRY
1678 save_ClipPlane(GLenum plane, const GLdouble * equ)
1679 {
1680    GET_CURRENT_CONTEXT(ctx);
1681    Node *n;
1682    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1683    n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
1684    if (n) {
1685       n[1].e = plane;
1686       n[2].f = (GLfloat) equ[0];
1687       n[3].f = (GLfloat) equ[1];
1688       n[4].f = (GLfloat) equ[2];
1689       n[5].f = (GLfloat) equ[3];
1690    }
1691    if (ctx->ExecuteFlag) {
1692       CALL_ClipPlane(ctx->Exec, (plane, equ));
1693    }
1694 }
1695
1696
1697
1698 static void GLAPIENTRY
1699 save_ColorMask(GLboolean red, GLboolean green,
1700                GLboolean blue, GLboolean alpha)
1701 {
1702    GET_CURRENT_CONTEXT(ctx);
1703    Node *n;
1704    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1705    n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
1706    if (n) {
1707       n[1].b = red;
1708       n[2].b = green;
1709       n[3].b = blue;
1710       n[4].b = alpha;
1711    }
1712    if (ctx->ExecuteFlag) {
1713       CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
1714    }
1715 }
1716
1717
1718 static void GLAPIENTRY
1719 save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
1720                       GLboolean blue, GLboolean alpha)
1721 {
1722    GET_CURRENT_CONTEXT(ctx);
1723    Node *n;
1724    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1725    n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
1726    if (n) {
1727       n[1].ui = buf;
1728       n[2].b = red;
1729       n[3].b = green;
1730       n[4].b = blue;
1731       n[5].b = alpha;
1732    }
1733    if (ctx->ExecuteFlag) {
1734       /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/
1735    }
1736 }
1737
1738
1739 static void GLAPIENTRY
1740 save_ColorMaterial(GLenum face, GLenum mode)
1741 {
1742    GET_CURRENT_CONTEXT(ctx);
1743    Node *n;
1744    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1745
1746    n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
1747    if (n) {
1748       n[1].e = face;
1749       n[2].e = mode;
1750    }
1751    if (ctx->ExecuteFlag) {
1752       CALL_ColorMaterial(ctx->Exec, (face, mode));
1753    }
1754 }
1755
1756
1757 static void GLAPIENTRY
1758 save_ColorTable(GLenum target, GLenum internalFormat,
1759                 GLsizei width, GLenum format, GLenum type,
1760                 const GLvoid * table)
1761 {
1762    GET_CURRENT_CONTEXT(ctx);
1763    if (_mesa_is_proxy_texture(target)) {
1764       /* execute immediately */
1765       CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1766                                   format, type, table));
1767    }
1768    else {
1769       Node *n;
1770       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1771       n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6);
1772       if (n) {
1773          n[1].e = target;
1774          n[2].e = internalFormat;
1775          n[3].i = width;
1776          n[4].e = format;
1777          n[5].e = type;
1778          n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table,
1779                                   &ctx->Unpack);
1780       }
1781       if (ctx->ExecuteFlag) {
1782          CALL_ColorTable(ctx->Exec, (target, internalFormat, width,
1783                                      format, type, table));
1784       }
1785    }
1786 }
1787
1788
1789
1790 static void GLAPIENTRY
1791 save_ColorTableParameterfv(GLenum target, GLenum pname,
1792                            const GLfloat *params)
1793 {
1794    GET_CURRENT_CONTEXT(ctx);
1795    Node *n;
1796
1797    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1798
1799    n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6);
1800    if (n) {
1801       n[1].e = target;
1802       n[2].e = pname;
1803       n[3].f = params[0];
1804       if (pname == GL_COLOR_TABLE_SGI ||
1805           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1806           pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1807          n[4].f = params[1];
1808          n[5].f = params[2];
1809          n[6].f = params[3];
1810       }
1811    }
1812
1813    if (ctx->ExecuteFlag) {
1814       CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params));
1815    }
1816 }
1817
1818
1819 static void GLAPIENTRY
1820 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
1821 {
1822    GET_CURRENT_CONTEXT(ctx);
1823    Node *n;
1824
1825    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1826
1827    n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6);
1828    if (n) {
1829       n[1].e = target;
1830       n[2].e = pname;
1831       n[3].i = params[0];
1832       if (pname == GL_COLOR_TABLE_SGI ||
1833           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
1834           pname == GL_TEXTURE_COLOR_TABLE_SGI) {
1835          n[4].i = params[1];
1836          n[5].i = params[2];
1837          n[6].i = params[3];
1838       }
1839    }
1840
1841    if (ctx->ExecuteFlag) {
1842       CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params));
1843    }
1844 }
1845
1846
1847
1848 static void GLAPIENTRY
1849 save_ColorSubTable(GLenum target, GLsizei start, GLsizei count,
1850                    GLenum format, GLenum type, const GLvoid * table)
1851 {
1852    GET_CURRENT_CONTEXT(ctx);
1853    Node *n;
1854    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1855    n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6);
1856    if (n) {
1857       n[1].e = target;
1858       n[2].i = start;
1859       n[3].i = count;
1860       n[4].e = format;
1861       n[5].e = type;
1862       n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table,
1863                                &ctx->Unpack);
1864    }
1865    if (ctx->ExecuteFlag) {
1866       CALL_ColorSubTable(ctx->Exec,
1867                          (target, start, count, format, type, table));
1868    }
1869 }
1870
1871
1872 static void GLAPIENTRY
1873 save_CopyColorSubTable(GLenum target, GLsizei start,
1874                        GLint x, GLint y, GLsizei width)
1875 {
1876    GET_CURRENT_CONTEXT(ctx);
1877    Node *n;
1878
1879    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1880    n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5);
1881    if (n) {
1882       n[1].e = target;
1883       n[2].i = start;
1884       n[3].i = x;
1885       n[4].i = y;
1886       n[5].i = width;
1887    }
1888    if (ctx->ExecuteFlag) {
1889       CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width));
1890    }
1891 }
1892
1893
1894 static void GLAPIENTRY
1895 save_CopyColorTable(GLenum target, GLenum internalformat,
1896                     GLint x, GLint y, GLsizei width)
1897 {
1898    GET_CURRENT_CONTEXT(ctx);
1899    Node *n;
1900
1901    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1902    n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5);
1903    if (n) {
1904       n[1].e = target;
1905       n[2].e = internalformat;
1906       n[3].i = x;
1907       n[4].i = y;
1908       n[5].i = width;
1909    }
1910    if (ctx->ExecuteFlag) {
1911       CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width));
1912    }
1913 }
1914
1915
1916 static void GLAPIENTRY
1917 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
1918                          GLenum format, GLenum type, const GLvoid * filter)
1919 {
1920    GET_CURRENT_CONTEXT(ctx);
1921    Node *n;
1922
1923    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1924
1925    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6);
1926    if (n) {
1927       n[1].e = target;
1928       n[2].e = internalFormat;
1929       n[3].i = width;
1930       n[4].e = format;
1931       n[5].e = type;
1932       n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter,
1933                                &ctx->Unpack);
1934    }
1935    if (ctx->ExecuteFlag) {
1936       CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width,
1937                                            format, type, filter));
1938    }
1939 }
1940
1941
1942 static void GLAPIENTRY
1943 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
1944                          GLsizei width, GLsizei height, GLenum format,
1945                          GLenum type, const GLvoid * filter)
1946 {
1947    GET_CURRENT_CONTEXT(ctx);
1948    Node *n;
1949
1950    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1951
1952    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7);
1953    if (n) {
1954       n[1].e = target;
1955       n[2].e = internalFormat;
1956       n[3].i = width;
1957       n[4].i = height;
1958       n[5].e = format;
1959       n[6].e = type;
1960       n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter,
1961                                &ctx->Unpack);
1962    }
1963    if (ctx->ExecuteFlag) {
1964       CALL_ConvolutionFilter2D(ctx->Exec,
1965                                (target, internalFormat, width, height, format,
1966                                 type, filter));
1967    }
1968 }
1969
1970
1971 static void GLAPIENTRY
1972 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
1973 {
1974    GET_CURRENT_CONTEXT(ctx);
1975    Node *n;
1976    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1977    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3);
1978    if (n) {
1979       n[1].e = target;
1980       n[2].e = pname;
1981       n[3].i = param;
1982    }
1983    if (ctx->ExecuteFlag) {
1984       CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param));
1985    }
1986 }
1987
1988
1989 static void GLAPIENTRY
1990 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
1991 {
1992    GET_CURRENT_CONTEXT(ctx);
1993    Node *n;
1994    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1995    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6);
1996    if (n) {
1997       n[1].e = target;
1998       n[2].e = pname;
1999       n[3].i = params[0];
2000       if (pname == GL_CONVOLUTION_BORDER_COLOR ||
2001           pname == GL_CONVOLUTION_FILTER_SCALE ||
2002           pname == GL_CONVOLUTION_FILTER_BIAS) {
2003          n[4].i = params[1];
2004          n[5].i = params[2];
2005          n[6].i = params[3];
2006       }
2007       else {
2008          n[4].i = n[5].i = n[6].i = 0;
2009       }
2010    }
2011    if (ctx->ExecuteFlag) {
2012       CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params));
2013    }
2014 }
2015
2016
2017 static void GLAPIENTRY
2018 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
2019 {
2020    GET_CURRENT_CONTEXT(ctx);
2021    Node *n;
2022    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2023    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3);
2024    if (n) {
2025       n[1].e = target;
2026       n[2].e = pname;
2027       n[3].f = param;
2028    }
2029    if (ctx->ExecuteFlag) {
2030       CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param));
2031    }
2032 }
2033
2034
2035 static void GLAPIENTRY
2036 save_ConvolutionParameterfv(GLenum target, GLenum pname,
2037                             const GLfloat *params)
2038 {
2039    GET_CURRENT_CONTEXT(ctx);
2040    Node *n;
2041    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2042    n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6);
2043    if (n) {
2044       n[1].e = target;
2045       n[2].e = pname;
2046       n[3].f = params[0];
2047       if (pname == GL_CONVOLUTION_BORDER_COLOR ||
2048           pname == GL_CONVOLUTION_FILTER_SCALE ||
2049           pname == GL_CONVOLUTION_FILTER_BIAS) {
2050          n[4].f = params[1];
2051          n[5].f = params[2];
2052          n[6].f = params[3];
2053       }
2054       else {
2055          n[4].f = n[5].f = n[6].f = 0.0F;
2056       }
2057    }
2058    if (ctx->ExecuteFlag) {
2059       CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params));
2060    }
2061 }
2062
2063
2064 static void GLAPIENTRY
2065 save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
2066 {
2067    GET_CURRENT_CONTEXT(ctx);
2068    Node *n;
2069    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2070    n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
2071    if (n) {
2072       n[1].i = x;
2073       n[2].i = y;
2074       n[3].i = (GLint) width;
2075       n[4].i = (GLint) height;
2076       n[5].e = type;
2077    }
2078    if (ctx->ExecuteFlag) {
2079       CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
2080    }
2081 }
2082
2083
2084
2085 static void GLAPIENTRY
2086 save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
2087                     GLint x, GLint y, GLsizei width, GLint border)
2088 {
2089    GET_CURRENT_CONTEXT(ctx);
2090    Node *n;
2091    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2092    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
2093    if (n) {
2094       n[1].e = target;
2095       n[2].i = level;
2096       n[3].e = internalformat;
2097       n[4].i = x;
2098       n[5].i = y;
2099       n[6].i = width;
2100       n[7].i = border;
2101    }
2102    if (ctx->ExecuteFlag) {
2103       CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
2104                                       x, y, width, border));
2105    }
2106 }
2107
2108
2109 static void GLAPIENTRY
2110 save_CopyTexImage2D(GLenum target, GLint level,
2111                     GLenum internalformat,
2112                     GLint x, GLint y, GLsizei width,
2113                     GLsizei height, GLint border)
2114 {
2115    GET_CURRENT_CONTEXT(ctx);
2116    Node *n;
2117    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2118    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
2119    if (n) {
2120       n[1].e = target;
2121       n[2].i = level;
2122       n[3].e = internalformat;
2123       n[4].i = x;
2124       n[5].i = y;
2125       n[6].i = width;
2126       n[7].i = height;
2127       n[8].i = border;
2128    }
2129    if (ctx->ExecuteFlag) {
2130       CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
2131                                       x, y, width, height, border));
2132    }
2133 }
2134
2135
2136
2137 static void GLAPIENTRY
2138 save_CopyTexSubImage1D(GLenum target, GLint level,
2139                        GLint xoffset, GLint x, GLint y, GLsizei width)
2140 {
2141    GET_CURRENT_CONTEXT(ctx);
2142    Node *n;
2143    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2144    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
2145    if (n) {
2146       n[1].e = target;
2147       n[2].i = level;
2148       n[3].i = xoffset;
2149       n[4].i = x;
2150       n[5].i = y;
2151       n[6].i = width;
2152    }
2153    if (ctx->ExecuteFlag) {
2154       CALL_CopyTexSubImage1D(ctx->Exec,
2155                              (target, level, xoffset, x, y, width));
2156    }
2157 }
2158
2159
2160 static void GLAPIENTRY
2161 save_CopyTexSubImage2D(GLenum target, GLint level,
2162                        GLint xoffset, GLint yoffset,
2163                        GLint x, GLint y, GLsizei width, GLint height)
2164 {
2165    GET_CURRENT_CONTEXT(ctx);
2166    Node *n;
2167    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2168    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
2169    if (n) {
2170       n[1].e = target;
2171       n[2].i = level;
2172       n[3].i = xoffset;
2173       n[4].i = yoffset;
2174       n[5].i = x;
2175       n[6].i = y;
2176       n[7].i = width;
2177       n[8].i = height;
2178    }
2179    if (ctx->ExecuteFlag) {
2180       CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
2181                                          x, y, width, height));
2182    }
2183 }
2184
2185
2186 static void GLAPIENTRY
2187 save_CopyTexSubImage3D(GLenum target, GLint level,
2188                        GLint xoffset, GLint yoffset, GLint zoffset,
2189                        GLint x, GLint y, GLsizei width, GLint height)
2190 {
2191    GET_CURRENT_CONTEXT(ctx);
2192    Node *n;
2193    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2194    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
2195    if (n) {
2196       n[1].e = target;
2197       n[2].i = level;
2198       n[3].i = xoffset;
2199       n[4].i = yoffset;
2200       n[5].i = zoffset;
2201       n[6].i = x;
2202       n[7].i = y;
2203       n[8].i = width;
2204       n[9].i = height;
2205    }
2206    if (ctx->ExecuteFlag) {
2207       CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
2208                                          xoffset, yoffset, zoffset,
2209                                          x, y, width, height));
2210    }
2211 }
2212
2213
2214 static void GLAPIENTRY
2215 save_CullFace(GLenum mode)
2216 {
2217    GET_CURRENT_CONTEXT(ctx);
2218    Node *n;
2219    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2220    n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
2221    if (n) {
2222       n[1].e = mode;
2223    }
2224    if (ctx->ExecuteFlag) {
2225       CALL_CullFace(ctx->Exec, (mode));
2226    }
2227 }
2228
2229
2230 static void GLAPIENTRY
2231 save_DepthFunc(GLenum func)
2232 {
2233    GET_CURRENT_CONTEXT(ctx);
2234    Node *n;
2235    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2236    n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
2237    if (n) {
2238       n[1].e = func;
2239    }
2240    if (ctx->ExecuteFlag) {
2241       CALL_DepthFunc(ctx->Exec, (func));
2242    }
2243 }
2244
2245
2246 static void GLAPIENTRY
2247 save_DepthMask(GLboolean mask)
2248 {
2249    GET_CURRENT_CONTEXT(ctx);
2250    Node *n;
2251    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2252    n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
2253    if (n) {
2254       n[1].b = mask;
2255    }
2256    if (ctx->ExecuteFlag) {
2257       CALL_DepthMask(ctx->Exec, (mask));
2258    }
2259 }
2260
2261
2262 static void GLAPIENTRY
2263 save_DepthRange(GLclampd nearval, GLclampd farval)
2264 {
2265    GET_CURRENT_CONTEXT(ctx);
2266    Node *n;
2267    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2268    n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
2269    if (n) {
2270       n[1].f = (GLfloat) nearval;
2271       n[2].f = (GLfloat) farval;
2272    }
2273    if (ctx->ExecuteFlag) {
2274       CALL_DepthRange(ctx->Exec, (nearval, farval));
2275    }
2276 }
2277
2278
2279 static void GLAPIENTRY
2280 save_Disable(GLenum cap)
2281 {
2282    GET_CURRENT_CONTEXT(ctx);
2283    Node *n;
2284    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2285    n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
2286    if (n) {
2287       n[1].e = cap;
2288    }
2289    if (ctx->ExecuteFlag) {
2290       CALL_Disable(ctx->Exec, (cap));
2291    }
2292 }
2293
2294
2295 static void GLAPIENTRY
2296 save_DisableIndexed(GLuint index, GLenum cap)
2297 {
2298    GET_CURRENT_CONTEXT(ctx);
2299    Node *n;
2300    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2301    n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
2302    if (n) {
2303       n[1].ui = index;
2304       n[2].e = cap;
2305    }
2306    if (ctx->ExecuteFlag) {
2307       CALL_DisableIndexedEXT(ctx->Exec, (index, cap));
2308    }
2309 }
2310
2311
2312 static void GLAPIENTRY
2313 save_DrawBuffer(GLenum mode)
2314 {
2315    GET_CURRENT_CONTEXT(ctx);
2316    Node *n;
2317    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2318    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
2319    if (n) {
2320       n[1].e = mode;
2321    }
2322    if (ctx->ExecuteFlag) {
2323       CALL_DrawBuffer(ctx->Exec, (mode));
2324    }
2325 }
2326
2327
2328 static void GLAPIENTRY
2329 save_DrawPixels(GLsizei width, GLsizei height,
2330                 GLenum format, GLenum type, const GLvoid * pixels)
2331 {
2332    GET_CURRENT_CONTEXT(ctx);
2333    Node *n;
2334
2335    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2336
2337    n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5);
2338    if (n) {
2339       n[1].i = width;
2340       n[2].i = height;
2341       n[3].e = format;
2342       n[4].e = type;
2343       n[5].data = unpack_image(ctx, 2, width, height, 1, format, type,
2344                                pixels, &ctx->Unpack);
2345    }
2346    if (ctx->ExecuteFlag) {
2347       CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
2348    }
2349 }
2350
2351
2352
2353 static void GLAPIENTRY
2354 save_Enable(GLenum cap)
2355 {
2356    GET_CURRENT_CONTEXT(ctx);
2357    Node *n;
2358    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2359    n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
2360    if (n) {
2361       n[1].e = cap;
2362    }
2363    if (ctx->ExecuteFlag) {
2364       CALL_Enable(ctx->Exec, (cap));
2365    }
2366 }
2367
2368
2369
2370 static void GLAPIENTRY
2371 save_EnableIndexed(GLuint index, GLenum cap)
2372 {
2373    GET_CURRENT_CONTEXT(ctx);
2374    Node *n;
2375    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2376    n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
2377    if (n) {
2378       n[1].ui = index;
2379       n[2].e = cap;
2380    }
2381    if (ctx->ExecuteFlag) {
2382       CALL_EnableIndexedEXT(ctx->Exec, (index, cap));
2383    }
2384 }
2385
2386
2387
2388 static void GLAPIENTRY
2389 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
2390 {
2391    GET_CURRENT_CONTEXT(ctx);
2392    Node *n;
2393    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2394    n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
2395    if (n) {
2396       n[1].e = mode;
2397       n[2].i = i1;
2398       n[3].i = i2;
2399    }
2400    if (ctx->ExecuteFlag) {
2401       CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
2402    }
2403 }
2404
2405
2406 static void GLAPIENTRY
2407 save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
2408 {
2409    GET_CURRENT_CONTEXT(ctx);
2410    Node *n;
2411    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2412    n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
2413    if (n) {
2414       n[1].e = mode;
2415       n[2].i = i1;
2416       n[3].i = i2;
2417       n[4].i = j1;
2418       n[5].i = j2;
2419    }
2420    if (ctx->ExecuteFlag) {
2421       CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
2422    }
2423 }
2424
2425
2426
2427
2428 static void GLAPIENTRY
2429 save_Fogfv(GLenum pname, const GLfloat *params)
2430 {
2431    GET_CURRENT_CONTEXT(ctx);
2432    Node *n;
2433    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2434    n = alloc_instruction(ctx, OPCODE_FOG, 5);
2435    if (n) {
2436       n[1].e = pname;
2437       n[2].f = params[0];
2438       n[3].f = params[1];
2439       n[4].f = params[2];
2440       n[5].f = params[3];
2441    }
2442    if (ctx->ExecuteFlag) {
2443       CALL_Fogfv(ctx->Exec, (pname, params));
2444    }
2445 }
2446
2447
2448 static void GLAPIENTRY
2449 save_Fogf(GLenum pname, GLfloat param)
2450 {
2451    GLfloat parray[4];
2452    parray[0] = param;
2453    parray[1] = parray[2] = parray[3] = 0.0F;
2454    save_Fogfv(pname, parray);
2455 }
2456
2457
2458 static void GLAPIENTRY
2459 save_Fogiv(GLenum pname, const GLint *params)
2460 {
2461    GLfloat p[4];
2462    switch (pname) {
2463    case GL_FOG_MODE:
2464    case GL_FOG_DENSITY:
2465    case GL_FOG_START:
2466    case GL_FOG_END:
2467    case GL_FOG_INDEX:
2468       p[0] = (GLfloat) *params;
2469       p[1] = 0.0f;
2470       p[2] = 0.0f;
2471       p[3] = 0.0f;
2472       break;
2473    case GL_FOG_COLOR:
2474       p[0] = INT_TO_FLOAT(params[0]);
2475       p[1] = INT_TO_FLOAT(params[1]);
2476       p[2] = INT_TO_FLOAT(params[2]);
2477       p[3] = INT_TO_FLOAT(params[3]);
2478       break;
2479    default:
2480       /* Error will be caught later in gl_Fogfv */
2481       ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
2482    }
2483    save_Fogfv(pname, p);
2484 }
2485
2486
2487 static void GLAPIENTRY
2488 save_Fogi(GLenum pname, GLint param)
2489 {
2490    GLint parray[4];
2491    parray[0] = param;
2492    parray[1] = parray[2] = parray[3] = 0;
2493    save_Fogiv(pname, parray);
2494 }
2495
2496
2497 static void GLAPIENTRY
2498 save_FrontFace(GLenum mode)
2499 {
2500    GET_CURRENT_CONTEXT(ctx);
2501    Node *n;
2502    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2503    n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
2504    if (n) {
2505       n[1].e = mode;
2506    }
2507    if (ctx->ExecuteFlag) {
2508       CALL_FrontFace(ctx->Exec, (mode));
2509    }
2510 }
2511
2512
2513 static void GLAPIENTRY
2514 save_Frustum(GLdouble left, GLdouble right,
2515              GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2516 {
2517    GET_CURRENT_CONTEXT(ctx);
2518    Node *n;
2519    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2520    n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
2521    if (n) {
2522       n[1].f = (GLfloat) left;
2523       n[2].f = (GLfloat) right;
2524       n[3].f = (GLfloat) bottom;
2525       n[4].f = (GLfloat) top;
2526       n[5].f = (GLfloat) nearval;
2527       n[6].f = (GLfloat) farval;
2528    }
2529    if (ctx->ExecuteFlag) {
2530       CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
2531    }
2532 }
2533
2534
2535 static void GLAPIENTRY
2536 save_Hint(GLenum target, GLenum mode)
2537 {
2538    GET_CURRENT_CONTEXT(ctx);
2539    Node *n;
2540    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2541    n = alloc_instruction(ctx, OPCODE_HINT, 2);
2542    if (n) {
2543       n[1].e = target;
2544       n[2].e = mode;
2545    }
2546    if (ctx->ExecuteFlag) {
2547       CALL_Hint(ctx->Exec, (target, mode));
2548    }
2549 }
2550
2551
2552 static void GLAPIENTRY
2553 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat,
2554                GLboolean sink)
2555 {
2556    GET_CURRENT_CONTEXT(ctx);
2557    Node *n;
2558
2559    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2560    n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4);
2561    if (n) {
2562       n[1].e = target;
2563       n[2].i = width;
2564       n[3].e = internalFormat;
2565       n[4].b = sink;
2566    }
2567    if (ctx->ExecuteFlag) {
2568       CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink));
2569    }
2570 }
2571
2572
2573 static void GLAPIENTRY
2574 save_IndexMask(GLuint mask)
2575 {
2576    GET_CURRENT_CONTEXT(ctx);
2577    Node *n;
2578    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2579    n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
2580    if (n) {
2581       n[1].ui = mask;
2582    }
2583    if (ctx->ExecuteFlag) {
2584       CALL_IndexMask(ctx->Exec, (mask));
2585    }
2586 }
2587
2588
2589 static void GLAPIENTRY
2590 save_InitNames(void)
2591 {
2592    GET_CURRENT_CONTEXT(ctx);
2593    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2594    (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
2595    if (ctx->ExecuteFlag) {
2596       CALL_InitNames(ctx->Exec, ());
2597    }
2598 }
2599
2600
2601 static void GLAPIENTRY
2602 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2603 {
2604    GET_CURRENT_CONTEXT(ctx);
2605    Node *n;
2606    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2607    n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
2608    if (n) {
2609       GLint i, nParams;
2610       n[1].e = light;
2611       n[2].e = pname;
2612       switch (pname) {
2613       case GL_AMBIENT:
2614          nParams = 4;
2615          break;
2616       case GL_DIFFUSE:
2617          nParams = 4;
2618          break;
2619       case GL_SPECULAR:
2620          nParams = 4;
2621          break;
2622       case GL_POSITION:
2623          nParams = 4;
2624          break;
2625       case GL_SPOT_DIRECTION:
2626          nParams = 3;
2627          break;
2628       case GL_SPOT_EXPONENT:
2629          nParams = 1;
2630          break;
2631       case GL_SPOT_CUTOFF:
2632          nParams = 1;
2633          break;
2634       case GL_CONSTANT_ATTENUATION:
2635          nParams = 1;
2636          break;
2637       case GL_LINEAR_ATTENUATION:
2638          nParams = 1;
2639          break;
2640       case GL_QUADRATIC_ATTENUATION:
2641          nParams = 1;
2642          break;
2643       default:
2644          nParams = 0;
2645       }
2646       for (i = 0; i < nParams; i++) {
2647          n[3 + i].f = params[i];
2648       }
2649    }
2650    if (ctx->ExecuteFlag) {
2651       CALL_Lightfv(ctx->Exec, (light, pname, params));
2652    }
2653 }
2654
2655
2656 static void GLAPIENTRY
2657 save_Lightf(GLenum light, GLenum pname, GLfloat param)
2658 {
2659    GLfloat parray[4];
2660    parray[0] = param;
2661    parray[1] = parray[2] = parray[3] = 0.0F;
2662    save_Lightfv(light, pname, parray);
2663 }
2664
2665
2666 static void GLAPIENTRY
2667 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2668 {
2669    GLfloat fparam[4];
2670    switch (pname) {
2671    case GL_AMBIENT:
2672    case GL_DIFFUSE:
2673    case GL_SPECULAR:
2674       fparam[0] = INT_TO_FLOAT(params[0]);
2675       fparam[1] = INT_TO_FLOAT(params[1]);
2676       fparam[2] = INT_TO_FLOAT(params[2]);
2677       fparam[3] = INT_TO_FLOAT(params[3]);
2678       break;
2679    case GL_POSITION:
2680       fparam[0] = (GLfloat) params[0];
2681       fparam[1] = (GLfloat) params[1];
2682       fparam[2] = (GLfloat) params[2];
2683       fparam[3] = (GLfloat) params[3];
2684       break;
2685    case GL_SPOT_DIRECTION:
2686       fparam[0] = (GLfloat) params[0];
2687       fparam[1] = (GLfloat) params[1];
2688       fparam[2] = (GLfloat) params[2];
2689       break;
2690    case GL_SPOT_EXPONENT:
2691    case GL_SPOT_CUTOFF:
2692    case GL_CONSTANT_ATTENUATION:
2693    case GL_LINEAR_ATTENUATION:
2694    case GL_QUADRATIC_ATTENUATION:
2695       fparam[0] = (GLfloat) params[0];
2696       break;
2697    default:
2698       /* error will be caught later in gl_Lightfv */
2699       ;
2700    }
2701    save_Lightfv(light, pname, fparam);
2702 }
2703
2704
2705 static void GLAPIENTRY
2706 save_Lighti(GLenum light, GLenum pname, GLint param)
2707 {
2708    GLint parray[4];
2709    parray[0] = param;
2710    parray[1] = parray[2] = parray[3] = 0;
2711    save_Lightiv(light, pname, parray);
2712 }
2713
2714
2715 static void GLAPIENTRY
2716 save_LightModelfv(GLenum pname, const GLfloat *params)
2717 {
2718    GET_CURRENT_CONTEXT(ctx);
2719    Node *n;
2720    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2721    n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
2722    if (n) {
2723       n[1].e = pname;
2724       n[2].f = params[0];
2725       n[3].f = params[1];
2726       n[4].f = params[2];
2727       n[5].f = params[3];
2728    }
2729    if (ctx->ExecuteFlag) {
2730       CALL_LightModelfv(ctx->Exec, (pname, params));
2731    }
2732 }
2733
2734
2735 static void GLAPIENTRY
2736 save_LightModelf(GLenum pname, GLfloat param)
2737 {
2738    GLfloat parray[4];
2739    parray[0] = param;
2740    parray[1] = parray[2] = parray[3] = 0.0F;
2741    save_LightModelfv(pname, parray);
2742 }
2743
2744
2745 static void GLAPIENTRY
2746 save_LightModeliv(GLenum pname, const GLint *params)
2747 {
2748    GLfloat fparam[4];
2749    switch (pname) {
2750    case GL_LIGHT_MODEL_AMBIENT:
2751       fparam[0] = INT_TO_FLOAT(params[0]);
2752       fparam[1] = INT_TO_FLOAT(params[1]);
2753       fparam[2] = INT_TO_FLOAT(params[2]);
2754       fparam[3] = INT_TO_FLOAT(params[3]);
2755       break;
2756    case GL_LIGHT_MODEL_LOCAL_VIEWER:
2757    case GL_LIGHT_MODEL_TWO_SIDE:
2758    case GL_LIGHT_MODEL_COLOR_CONTROL:
2759       fparam[0] = (GLfloat) params[0];
2760       fparam[1] = 0.0F;
2761       fparam[2] = 0.0F;
2762       fparam[3] = 0.0F;
2763       break;
2764    default:
2765       /* Error will be caught later in gl_LightModelfv */
2766       ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
2767    }
2768    save_LightModelfv(pname, fparam);
2769 }
2770
2771
2772 static void GLAPIENTRY
2773 save_LightModeli(GLenum pname, GLint param)
2774 {
2775    GLint parray[4];
2776    parray[0] = param;
2777    parray[1] = parray[2] = parray[3] = 0;
2778    save_LightModeliv(pname, parray);
2779 }
2780
2781
2782 static void GLAPIENTRY
2783 save_LineStipple(GLint factor, GLushort pattern)
2784 {
2785    GET_CURRENT_CONTEXT(ctx);
2786    Node *n;
2787    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2788    n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
2789    if (n) {
2790       n[1].i = factor;
2791       n[2].us = pattern;
2792    }
2793    if (ctx->ExecuteFlag) {
2794       CALL_LineStipple(ctx->Exec, (factor, pattern));
2795    }
2796 }
2797
2798
2799 static void GLAPIENTRY
2800 save_LineWidth(GLfloat width)
2801 {
2802    GET_CURRENT_CONTEXT(ctx);
2803    Node *n;
2804    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2805    n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
2806    if (n) {
2807       n[1].f = width;
2808    }
2809    if (ctx->ExecuteFlag) {
2810       CALL_LineWidth(ctx->Exec, (width));
2811    }
2812 }
2813
2814
2815 static void GLAPIENTRY
2816 save_ListBase(GLuint base)
2817 {
2818    GET_CURRENT_CONTEXT(ctx);
2819    Node *n;
2820    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2821    n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
2822    if (n) {
2823       n[1].ui = base;
2824    }
2825    if (ctx->ExecuteFlag) {
2826       CALL_ListBase(ctx->Exec, (base));
2827    }
2828 }
2829
2830
2831 static void GLAPIENTRY
2832 save_LoadIdentity(void)
2833 {
2834    GET_CURRENT_CONTEXT(ctx);
2835    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2836    (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
2837    if (ctx->ExecuteFlag) {
2838       CALL_LoadIdentity(ctx->Exec, ());
2839    }
2840 }
2841
2842
2843 static void GLAPIENTRY
2844 save_LoadMatrixf(const GLfloat * m)
2845 {
2846    GET_CURRENT_CONTEXT(ctx);
2847    Node *n;
2848    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2849    n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
2850    if (n) {
2851       GLuint i;
2852       for (i = 0; i < 16; i++) {
2853          n[1 + i].f = m[i];
2854       }
2855    }
2856    if (ctx->ExecuteFlag) {
2857       CALL_LoadMatrixf(ctx->Exec, (m));
2858    }
2859 }
2860
2861
2862 static void GLAPIENTRY
2863 save_LoadMatrixd(const GLdouble * m)
2864 {
2865    GLfloat f[16];
2866    GLint i;
2867    for (i = 0; i < 16; i++) {
2868       f[i] = (GLfloat) m[i];
2869    }
2870    save_LoadMatrixf(f);
2871 }
2872
2873
2874 static void GLAPIENTRY
2875 save_LoadName(GLuint name)
2876 {
2877    GET_CURRENT_CONTEXT(ctx);
2878    Node *n;
2879    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2880    n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
2881    if (n) {
2882       n[1].ui = name;
2883    }
2884    if (ctx->ExecuteFlag) {
2885       CALL_LoadName(ctx->Exec, (name));
2886    }
2887 }
2888
2889
2890 static void GLAPIENTRY
2891 save_LogicOp(GLenum opcode)
2892 {
2893    GET_CURRENT_CONTEXT(ctx);
2894    Node *n;
2895    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2896    n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
2897    if (n) {
2898       n[1].e = opcode;
2899    }
2900    if (ctx->ExecuteFlag) {
2901       CALL_LogicOp(ctx->Exec, (opcode));
2902    }
2903 }
2904
2905
2906 static void GLAPIENTRY
2907 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2908            GLint order, const GLdouble * points)
2909 {
2910    GET_CURRENT_CONTEXT(ctx);
2911    Node *n;
2912    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2913    n = alloc_instruction(ctx, OPCODE_MAP1, 6);
2914    if (n) {
2915       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
2916       n[1].e = target;
2917       n[2].f = (GLfloat) u1;
2918       n[3].f = (GLfloat) u2;
2919       n[4].i = _mesa_evaluator_components(target);      /* stride */
2920       n[5].i = order;
2921       n[6].data = (void *) pnts;
2922    }
2923    if (ctx->ExecuteFlag) {
2924       CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
2925    }
2926 }
2927
2928 static void GLAPIENTRY
2929 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2930            GLint order, const GLfloat * points)
2931 {
2932    GET_CURRENT_CONTEXT(ctx);
2933    Node *n;
2934    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2935    n = alloc_instruction(ctx, OPCODE_MAP1, 6);
2936    if (n) {
2937       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
2938       n[1].e = target;
2939       n[2].f = u1;
2940       n[3].f = u2;
2941       n[4].i = _mesa_evaluator_components(target);      /* stride */
2942       n[5].i = order;
2943       n[6].data = (void *) pnts;
2944    }
2945    if (ctx->ExecuteFlag) {
2946       CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
2947    }
2948 }
2949
2950
2951 static void GLAPIENTRY
2952 save_Map2d(GLenum target,
2953            GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2954            GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2955            const GLdouble * points)
2956 {
2957    GET_CURRENT_CONTEXT(ctx);
2958    Node *n;
2959    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2960    n = alloc_instruction(ctx, OPCODE_MAP2, 10);
2961    if (n) {
2962       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
2963                                               vstride, vorder, points);
2964       n[1].e = target;
2965       n[2].f = (GLfloat) u1;
2966       n[3].f = (GLfloat) u2;
2967       n[4].f = (GLfloat) v1;
2968       n[5].f = (GLfloat) v2;
2969       /* XXX verify these strides are correct */
2970       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
2971       n[7].i = _mesa_evaluator_components(target);      /*vstride */
2972       n[8].i = uorder;
2973       n[9].i = vorder;
2974       n[10].data = (void *) pnts;
2975    }
2976    if (ctx->ExecuteFlag) {
2977       CALL_Map2d(ctx->Exec, (target,
2978                              u1, u2, ustride, uorder,
2979                              v1, v2, vstride, vorder, points));
2980    }
2981 }
2982
2983
2984 static void GLAPIENTRY
2985 save_Map2f(GLenum target,
2986            GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2987            GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2988            const GLfloat * points)
2989 {
2990    GET_CURRENT_CONTEXT(ctx);
2991    Node *n;
2992    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2993    n = alloc_instruction(ctx, OPCODE_MAP2, 10);
2994    if (n) {
2995       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
2996                                               vstride, vorder, points);
2997       n[1].e = target;
2998       n[2].f = u1;
2999       n[3].f = u2;
3000       n[4].f = v1;
3001       n[5].f = v2;
3002       /* XXX verify these strides are correct */
3003       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
3004       n[7].i = _mesa_evaluator_components(target);      /*vstride */
3005       n[8].i = uorder;
3006       n[9].i = vorder;
3007       n[10].data = (void *) pnts;
3008    }
3009    if (ctx->ExecuteFlag) {
3010       CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
3011                              v1, v2, vstride, vorder, points));
3012    }
3013 }
3014
3015
3016 static void GLAPIENTRY
3017 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
3018 {
3019    GET_CURRENT_CONTEXT(ctx);
3020    Node *n;
3021    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3022    n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
3023    if (n) {
3024       n[1].i = un;
3025       n[2].f = u1;
3026       n[3].f = u2;
3027    }
3028    if (ctx->ExecuteFlag) {
3029       CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
3030    }
3031 }
3032
3033
3034 static void GLAPIENTRY
3035 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
3036 {
3037    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
3038 }
3039
3040
3041 static void GLAPIENTRY
3042 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
3043                GLint vn, GLfloat v1, GLfloat v2)
3044 {
3045    GET_CURRENT_CONTEXT(ctx);
3046    Node *n;
3047    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3048    n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
3049    if (n) {
3050       n[1].i = un;
3051       n[2].f = u1;
3052       n[3].f = u2;
3053       n[4].i = vn;
3054       n[5].f = v1;
3055       n[6].f = v2;
3056    }
3057    if (ctx->ExecuteFlag) {
3058       CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
3059    }
3060 }
3061
3062
3063
3064 static void GLAPIENTRY
3065 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
3066                GLint vn, GLdouble v1, GLdouble v2)
3067 {
3068    save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
3069                   vn, (GLfloat) v1, (GLfloat) v2);
3070 }
3071
3072
3073 static void GLAPIENTRY
3074 save_MatrixMode(GLenum mode)
3075 {
3076    GET_CURRENT_CONTEXT(ctx);
3077    Node *n;
3078    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3079    n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
3080    if (n) {
3081       n[1].e = mode;
3082    }
3083    if (ctx->ExecuteFlag) {
3084       CALL_MatrixMode(ctx->Exec, (mode));
3085    }
3086 }
3087
3088
3089 static void GLAPIENTRY
3090 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
3091 {
3092    GET_CURRENT_CONTEXT(ctx);
3093    Node *n;
3094
3095    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3096    n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3);
3097    if (n) {
3098       n[1].e = target;
3099       n[2].e = internalFormat;
3100       n[3].b = sink;
3101    }
3102    if (ctx->ExecuteFlag) {
3103       CALL_Minmax(ctx->Exec, (target, internalFormat, sink));
3104    }
3105 }
3106
3107
3108 static void GLAPIENTRY
3109 save_MultMatrixf(const GLfloat * m)
3110 {
3111    GET_CURRENT_CONTEXT(ctx);
3112    Node *n;
3113    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3114    n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
3115    if (n) {
3116       GLuint i;
3117       for (i = 0; i < 16; i++) {
3118          n[1 + i].f = m[i];
3119       }
3120    }
3121    if (ctx->ExecuteFlag) {
3122       CALL_MultMatrixf(ctx->Exec, (m));
3123    }
3124 }
3125
3126
3127 static void GLAPIENTRY
3128 save_MultMatrixd(const GLdouble * m)
3129 {
3130    GLfloat f[16];
3131    GLint i;
3132    for (i = 0; i < 16; i++) {
3133       f[i] = (GLfloat) m[i];
3134    }
3135    save_MultMatrixf(f);
3136 }
3137
3138
3139 static void GLAPIENTRY
3140 save_NewList(GLuint name, GLenum mode)
3141 {
3142    GET_CURRENT_CONTEXT(ctx);
3143    /* It's an error to call this function while building a display list */
3144    _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
3145    (void) name;
3146    (void) mode;
3147 }
3148
3149
3150
3151 static void GLAPIENTRY
3152 save_Ortho(GLdouble left, GLdouble right,
3153            GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
3154 {
3155    GET_CURRENT_CONTEXT(ctx);
3156    Node *n;
3157    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3158    n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
3159    if (n) {
3160       n[1].f = (GLfloat) left;
3161       n[2].f = (GLfloat) right;
3162       n[3].f = (GLfloat) bottom;
3163       n[4].f = (GLfloat) top;
3164       n[5].f = (GLfloat) nearval;
3165       n[6].f = (GLfloat) farval;
3166    }
3167    if (ctx->ExecuteFlag) {
3168       CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
3169    }
3170 }
3171
3172
3173 static void GLAPIENTRY
3174 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
3175 {
3176    GET_CURRENT_CONTEXT(ctx);
3177    Node *n;
3178    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3179    n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3);
3180    if (n) {
3181       n[1].e = map;
3182       n[2].i = mapsize;
3183       n[3].data = (void *) malloc(mapsize * sizeof(GLfloat));
3184       memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat));
3185    }
3186    if (ctx->ExecuteFlag) {
3187       CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
3188    }
3189 }
3190
3191
3192 static void GLAPIENTRY
3193 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
3194 {
3195    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3196    GLint i;
3197    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3198       for (i = 0; i < mapsize; i++) {
3199          fvalues[i] = (GLfloat) values[i];
3200       }
3201    }
3202    else {
3203       for (i = 0; i < mapsize; i++) {
3204          fvalues[i] = UINT_TO_FLOAT(values[i]);
3205       }
3206    }
3207    save_PixelMapfv(map, mapsize, fvalues);
3208 }
3209
3210
3211 static void GLAPIENTRY
3212 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
3213 {
3214    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3215    GLint i;
3216    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3217       for (i = 0; i < mapsize; i++) {
3218          fvalues[i] = (GLfloat) values[i];
3219       }
3220    }
3221    else {
3222       for (i = 0; i < mapsize; i++) {
3223          fvalues[i] = USHORT_TO_FLOAT(values[i]);
3224       }
3225    }
3226    save_PixelMapfv(map, mapsize, fvalues);
3227 }
3228
3229
3230 static void GLAPIENTRY
3231 save_PixelTransferf(GLenum pname, GLfloat param)
3232 {
3233    GET_CURRENT_CONTEXT(ctx);
3234    Node *n;
3235    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3236    n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
3237    if (n) {
3238       n[1].e = pname;
3239       n[2].f = param;
3240    }
3241    if (ctx->ExecuteFlag) {
3242       CALL_PixelTransferf(ctx->Exec, (pname, param));
3243    }
3244 }
3245
3246
3247 static void GLAPIENTRY
3248 save_PixelTransferi(GLenum pname, GLint param)
3249 {
3250    save_PixelTransferf(pname, (GLfloat) param);
3251 }
3252
3253
3254 static void GLAPIENTRY
3255 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
3256 {
3257    GET_CURRENT_CONTEXT(ctx);
3258    Node *n;
3259    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3260    n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
3261    if (n) {
3262       n[1].f = xfactor;
3263       n[2].f = yfactor;
3264    }
3265    if (ctx->ExecuteFlag) {
3266       CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
3267    }
3268 }
3269
3270
3271 static void GLAPIENTRY
3272 save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
3273 {
3274    GET_CURRENT_CONTEXT(ctx);
3275    Node *n;
3276    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3277    n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
3278    if (n) {
3279       n[1].e = pname;
3280       n[2].f = params[0];
3281       n[3].f = params[1];
3282       n[4].f = params[2];
3283    }
3284    if (ctx->ExecuteFlag) {
3285       CALL_PointParameterfvEXT(ctx->Exec, (pname, params));
3286    }
3287 }
3288
3289
3290 static void GLAPIENTRY
3291 save_PointParameterfEXT(GLenum pname, GLfloat param)
3292 {
3293    GLfloat parray[3];
3294    parray[0] = param;
3295    parray[1] = parray[2] = 0.0F;
3296    save_PointParameterfvEXT(pname, parray);
3297 }
3298
3299 static void GLAPIENTRY
3300 save_PointParameteriNV(GLenum pname, GLint param)
3301 {
3302    GLfloat parray[3];
3303    parray[0] = (GLfloat) param;
3304    parray[1] = parray[2] = 0.0F;
3305    save_PointParameterfvEXT(pname, parray);
3306 }
3307
3308 static void GLAPIENTRY
3309 save_PointParameterivNV(GLenum pname, const GLint * param)
3310 {
3311    GLfloat parray[3];
3312    parray[0] = (GLfloat) param[0];
3313    parray[1] = parray[2] = 0.0F;
3314    save_PointParameterfvEXT(pname, parray);
3315 }
3316
3317
3318 static void GLAPIENTRY
3319 save_PointSize(GLfloat size)
3320 {
3321    GET_CURRENT_CONTEXT(ctx);
3322    Node *n;
3323    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3324    n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
3325    if (n) {
3326       n[1].f = size;
3327    }
3328    if (ctx->ExecuteFlag) {
3329       CALL_PointSize(ctx->Exec, (size));
3330    }
3331 }
3332
3333
3334 static void GLAPIENTRY
3335 save_PolygonMode(GLenum face, GLenum mode)
3336 {
3337    GET_CURRENT_CONTEXT(ctx);
3338    Node *n;
3339    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3340    n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
3341    if (n) {
3342       n[1].e = face;
3343       n[2].e = mode;
3344    }
3345    if (ctx->ExecuteFlag) {
3346       CALL_PolygonMode(ctx->Exec, (face, mode));
3347    }
3348 }
3349
3350
3351 static void GLAPIENTRY
3352 save_PolygonStipple(const GLubyte * pattern)
3353 {
3354    GET_CURRENT_CONTEXT(ctx);
3355    Node *n;
3356
3357    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3358
3359    n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1);
3360    if (n) {
3361       n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
3362                                pattern, &ctx->Unpack);
3363    }
3364    if (ctx->ExecuteFlag) {
3365       CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
3366    }
3367 }
3368
3369
3370 static void GLAPIENTRY
3371 save_PolygonOffset(GLfloat factor, GLfloat units)
3372 {
3373    GET_CURRENT_CONTEXT(ctx);
3374    Node *n;
3375    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3376    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
3377    if (n) {
3378       n[1].f = factor;
3379       n[2].f = units;
3380    }
3381    if (ctx->ExecuteFlag) {
3382       CALL_PolygonOffset(ctx->Exec, (factor, units));
3383    }
3384 }
3385
3386
3387 static void GLAPIENTRY
3388 save_PolygonOffsetEXT(GLfloat factor, GLfloat bias)
3389 {
3390    GET_CURRENT_CONTEXT(ctx);
3391    /* XXX mult by DepthMaxF here??? */
3392    save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
3393 }
3394
3395
3396 static void GLAPIENTRY
3397 save_PopAttrib(void)
3398 {
3399    GET_CURRENT_CONTEXT(ctx);
3400    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3401    (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
3402    if (ctx->ExecuteFlag) {
3403       CALL_PopAttrib(ctx->Exec, ());
3404    }
3405 }
3406
3407
3408 static void GLAPIENTRY
3409 save_PopMatrix(void)
3410 {
3411    GET_CURRENT_CONTEXT(ctx);
3412    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3413    (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
3414    if (ctx->ExecuteFlag) {
3415       CALL_PopMatrix(ctx->Exec, ());
3416    }
3417 }
3418
3419
3420 static void GLAPIENTRY
3421 save_PopName(void)
3422 {
3423    GET_CURRENT_CONTEXT(ctx);
3424    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3425    (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
3426    if (ctx->ExecuteFlag) {
3427       CALL_PopName(ctx->Exec, ());
3428    }
3429 }
3430
3431
3432 static void GLAPIENTRY
3433 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
3434                         const GLclampf * priorities)
3435 {
3436    GET_CURRENT_CONTEXT(ctx);
3437    GLint i;
3438    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3439
3440    for (i = 0; i < num; i++) {
3441       Node *n;
3442       n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
3443       if (n) {
3444          n[1].ui = textures[i];
3445          n[2].f = priorities[i];
3446       }
3447    }
3448    if (ctx->ExecuteFlag) {
3449       CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
3450    }
3451 }
3452
3453
3454 static void GLAPIENTRY
3455 save_PushAttrib(GLbitfield mask)
3456 {
3457    GET_CURRENT_CONTEXT(ctx);
3458    Node *n;
3459    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3460    n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
3461    if (n) {
3462       n[1].bf = mask;
3463    }
3464    if (ctx->ExecuteFlag) {
3465       CALL_PushAttrib(ctx->Exec, (mask));
3466    }
3467 }
3468
3469
3470 static void GLAPIENTRY
3471 save_PushMatrix(void)
3472 {
3473    GET_CURRENT_CONTEXT(ctx);
3474    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3475    (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
3476    if (ctx->ExecuteFlag) {
3477       CALL_PushMatrix(ctx->Exec, ());
3478    }
3479 }
3480
3481
3482 static void GLAPIENTRY
3483 save_PushName(GLuint name)
3484 {
3485    GET_CURRENT_CONTEXT(ctx);
3486    Node *n;
3487    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3488    n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
3489    if (n) {
3490       n[1].ui = name;
3491    }
3492    if (ctx->ExecuteFlag) {
3493       CALL_PushName(ctx->Exec, (name));
3494    }
3495 }
3496
3497
3498 static void GLAPIENTRY
3499 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3500 {
3501    GET_CURRENT_CONTEXT(ctx);
3502    Node *n;
3503    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3504    n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
3505    if (n) {
3506       n[1].f = x;
3507       n[2].f = y;
3508       n[3].f = z;
3509       n[4].f = w;
3510    }
3511    if (ctx->ExecuteFlag) {
3512       CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
3513    }
3514 }
3515
3516 static void GLAPIENTRY
3517 save_RasterPos2d(GLdouble x, GLdouble y)
3518 {
3519    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3520 }
3521
3522 static void GLAPIENTRY
3523 save_RasterPos2f(GLfloat x, GLfloat y)
3524 {
3525    save_RasterPos4f(x, y, 0.0F, 1.0F);
3526 }
3527
3528 static void GLAPIENTRY
3529 save_RasterPos2i(GLint x, GLint y)
3530 {
3531    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3532 }
3533
3534 static void GLAPIENTRY
3535 save_RasterPos2s(GLshort x, GLshort y)
3536 {
3537    save_RasterPos4f(x, y, 0.0F, 1.0F);
3538 }
3539
3540 static void GLAPIENTRY
3541 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
3542 {
3543    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3544 }
3545
3546 static void GLAPIENTRY
3547 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
3548 {
3549    save_RasterPos4f(x, y, z, 1.0F);
3550 }
3551
3552 static void GLAPIENTRY
3553 save_RasterPos3i(GLint x, GLint y, GLint z)
3554 {
3555    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3556 }
3557
3558 static void GLAPIENTRY
3559 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
3560 {
3561    save_RasterPos4f(x, y, z, 1.0F);
3562 }
3563
3564 static void GLAPIENTRY
3565 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3566 {
3567    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3568 }
3569
3570 static void GLAPIENTRY
3571 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
3572 {
3573    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3574 }
3575
3576 static void GLAPIENTRY
3577 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
3578 {
3579    save_RasterPos4f(x, y, z, w);
3580 }
3581
3582 static void GLAPIENTRY
3583 save_RasterPos2dv(const GLdouble * v)
3584 {
3585    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3586 }
3587
3588 static void GLAPIENTRY
3589 save_RasterPos2fv(const GLfloat * v)
3590 {
3591    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3592 }
3593
3594 static void GLAPIENTRY
3595 save_RasterPos2iv(const GLint * v)
3596 {
3597    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3598 }
3599
3600 static void GLAPIENTRY
3601 save_RasterPos2sv(const GLshort * v)
3602 {
3603    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3604 }
3605
3606 static void GLAPIENTRY
3607 save_RasterPos3dv(const GLdouble * v)
3608 {
3609    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3610 }
3611
3612 static void GLAPIENTRY
3613 save_RasterPos3fv(const GLfloat * v)
3614 {
3615    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3616 }
3617
3618 static void GLAPIENTRY
3619 save_RasterPos3iv(const GLint * v)
3620 {
3621    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3622 }
3623
3624 static void GLAPIENTRY
3625 save_RasterPos3sv(const GLshort * v)
3626 {
3627    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3628 }
3629
3630 static void GLAPIENTRY
3631 save_RasterPos4dv(const GLdouble * v)
3632 {
3633    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3634                     (GLfloat) v[2], (GLfloat) v[3]);
3635 }
3636
3637 static void GLAPIENTRY
3638 save_RasterPos4fv(const GLfloat * v)
3639 {
3640    save_RasterPos4f(v[0], v[1], v[2], v[3]);
3641 }
3642
3643 static void GLAPIENTRY
3644 save_RasterPos4iv(const GLint * v)
3645 {
3646    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3647                     (GLfloat) v[2], (GLfloat) v[3]);
3648 }
3649
3650 static void GLAPIENTRY
3651 save_RasterPos4sv(const GLshort * v)
3652 {
3653    save_RasterPos4f(v[0], v[1], v[2], v[3]);
3654 }
3655
3656
3657 static void GLAPIENTRY
3658 save_PassThrough(GLfloat token)
3659 {
3660    GET_CURRENT_CONTEXT(ctx);
3661    Node *n;
3662    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3663    n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
3664    if (n) {
3665       n[1].f = token;
3666    }
3667    if (ctx->ExecuteFlag) {
3668       CALL_PassThrough(ctx->Exec, (token));
3669    }
3670 }
3671
3672
3673 static void GLAPIENTRY
3674 save_ReadBuffer(GLenum mode)
3675 {
3676    GET_CURRENT_CONTEXT(ctx);
3677    Node *n;
3678    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3679    n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
3680    if (n) {
3681       n[1].e = mode;
3682    }
3683    if (ctx->ExecuteFlag) {
3684       CALL_ReadBuffer(ctx->Exec, (mode));
3685    }
3686 }
3687
3688
3689 static void GLAPIENTRY
3690 save_ResetHistogram(GLenum target)
3691 {
3692    GET_CURRENT_CONTEXT(ctx);
3693    Node *n;
3694    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3695    n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1);
3696    if (n) {
3697       n[1].e = target;
3698    }
3699    if (ctx->ExecuteFlag) {
3700       CALL_ResetHistogram(ctx->Exec, (target));
3701    }
3702 }
3703
3704
3705 static void GLAPIENTRY
3706 save_ResetMinmax(GLenum target)
3707 {
3708    GET_CURRENT_CONTEXT(ctx);
3709    Node *n;
3710    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3711    n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1);
3712    if (n) {
3713       n[1].e = target;
3714    }
3715    if (ctx->ExecuteFlag) {
3716       CALL_ResetMinmax(ctx->Exec, (target));
3717    }
3718 }
3719
3720
3721 static void GLAPIENTRY
3722 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
3723 {
3724    GET_CURRENT_CONTEXT(ctx);
3725    Node *n;
3726    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3727    n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
3728    if (n) {
3729       n[1].f = angle;
3730       n[2].f = x;
3731       n[3].f = y;
3732       n[4].f = z;
3733    }
3734    if (ctx->ExecuteFlag) {
3735       CALL_Rotatef(ctx->Exec, (angle, x, y, z));
3736    }
3737 }
3738
3739
3740 static void GLAPIENTRY
3741 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
3742 {
3743    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3744 }
3745
3746
3747 static void GLAPIENTRY
3748 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
3749 {
3750    GET_CURRENT_CONTEXT(ctx);
3751    Node *n;
3752    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3753    n = alloc_instruction(ctx, OPCODE_SCALE, 3);
3754    if (n) {
3755       n[1].f = x;
3756       n[2].f = y;
3757       n[3].f = z;
3758    }
3759    if (ctx->ExecuteFlag) {
3760       CALL_Scalef(ctx->Exec, (x, y, z));
3761    }
3762 }
3763
3764
3765 static void GLAPIENTRY
3766 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
3767 {
3768    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3769 }
3770
3771
3772 static void GLAPIENTRY
3773 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
3774 {
3775    GET_CURRENT_CONTEXT(ctx);
3776    Node *n;
3777    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3778    n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
3779    if (n) {
3780       n[1].i = x;
3781       n[2].i = y;
3782       n[3].i = width;
3783       n[4].i = height;
3784    }
3785    if (ctx->ExecuteFlag) {
3786       CALL_Scissor(ctx->Exec, (x, y, width, height));
3787    }
3788 }
3789
3790
3791 static void GLAPIENTRY
3792 save_ShadeModel(GLenum mode)
3793 {
3794    GET_CURRENT_CONTEXT(ctx);
3795    Node *n;
3796    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
3797
3798    if (ctx->ExecuteFlag) {
3799       CALL_ShadeModel(ctx->Exec, (mode));
3800    }
3801
3802    if (ctx->ListState.Current.ShadeModel == mode)
3803       return;
3804
3805    SAVE_FLUSH_VERTICES(ctx);
3806
3807    /* Only save the value if we know the statechange will take effect:
3808     */
3809    if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
3810       ctx->ListState.Current.ShadeModel = mode;
3811
3812    n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
3813    if (n) {
3814       n[1].e = mode;
3815    }
3816 }
3817
3818
3819 static void GLAPIENTRY
3820 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
3821 {
3822    GET_CURRENT_CONTEXT(ctx);
3823    Node *n;
3824    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3825    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
3826    if (n) {
3827       n[1].e = func;
3828       n[2].i = ref;
3829       n[3].ui = mask;
3830    }
3831    if (ctx->ExecuteFlag) {
3832       CALL_StencilFunc(ctx->Exec, (func, ref, mask));
3833    }
3834 }
3835
3836
3837 static void GLAPIENTRY
3838 save_StencilMask(GLuint mask)
3839 {
3840    GET_CURRENT_CONTEXT(ctx);
3841    Node *n;
3842    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3843    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
3844    if (n) {
3845       n[1].ui = mask;
3846    }
3847    if (ctx->ExecuteFlag) {
3848       CALL_StencilMask(ctx->Exec, (mask));
3849    }
3850 }
3851
3852
3853 static void GLAPIENTRY
3854 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3855 {
3856    GET_CURRENT_CONTEXT(ctx);
3857    Node *n;
3858    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3859    n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
3860    if (n) {
3861       n[1].e = fail;
3862       n[2].e = zfail;
3863       n[3].e = zpass;
3864    }
3865    if (ctx->ExecuteFlag) {
3866       CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
3867    }
3868 }
3869
3870
3871 static void GLAPIENTRY
3872 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3873 {
3874    GET_CURRENT_CONTEXT(ctx);
3875    Node *n;
3876    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3877    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3878    if (n) {
3879       n[1].e = face;
3880       n[2].e = func;
3881       n[3].i = ref;
3882       n[4].ui = mask;
3883    }
3884    if (ctx->ExecuteFlag) {
3885       CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
3886    }
3887 }
3888
3889
3890 static void GLAPIENTRY
3891 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
3892                             GLuint mask)
3893 {
3894    GET_CURRENT_CONTEXT(ctx);
3895    Node *n;
3896    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3897    /* GL_FRONT */
3898    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3899    if (n) {
3900       n[1].e = GL_FRONT;
3901       n[2].e = frontfunc;
3902       n[3].i = ref;
3903       n[4].ui = mask;
3904    }
3905    /* GL_BACK */
3906    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3907    if (n) {
3908       n[1].e = GL_BACK;
3909       n[2].e = backfunc;
3910       n[3].i = ref;
3911       n[4].ui = mask;
3912    }
3913    if (ctx->ExecuteFlag) {
3914       CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
3915       CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
3916    }
3917 }
3918
3919
3920 static void GLAPIENTRY
3921 save_StencilMaskSeparate(GLenum face, GLuint mask)
3922 {
3923    GET_CURRENT_CONTEXT(ctx);
3924    Node *n;
3925    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3926    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
3927    if (n) {
3928       n[1].e = face;
3929       n[2].ui = mask;
3930    }
3931    if (ctx->ExecuteFlag) {
3932       CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
3933    }
3934 }
3935
3936
3937 static void GLAPIENTRY
3938 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3939 {
3940    GET_CURRENT_CONTEXT(ctx);
3941    Node *n;
3942    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3943    n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
3944    if (n) {
3945       n[1].e = face;
3946       n[2].e = fail;
3947       n[3].e = zfail;
3948       n[4].e = zpass;
3949    }
3950    if (ctx->ExecuteFlag) {
3951       CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
3952    }
3953 }
3954
3955
3956 static void GLAPIENTRY
3957 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
3958 {
3959    GET_CURRENT_CONTEXT(ctx);
3960    Node *n;
3961    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3962    n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
3963    if (n) {
3964       n[1].e = target;
3965       n[2].e = pname;
3966       if (pname == GL_TEXTURE_ENV_COLOR) {
3967          n[3].f = params[0];
3968          n[4].f = params[1];
3969          n[5].f = params[2];
3970          n[6].f = params[3];
3971       }
3972       else {
3973          n[3].f = params[0];
3974          n[4].f = n[5].f = n[6].f = 0.0F;
3975       }
3976    }
3977    if (ctx->ExecuteFlag) {
3978       CALL_TexEnvfv(ctx->Exec, (target, pname, params));
3979    }
3980 }
3981
3982
3983 static void GLAPIENTRY
3984 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
3985 {
3986    GLfloat parray[4];
3987    parray[0] = (GLfloat) param;
3988    parray[1] = parray[2] = parray[3] = 0.0F;
3989    save_TexEnvfv(target, pname, parray);
3990 }
3991
3992
3993 static void GLAPIENTRY
3994 save_TexEnvi(GLenum target, GLenum pname, GLint param)
3995 {
3996    GLfloat p[4];
3997    p[0] = (GLfloat) param;
3998    p[1] = p[2] = p[3] = 0.0F;
3999    save_TexEnvfv(target, pname, p);
4000 }
4001
4002
4003 static void GLAPIENTRY
4004 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
4005 {
4006    GLfloat p[4];
4007    if (pname == GL_TEXTURE_ENV_COLOR) {
4008       p[0] = INT_TO_FLOAT(param[0]);
4009       p[1] = INT_TO_FLOAT(param[1]);
4010       p[2] = INT_TO_FLOAT(param[2]);
4011       p[3] = INT_TO_FLOAT(param[3]);
4012    }
4013    else {
4014       p[0] = (GLfloat) param[0];
4015       p[1] = p[2] = p[3] = 0.0F;
4016    }
4017    save_TexEnvfv(target, pname, p);
4018 }
4019
4020
4021 static void GLAPIENTRY
4022 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
4023 {
4024    GET_CURRENT_CONTEXT(ctx);
4025    Node *n;
4026    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4027    n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
4028    if (n) {
4029       n[1].e = coord;
4030       n[2].e = pname;
4031       n[3].f = params[0];
4032       n[4].f = params[1];
4033       n[5].f = params[2];
4034       n[6].f = params[3];
4035    }
4036    if (ctx->ExecuteFlag) {
4037       CALL_TexGenfv(ctx->Exec, (coord, pname, params));
4038    }
4039 }
4040
4041
4042 static void GLAPIENTRY
4043 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
4044 {
4045    GLfloat p[4];
4046    p[0] = (GLfloat) params[0];
4047    p[1] = (GLfloat) params[1];
4048    p[2] = (GLfloat) params[2];
4049    p[3] = (GLfloat) params[3];
4050    save_TexGenfv(coord, pname, p);
4051 }
4052
4053
4054 static void GLAPIENTRY
4055 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
4056 {
4057    GLfloat parray[4];
4058    parray[0] = (GLfloat) param;
4059    parray[1] = parray[2] = parray[3] = 0.0F;
4060    save_TexGenfv(coord, pname, parray);
4061 }
4062
4063
4064 static void GLAPIENTRY
4065 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
4066 {
4067    GLfloat p[4];
4068    p[0] = (GLfloat) params[0];
4069    p[1] = (GLfloat) params[1];
4070    p[2] = (GLfloat) params[2];
4071    p[3] = (GLfloat) params[3];
4072    save_TexGenfv(coord, pname, p);
4073 }
4074
4075
4076 static void GLAPIENTRY
4077 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
4078 {
4079    GLfloat parray[4];
4080    parray[0] = param;
4081    parray[1] = parray[2] = parray[3] = 0.0F;
4082    save_TexGenfv(coord, pname, parray);
4083 }
4084
4085
4086 static void GLAPIENTRY
4087 save_TexGeni(GLenum coord, GLenum pname, GLint param)
4088 {
4089    GLint parray[4];
4090    parray[0] = param;
4091    parray[1] = parray[2] = parray[3] = 0;
4092    save_TexGeniv(coord, pname, parray);
4093 }
4094
4095
4096 static void GLAPIENTRY
4097 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
4098 {
4099    GET_CURRENT_CONTEXT(ctx);
4100    Node *n;
4101    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4102    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
4103    if (n) {
4104       n[1].e = target;
4105       n[2].e = pname;
4106       n[3].f = params[0];
4107       n[4].f = params[1];
4108       n[5].f = params[2];
4109       n[6].f = params[3];
4110    }
4111    if (ctx->ExecuteFlag) {
4112       CALL_TexParameterfv(ctx->Exec, (target, pname, params));
4113    }
4114 }
4115
4116
4117 static void GLAPIENTRY
4118 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
4119 {
4120    GLfloat parray[4];
4121    parray[0] = param;
4122    parray[1] = parray[2] = parray[3] = 0.0F;
4123    save_TexParameterfv(target, pname, parray);
4124 }
4125
4126
4127 static void GLAPIENTRY
4128 save_TexParameteri(GLenum target, GLenum pname, GLint param)
4129 {
4130    GLfloat fparam[4];
4131    fparam[0] = (GLfloat) param;
4132    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4133    save_TexParameterfv(target, pname, fparam);
4134 }
4135
4136
4137 static void GLAPIENTRY
4138 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
4139 {
4140    GLfloat fparam[4];
4141    fparam[0] = (GLfloat) params[0];
4142    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4143    save_TexParameterfv(target, pname, fparam);
4144 }
4145
4146
4147 static void GLAPIENTRY
4148 save_TexImage1D(GLenum target,
4149                 GLint level, GLint components,
4150                 GLsizei width, GLint border,
4151                 GLenum format, GLenum type, const GLvoid * pixels)
4152 {
4153    GET_CURRENT_CONTEXT(ctx);
4154    if (target == GL_PROXY_TEXTURE_1D) {
4155       /* don't compile, execute immediately */
4156       CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4157                                   border, format, type, pixels));
4158    }
4159    else {
4160       Node *n;
4161       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4162       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8);
4163       if (n) {
4164          n[1].e = target;
4165          n[2].i = level;
4166          n[3].i = components;
4167          n[4].i = (GLint) width;
4168          n[5].i = border;
4169          n[6].e = format;
4170          n[7].e = type;
4171          n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type,
4172                                   pixels, &ctx->Unpack);
4173       }
4174       if (ctx->ExecuteFlag) {
4175          CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4176                                      border, format, type, pixels));
4177       }
4178    }
4179 }
4180
4181
4182 static void GLAPIENTRY
4183 save_TexImage2D(GLenum target,
4184                 GLint level, GLint components,
4185                 GLsizei width, GLsizei height, GLint border,
4186                 GLenum format, GLenum type, const GLvoid * pixels)
4187 {
4188    GET_CURRENT_CONTEXT(ctx);
4189    if (target == GL_PROXY_TEXTURE_2D) {
4190       /* don't compile, execute immediately */
4191       CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4192                                   height, border, format, type, pixels));
4193    }
4194    else {
4195       Node *n;
4196       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4197       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9);
4198       if (n) {
4199          n[1].e = target;
4200          n[2].i = level;
4201          n[3].i = components;
4202          n[4].i = (GLint) width;
4203          n[5].i = (GLint) height;
4204          n[6].i = border;
4205          n[7].e = format;
4206          n[8].e = type;
4207          n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
4208                                   pixels, &ctx->Unpack);
4209       }
4210       if (ctx->ExecuteFlag) {
4211          CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4212                                      height, border, format, type, pixels));
4213       }
4214    }
4215 }
4216
4217
4218 static void GLAPIENTRY
4219 save_TexImage3D(GLenum target,
4220                 GLint level, GLint internalFormat,
4221                 GLsizei width, GLsizei height, GLsizei depth,
4222                 GLint border,
4223                 GLenum format, GLenum type, const GLvoid * pixels)
4224 {
4225    GET_CURRENT_CONTEXT(ctx);
4226    if (target == GL_PROXY_TEXTURE_3D) {
4227       /* don't compile, execute immediately */
4228       CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4229                                   height, depth, border, format, type,
4230                                   pixels));
4231    }
4232    else {
4233       Node *n;
4234       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4235       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10);
4236       if (n) {
4237          n[1].e = target;
4238          n[2].i = level;
4239          n[3].i = (GLint) internalFormat;
4240          n[4].i = (GLint) width;
4241          n[5].i = (GLint) height;
4242          n[6].i = (GLint) depth;
4243          n[7].i = border;
4244          n[8].e = format;
4245          n[9].e = type;
4246          n[10].data = unpack_image(ctx, 3, width, height, depth, format, type,
4247                                    pixels, &ctx->Unpack);
4248       }
4249       if (ctx->ExecuteFlag) {
4250          CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4251                                      height, depth, border, format, type,
4252                                      pixels));
4253       }
4254    }
4255 }
4256
4257
4258 static void GLAPIENTRY
4259 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
4260                    GLsizei width, GLenum format, GLenum type,
4261                    const GLvoid * pixels)
4262 {
4263    GET_CURRENT_CONTEXT(ctx);
4264    Node *n;
4265
4266    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4267
4268    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7);
4269    if (n) {
4270       n[1].e = target;
4271       n[2].i = level;
4272       n[3].i = xoffset;
4273       n[4].i = (GLint) width;
4274       n[5].e = format;
4275       n[6].e = type;
4276       n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type,
4277                                pixels, &ctx->Unpack);
4278    }
4279    if (ctx->ExecuteFlag) {
4280       CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
4281                                      format, type, pixels));
4282    }
4283 }
4284
4285
4286 static void GLAPIENTRY
4287 save_TexSubImage2D(GLenum target, GLint level,
4288                    GLint xoffset, GLint yoffset,
4289                    GLsizei width, GLsizei height,
4290                    GLenum format, GLenum type, const GLvoid * pixels)
4291 {
4292    GET_CURRENT_CONTEXT(ctx);
4293    Node *n;
4294
4295    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4296
4297    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9);
4298    if (n) {
4299       n[1].e = target;
4300       n[2].i = level;
4301       n[3].i = xoffset;
4302       n[4].i = yoffset;
4303       n[5].i = (GLint) width;
4304       n[6].i = (GLint) height;
4305       n[7].e = format;
4306       n[8].e = type;
4307       n[9].data = unpack_image(ctx, 2, width, height, 1, format, type,
4308                                pixels, &ctx->Unpack);
4309    }
4310    if (ctx->ExecuteFlag) {
4311       CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
4312                                      width, height, format, type, pixels));
4313    }
4314 }
4315
4316
4317 static void GLAPIENTRY
4318 save_TexSubImage3D(GLenum target, GLint level,
4319                    GLint xoffset, GLint yoffset, GLint zoffset,
4320                    GLsizei width, GLsizei height, GLsizei depth,
4321                    GLenum format, GLenum type, const GLvoid * pixels)
4322 {
4323    GET_CURRENT_CONTEXT(ctx);
4324    Node *n;
4325
4326    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4327
4328    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11);
4329    if (n) {
4330       n[1].e = target;
4331       n[2].i = level;
4332       n[3].i = xoffset;
4333       n[4].i = yoffset;
4334       n[5].i = zoffset;
4335       n[6].i = (GLint) width;
4336       n[7].i = (GLint) height;
4337       n[8].i = (GLint) depth;
4338       n[9].e = format;
4339       n[10].e = type;
4340       n[11].data = unpack_image(ctx, 3, width, height, depth, format, type,
4341                                 pixels, &ctx->Unpack);
4342    }
4343    if (ctx->ExecuteFlag) {
4344       CALL_TexSubImage3D(ctx->Exec, (target, level,
4345                                      xoffset, yoffset, zoffset,
4346                                      width, height, depth, format, type,
4347                                      pixels));
4348    }
4349 }
4350
4351
4352 static void GLAPIENTRY
4353 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
4354 {
4355    GET_CURRENT_CONTEXT(ctx);
4356    Node *n;
4357    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4358    n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
4359    if (n) {
4360       n[1].f = x;
4361       n[2].f = y;
4362       n[3].f = z;
4363    }
4364    if (ctx->ExecuteFlag) {
4365       CALL_Translatef(ctx->Exec, (x, y, z));
4366    }
4367 }
4368
4369
4370 static void GLAPIENTRY
4371 save_Translated(GLdouble x, GLdouble y, GLdouble z)
4372 {
4373    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4374 }
4375
4376
4377
4378 static void GLAPIENTRY
4379 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
4380 {
4381    GET_CURRENT_CONTEXT(ctx);
4382    Node *n;
4383    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4384    n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
4385    if (n) {
4386       n[1].i = x;
4387       n[2].i = y;
4388       n[3].i = (GLint) width;
4389       n[4].i = (GLint) height;
4390    }
4391    if (ctx->ExecuteFlag) {
4392       CALL_Viewport(ctx->Exec, (x, y, width, height));
4393    }
4394 }
4395
4396
4397 static void GLAPIENTRY
4398 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4399 {
4400    GET_CURRENT_CONTEXT(ctx);
4401    Node *n;
4402    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4403    n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
4404    if (n) {
4405       n[1].f = x;
4406       n[2].f = y;
4407       n[3].f = z;
4408       n[4].f = w;
4409    }
4410    if (ctx->ExecuteFlag) {
4411       CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
4412    }
4413 }
4414
4415 static void GLAPIENTRY
4416 save_WindowPos2dMESA(GLdouble x, GLdouble y)
4417 {
4418    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4419 }
4420
4421 static void GLAPIENTRY
4422 save_WindowPos2fMESA(GLfloat x, GLfloat y)
4423 {
4424    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4425 }
4426
4427 static void GLAPIENTRY
4428 save_WindowPos2iMESA(GLint x, GLint y)
4429 {
4430    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4431 }
4432
4433 static void GLAPIENTRY
4434 save_WindowPos2sMESA(GLshort x, GLshort y)
4435 {
4436    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4437 }
4438
4439 static void GLAPIENTRY
4440 save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
4441 {
4442    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4443 }
4444
4445 static void GLAPIENTRY
4446 save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
4447 {
4448    save_WindowPos4fMESA(x, y, z, 1.0F);
4449 }
4450
4451 static void GLAPIENTRY
4452 save_WindowPos3iMESA(GLint x, GLint y, GLint z)
4453 {
4454    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4455 }
4456
4457 static void GLAPIENTRY
4458 save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
4459 {
4460    save_WindowPos4fMESA(x, y, z, 1.0F);
4461 }
4462
4463 static void GLAPIENTRY
4464 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4465 {
4466    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4467 }
4468
4469 static void GLAPIENTRY
4470 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
4471 {
4472    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4473 }
4474
4475 static void GLAPIENTRY
4476 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
4477 {
4478    save_WindowPos4fMESA(x, y, z, w);
4479 }
4480
4481 static void GLAPIENTRY
4482 save_WindowPos2dvMESA(const GLdouble * v)
4483 {
4484    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4485 }
4486
4487 static void GLAPIENTRY
4488 save_WindowPos2fvMESA(const GLfloat * v)
4489 {
4490    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4491 }
4492
4493 static void GLAPIENTRY
4494 save_WindowPos2ivMESA(const GLint * v)
4495 {
4496    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4497 }
4498
4499 static void GLAPIENTRY
4500 save_WindowPos2svMESA(const GLshort * v)
4501 {
4502    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4503 }
4504
4505 static void GLAPIENTRY
4506 save_WindowPos3dvMESA(const GLdouble * v)
4507 {
4508    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4509 }
4510
4511 static void GLAPIENTRY
4512 save_WindowPos3fvMESA(const GLfloat * v)
4513 {
4514    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4515 }
4516
4517 static void GLAPIENTRY
4518 save_WindowPos3ivMESA(const GLint * v)
4519 {
4520    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4521 }
4522
4523 static void GLAPIENTRY
4524 save_WindowPos3svMESA(const GLshort * v)
4525 {
4526    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4527 }
4528
4529 static void GLAPIENTRY
4530 save_WindowPos4dvMESA(const GLdouble * v)
4531 {
4532    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4533                         (GLfloat) v[2], (GLfloat) v[3]);
4534 }
4535
4536 static void GLAPIENTRY
4537 save_WindowPos4fvMESA(const GLfloat * v)
4538 {
4539    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4540 }
4541
4542 static void GLAPIENTRY
4543 save_WindowPos4ivMESA(const GLint * v)
4544 {
4545    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4546                         (GLfloat) v[2], (GLfloat) v[3]);
4547 }
4548
4549 static void GLAPIENTRY
4550 save_WindowPos4svMESA(const GLshort * v)
4551 {
4552    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4553 }
4554
4555
4556
4557 /* GL_ARB_multitexture */
4558 static void GLAPIENTRY
4559 save_ActiveTextureARB(GLenum target)
4560 {
4561    GET_CURRENT_CONTEXT(ctx);
4562    Node *n;
4563    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4564    n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
4565    if (n) {
4566       n[1].e = target;
4567    }
4568    if (ctx->ExecuteFlag) {
4569       CALL_ActiveTextureARB(ctx->Exec, (target));
4570    }
4571 }
4572
4573
4574 /* GL_ARB_transpose_matrix */
4575
4576 static void GLAPIENTRY
4577 save_LoadTransposeMatrixdARB(const GLdouble m[16])
4578 {
4579    GLfloat tm[16];
4580    _math_transposefd(tm, m);
4581    save_LoadMatrixf(tm);
4582 }
4583
4584
4585 static void GLAPIENTRY
4586 save_LoadTransposeMatrixfARB(const GLfloat m[16])
4587 {
4588    GLfloat tm[16];
4589    _math_transposef(tm, m);
4590    save_LoadMatrixf(tm);
4591 }
4592
4593
4594 static void GLAPIENTRY
4595 save_MultTransposeMatrixdARB(const GLdouble m[16])
4596 {
4597    GLfloat tm[16];
4598    _math_transposefd(tm, m);
4599    save_MultMatrixf(tm);
4600 }
4601
4602
4603 static void GLAPIENTRY
4604 save_MultTransposeMatrixfARB(const GLfloat m[16])
4605 {
4606    GLfloat tm[16];
4607    _math_transposef(tm, m);
4608    save_MultMatrixf(tm);
4609 }
4610
4611 static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func)
4612 {
4613    GET_CURRENT_CONTEXT(ctx);
4614    GLvoid *image;
4615
4616    if (!data)
4617       return NULL;
4618
4619    image = malloc(size);
4620    if (!image) {
4621       _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
4622       return NULL;
4623    }
4624    memcpy(image, data, size);
4625
4626    return image;
4627 }
4628
4629
4630 /* GL_ARB_texture_compression */
4631 static void GLAPIENTRY
4632 save_CompressedTexImage1DARB(GLenum target, GLint level,
4633                              GLenum internalFormat, GLsizei width,
4634                              GLint border, GLsizei imageSize,
4635                              const GLvoid * data)
4636 {
4637    GET_CURRENT_CONTEXT(ctx);
4638    if (target == GL_PROXY_TEXTURE_1D) {
4639       /* don't compile, execute immediately */
4640       CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat,
4641                                                width, border, imageSize,
4642                                                data));
4643    }
4644    else {
4645       Node *n;
4646       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4647
4648       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7);
4649       if (n) {
4650          n[1].e = target;
4651          n[2].i = level;
4652          n[3].e = internalFormat;
4653          n[4].i = (GLint) width;
4654          n[5].i = border;
4655          n[6].i = imageSize;
4656          n[7].data = copy_data(data, imageSize, "glCompressedTexImage1DARB");
4657       }
4658       if (ctx->ExecuteFlag) {
4659          CALL_CompressedTexImage1DARB(ctx->Exec,
4660                                       (target, level, internalFormat, width,
4661                                        border, imageSize, data));
4662       }
4663    }
4664 }
4665
4666
4667 static void GLAPIENTRY
4668 save_CompressedTexImage2DARB(GLenum target, GLint level,
4669                              GLenum internalFormat, GLsizei width,
4670                              GLsizei height, GLint border, GLsizei imageSize,
4671                              const GLvoid * data)
4672 {
4673    GET_CURRENT_CONTEXT(ctx);
4674    if (target == GL_PROXY_TEXTURE_2D) {
4675       /* don't compile, execute immediately */
4676       CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat,
4677                                                width, height, border,
4678                                                imageSize, data));
4679    }
4680    else {
4681       Node *n;
4682       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4683
4684       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8);
4685       if (n) {
4686          n[1].e = target;
4687          n[2].i = level;
4688          n[3].e = internalFormat;
4689          n[4].i = (GLint) width;
4690          n[5].i = (GLint) height;
4691          n[6].i = border;
4692          n[7].i = imageSize;
4693          n[8].data = copy_data(data, imageSize, "glCompressedTexImage2DARB");
4694       }
4695       if (ctx->ExecuteFlag) {
4696          CALL_CompressedTexImage2DARB(ctx->Exec,
4697                                       (target, level, internalFormat, width,
4698                                        height, border, imageSize, data));
4699       }
4700    }
4701 }
4702
4703
4704 static void GLAPIENTRY
4705 save_CompressedTexImage3DARB(GLenum target, GLint level,
4706                              GLenum internalFormat, GLsizei width,
4707                              GLsizei height, GLsizei depth, GLint border,
4708                              GLsizei imageSize, const GLvoid * data)
4709 {
4710    GET_CURRENT_CONTEXT(ctx);
4711    if (target == GL_PROXY_TEXTURE_3D) {
4712       /* don't compile, execute immediately */
4713       CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat,
4714                                                width, height, depth, border,
4715                                                imageSize, data));
4716    }
4717    else {
4718       Node *n;
4719       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4720
4721       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9);
4722       if (n) {
4723          n[1].e = target;
4724          n[2].i = level;
4725          n[3].e = internalFormat;
4726          n[4].i = (GLint) width;
4727          n[5].i = (GLint) height;
4728          n[6].i = (GLint) depth;
4729          n[7].i = border;
4730          n[8].i = imageSize;
4731          n[9].data = copy_data(data, imageSize, "glCompressedTexImage3DARB");
4732       }
4733       if (ctx->ExecuteFlag) {
4734          CALL_CompressedTexImage3DARB(ctx->Exec,
4735                                       (target, level, internalFormat, width,
4736                                        height, depth, border, imageSize,
4737                                        data));
4738       }
4739    }
4740 }
4741
4742
4743 static void GLAPIENTRY
4744 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
4745                                 GLsizei width, GLenum format,
4746                                 GLsizei imageSize, const GLvoid * data)
4747 {
4748    Node *n;
4749    GET_CURRENT_CONTEXT(ctx);
4750    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4751
4752    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7);
4753    if (n) {
4754       n[1].e = target;
4755       n[2].i = level;
4756       n[3].i = xoffset;
4757       n[4].i = (GLint) width;
4758       n[5].e = format;
4759       n[6].i = imageSize;
4760       n[7].data = copy_data(data, imageSize, "glCompressedTexSubImage1DARB");
4761    }
4762    if (ctx->ExecuteFlag) {
4763       CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset,
4764                                                   width, format, imageSize,
4765                                                   data));
4766    }
4767 }
4768
4769
4770 static void GLAPIENTRY
4771 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
4772                                 GLint yoffset, GLsizei width, GLsizei height,
4773                                 GLenum format, GLsizei imageSize,
4774                                 const GLvoid * data)
4775 {
4776    Node *n;
4777    GET_CURRENT_CONTEXT(ctx);
4778    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4779
4780    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
4781    if (n) {
4782       n[1].e = target;
4783       n[2].i = level;
4784       n[3].i = xoffset;
4785       n[4].i = yoffset;
4786       n[5].i = (GLint) width;
4787       n[6].i = (GLint) height;
4788       n[7].e = format;
4789       n[8].i = imageSize;
4790       n[9].data = copy_data(data, imageSize, "glCompressedTexSubImage2DARB");
4791    }
4792    if (ctx->ExecuteFlag) {
4793       CALL_CompressedTexSubImage2DARB(ctx->Exec,
4794                                       (target, level, xoffset, yoffset, width,
4795                                        height, format, imageSize, data));
4796    }
4797 }
4798
4799
4800 static void GLAPIENTRY
4801 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
4802                                 GLint yoffset, GLint zoffset, GLsizei width,
4803                                 GLsizei height, GLsizei depth, GLenum format,
4804                                 GLsizei imageSize, const GLvoid * data)
4805 {
4806    Node *n;
4807    GET_CURRENT_CONTEXT(ctx);
4808    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4809
4810    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11);
4811    if (n) {
4812       n[1].e = target;
4813       n[2].i = level;
4814       n[3].i = xoffset;
4815       n[4].i = yoffset;
4816       n[5].i = zoffset;
4817       n[6].i = (GLint) width;
4818       n[7].i = (GLint) height;
4819       n[8].i = (GLint) depth;
4820       n[9].e = format;
4821       n[10].i = imageSize;
4822       n[11].data = copy_data(data, imageSize, "glCompressedTexSubImage3DARB");
4823    }
4824    if (ctx->ExecuteFlag) {
4825       CALL_CompressedTexSubImage3DARB(ctx->Exec,
4826                                       (target, level, xoffset, yoffset,
4827                                        zoffset, width, height, depth, format,
4828                                        imageSize, data));
4829    }
4830 }
4831
4832
4833 /* GL_ARB_multisample */
4834 static void GLAPIENTRY
4835 save_SampleCoverageARB(GLclampf value, GLboolean invert)
4836 {
4837    GET_CURRENT_CONTEXT(ctx);
4838    Node *n;
4839    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4840    n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
4841    if (n) {
4842       n[1].f = value;
4843       n[2].b = invert;
4844    }
4845    if (ctx->ExecuteFlag) {
4846       CALL_SampleCoverageARB(ctx->Exec, (value, invert));
4847    }
4848 }
4849
4850
4851 /*
4852  * GL_NV_vertex_program
4853  */
4854 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
4855 static void GLAPIENTRY
4856 save_BindProgramNV(GLenum target, GLuint id)
4857 {
4858    GET_CURRENT_CONTEXT(ctx);
4859    Node *n;
4860    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4861    n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2);
4862    if (n) {
4863       n[1].e = target;
4864       n[2].ui = id;
4865    }
4866    if (ctx->ExecuteFlag) {
4867       CALL_BindProgramNV(ctx->Exec, (target, id));
4868    }
4869 }
4870
4871 static void GLAPIENTRY
4872 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
4873                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4874 {
4875    GET_CURRENT_CONTEXT(ctx);
4876    Node *n;
4877    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4878    n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4879    if (n) {
4880       n[1].e = target;
4881       n[2].ui = index;
4882       n[3].f = x;
4883       n[4].f = y;
4884       n[5].f = z;
4885       n[6].f = w;
4886    }
4887    if (ctx->ExecuteFlag) {
4888       CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
4889    }
4890 }
4891
4892
4893 static void GLAPIENTRY
4894 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
4895                                const GLfloat *params)
4896 {
4897    save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
4898                                  params[2], params[3]);
4899 }
4900
4901
4902 static void GLAPIENTRY
4903 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
4904                                 const GLfloat * params)
4905 {
4906    GET_CURRENT_CONTEXT(ctx);
4907    Node *n;
4908    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4909
4910    if (count > 0) {
4911       GLint i;
4912       const GLfloat * p = params;
4913
4914       for (i = 0 ; i < count ; i++) {
4915          n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
4916          if (n) {
4917             n[1].e = target;
4918             n[2].ui = index;
4919             n[3].f = p[0];
4920             n[4].f = p[1];
4921             n[5].f = p[2];
4922             n[6].f = p[3];
4923             p += 4;
4924          }
4925       }
4926    }
4927
4928    if (ctx->ExecuteFlag) {
4929       CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
4930    }
4931 }
4932
4933
4934 static void GLAPIENTRY
4935 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
4936                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4937 {
4938    save_ProgramEnvParameter4fARB(target, index,
4939                                  (GLfloat) x,
4940                                  (GLfloat) y, (GLfloat) z, (GLfloat) w);
4941 }
4942
4943
4944 static void GLAPIENTRY
4945 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
4946                                const GLdouble *params)
4947 {
4948    save_ProgramEnvParameter4fARB(target, index,
4949                                  (GLfloat) params[0],
4950                                  (GLfloat) params[1],
4951                                  (GLfloat) params[2], (GLfloat) params[3]);
4952 }
4953
4954 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */
4955
4956 #if FEATURE_NV_vertex_program
4957 static void GLAPIENTRY
4958 save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
4959 {
4960    GET_CURRENT_CONTEXT(ctx);
4961    Node *n;
4962    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4963    n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6);
4964    if (n) {
4965       n[1].e = target;
4966       n[2].ui = id;
4967       n[3].f = params[0];
4968       n[4].f = params[1];
4969       n[5].f = params[2];
4970       n[6].f = params[3];
4971    }
4972    if (ctx->ExecuteFlag) {
4973       CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
4974    }
4975 }
4976
4977
4978 static void GLAPIENTRY
4979 save_ProgramParameters4dvNV(GLenum target, GLuint index,
4980                             GLsizei num, const GLdouble *params)
4981 {
4982    GLint i;
4983    for (i = 0; i < num; i++) {
4984       save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i);
4985    }
4986 }
4987
4988
4989 static void GLAPIENTRY
4990 save_ProgramParameters4fvNV(GLenum target, GLuint index,
4991                             GLsizei num, const GLfloat *params)
4992 {
4993    GLint i;
4994    for (i = 0; i < num; i++) {
4995       save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i);
4996    }
4997 }
4998
4999
5000 static void GLAPIENTRY
5001 save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
5002                    const GLubyte * program)
5003 {
5004    GET_CURRENT_CONTEXT(ctx);
5005    Node *n;
5006
5007    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5008
5009    n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
5010    if (n) {
5011       GLubyte *programCopy = (GLubyte *) malloc(len);
5012       if (!programCopy) {
5013          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
5014          return;
5015       }
5016       memcpy(programCopy, program, len);
5017       n[1].e = target;
5018       n[2].ui = id;
5019       n[3].i = len;
5020       n[4].data = programCopy;
5021    }
5022    if (ctx->ExecuteFlag) {
5023       CALL_LoadProgramNV(ctx->Exec, (target, id, len, program));
5024    }
5025 }
5026
5027
5028 static void GLAPIENTRY
5029 save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
5030 {
5031    GET_CURRENT_CONTEXT(ctx);
5032    Node *n;
5033
5034    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5035
5036    n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2);
5037    if (n) {
5038       GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint));
5039       if (!idCopy) {
5040          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
5041          return;
5042       }
5043       memcpy(idCopy, ids, num * sizeof(GLuint));
5044       n[1].i = num;
5045       n[2].data = idCopy;
5046    }
5047    if (ctx->ExecuteFlag) {
5048       CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids));
5049    }
5050 }
5051
5052
5053 static void GLAPIENTRY
5054 save_TrackMatrixNV(GLenum target, GLuint address,
5055                    GLenum matrix, GLenum transform)
5056 {
5057    GET_CURRENT_CONTEXT(ctx);
5058    Node *n;
5059    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5060    n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4);
5061    if (n) {
5062       n[1].e = target;
5063       n[2].ui = address;
5064       n[3].e = matrix;
5065       n[4].e = transform;
5066    }
5067    if (ctx->ExecuteFlag) {
5068       CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform));
5069    }
5070 }
5071 #endif /* FEATURE_NV_vertex_program */
5072
5073
5074 /*
5075  * GL_NV_fragment_program
5076  */
5077 #if FEATURE_NV_fragment_program
5078 static void GLAPIENTRY
5079 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
5080                                 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5081 {
5082    GET_CURRENT_CONTEXT(ctx);
5083    Node *n;
5084    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5085    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5086    if (n) {
5087       n[1].e = target;
5088       n[2].ui = index;
5089       n[3].f = x;
5090       n[4].f = y;
5091       n[5].f = z;
5092       n[6].f = w;
5093    }
5094    if (ctx->ExecuteFlag) {
5095       CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5096    }
5097 }
5098
5099
5100 static void GLAPIENTRY
5101 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
5102                                  const GLfloat *params)
5103 {
5104    GET_CURRENT_CONTEXT(ctx);
5105    Node *n;
5106    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5107    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5108    if (n) {
5109       n[1].e = target;
5110       n[2].ui = index;
5111       n[3].f = params[0];
5112       n[4].f = params[1];
5113       n[5].f = params[2];
5114       n[6].f = params[3];
5115    }
5116    if (ctx->ExecuteFlag) {
5117       CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
5118    }
5119 }
5120
5121
5122 static void GLAPIENTRY
5123 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5124                                   const GLfloat *params)
5125 {
5126    GET_CURRENT_CONTEXT(ctx);
5127    Node *n;
5128    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5129
5130    if (count > 0) {
5131       GLint i;
5132       const GLfloat * p = params;
5133
5134       for (i = 0 ; i < count ; i++) {
5135          n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5136          if (n) {
5137             n[1].e = target;
5138             n[2].ui = index;
5139             n[3].f = p[0];
5140             n[4].f = p[1];
5141             n[5].f = p[2];
5142             n[6].f = p[3];
5143             p += 4;
5144          }
5145       }
5146    }
5147
5148    if (ctx->ExecuteFlag) {
5149       CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
5150    }
5151 }
5152
5153
5154 static void GLAPIENTRY
5155 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
5156                                 GLdouble x, GLdouble y,
5157                                 GLdouble z, GLdouble w)
5158 {
5159    GET_CURRENT_CONTEXT(ctx);
5160    Node *n;
5161    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5162    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5163    if (n) {
5164       n[1].e = target;
5165       n[2].ui = index;
5166       n[3].f = (GLfloat) x;
5167       n[4].f = (GLfloat) y;
5168       n[5].f = (GLfloat) z;
5169       n[6].f = (GLfloat) w;
5170    }
5171    if (ctx->ExecuteFlag) {
5172       CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
5173    }
5174 }
5175
5176
5177 static void GLAPIENTRY
5178 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
5179                                  const GLdouble *params)
5180 {
5181    GET_CURRENT_CONTEXT(ctx);
5182    Node *n;
5183    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5184    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5185    if (n) {
5186       n[1].e = target;
5187       n[2].ui = index;
5188       n[3].f = (GLfloat) params[0];
5189       n[4].f = (GLfloat) params[1];
5190       n[5].f = (GLfloat) params[2];
5191       n[6].f = (GLfloat) params[3];
5192    }
5193    if (ctx->ExecuteFlag) {
5194       CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
5195    }
5196 }
5197
5198 static void GLAPIENTRY
5199 save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
5200                                GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5201 {
5202    GET_CURRENT_CONTEXT(ctx);
5203    Node *n;
5204
5205    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5206
5207    n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
5208    if (n) {
5209       GLubyte *nameCopy = (GLubyte *) malloc(len);
5210       if (!nameCopy) {
5211          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
5212          return;
5213       }
5214       memcpy(nameCopy, name, len);
5215       n[1].ui = id;
5216       n[2].i = len;
5217       n[3].data = nameCopy;
5218       n[4].f = x;
5219       n[5].f = y;
5220       n[6].f = z;
5221       n[7].f = w;
5222    }
5223    if (ctx->ExecuteFlag) {
5224       CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w));
5225    }
5226 }
5227
5228
5229 static void GLAPIENTRY
5230 save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name,
5231                                 const float v[])
5232 {
5233    save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
5234 }
5235
5236
5237 static void GLAPIENTRY
5238 save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name,
5239                                GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5240 {
5241    save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
5242                                   (GLfloat) z, (GLfloat) w);
5243 }
5244
5245
5246 static void GLAPIENTRY
5247 save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name,
5248                                 const double v[])
5249 {
5250    save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
5251                                   (GLfloat) v[1], (GLfloat) v[2],
5252                                   (GLfloat) v[3]);
5253 }
5254
5255 #endif /* FEATURE_NV_fragment_program */
5256
5257
5258
5259 /* GL_EXT_stencil_two_side */
5260 static void GLAPIENTRY
5261 save_ActiveStencilFaceEXT(GLenum face)
5262 {
5263    GET_CURRENT_CONTEXT(ctx);
5264    Node *n;
5265    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5266    n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
5267    if (n) {
5268       n[1].e = face;
5269    }
5270    if (ctx->ExecuteFlag) {
5271       CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
5272    }
5273 }
5274
5275
5276 /* GL_EXT_depth_bounds_test */
5277 static void GLAPIENTRY
5278 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
5279 {
5280    GET_CURRENT_CONTEXT(ctx);
5281    Node *n;
5282    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5283    n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
5284    if (n) {
5285       n[1].f = (GLfloat) zmin;
5286       n[2].f = (GLfloat) zmax;
5287    }
5288    if (ctx->ExecuteFlag) {
5289       CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
5290    }
5291 }
5292
5293
5294
5295 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
5296
5297 static void GLAPIENTRY
5298 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
5299                       const GLvoid * string)
5300 {
5301    GET_CURRENT_CONTEXT(ctx);
5302    Node *n;
5303
5304    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5305
5306    n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
5307    if (n) {
5308       GLubyte *programCopy = (GLubyte *) malloc(len);
5309       if (!programCopy) {
5310          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5311          return;
5312       }
5313       memcpy(programCopy, string, len);
5314       n[1].e = target;
5315       n[2].e = format;
5316       n[3].i = len;
5317       n[4].data = programCopy;
5318    }
5319    if (ctx->ExecuteFlag) {
5320       CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
5321    }
5322 }
5323
5324 #endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
5325
5326
5327 #if FEATURE_queryobj
5328
5329 static void GLAPIENTRY
5330 save_BeginQueryARB(GLenum target, GLuint id)
5331 {
5332    GET_CURRENT_CONTEXT(ctx);
5333    Node *n;
5334    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5335    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
5336    if (n) {
5337       n[1].e = target;
5338       n[2].ui = id;
5339    }
5340    if (ctx->ExecuteFlag) {
5341       CALL_BeginQueryARB(ctx->Exec, (target, id));
5342    }
5343 }
5344
5345 static void GLAPIENTRY
5346 save_EndQueryARB(GLenum target)
5347 {
5348    GET_CURRENT_CONTEXT(ctx);
5349    Node *n;
5350    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5351    n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
5352    if (n) {
5353       n[1].e = target;
5354    }
5355    if (ctx->ExecuteFlag) {
5356       CALL_EndQueryARB(ctx->Exec, (target));
5357    }
5358 }
5359
5360 static void GLAPIENTRY
5361 save_QueryCounter(GLuint id, GLenum target)
5362 {
5363    GET_CURRENT_CONTEXT(ctx);
5364    Node *n;
5365    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5366    n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2);
5367    if (n) {
5368       n[1].ui = id;
5369       n[2].e = target;
5370    }
5371    if (ctx->ExecuteFlag) {
5372       CALL_QueryCounter(ctx->Exec, (id, target));
5373    }
5374 }
5375
5376 static void GLAPIENTRY
5377 save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
5378 {
5379    GET_CURRENT_CONTEXT(ctx);
5380    Node *n;
5381    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5382    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3);
5383    if (n) {
5384       n[1].e = target;
5385       n[2].ui = index;
5386       n[3].ui = id;
5387    }
5388    if (ctx->ExecuteFlag) {
5389       CALL_BeginQueryIndexed(ctx->Exec, (target, index, id));
5390    }
5391 }
5392
5393 static void GLAPIENTRY
5394 save_EndQueryIndexed(GLenum target, GLuint index)
5395 {
5396    GET_CURRENT_CONTEXT(ctx);
5397    Node *n;
5398    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5399    n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2);
5400    if (n) {
5401       n[1].e = target;
5402       n[2].ui = index;
5403    }
5404    if (ctx->ExecuteFlag) {
5405       CALL_EndQueryIndexed(ctx->Exec, (target, index));
5406    }
5407 }
5408
5409 #endif /* FEATURE_queryobj */
5410
5411
5412 static void GLAPIENTRY
5413 save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
5414 {
5415    GET_CURRENT_CONTEXT(ctx);
5416    Node *n;
5417    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5418    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
5419    if (n) {
5420       GLint i;
5421       n[1].i = count;
5422       if (count > MAX_DRAW_BUFFERS)
5423          count = MAX_DRAW_BUFFERS;
5424       for (i = 0; i < count; i++) {
5425          n[2 + i].e = buffers[i];
5426       }
5427    }
5428    if (ctx->ExecuteFlag) {
5429       CALL_DrawBuffersARB(ctx->Exec, (count, buffers));
5430    }
5431 }
5432
5433 static void GLAPIENTRY
5434 save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param)
5435 {
5436    GET_CURRENT_CONTEXT(ctx);
5437    Node *n;
5438
5439    n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5);
5440    if (n) {
5441       n[1].ui = pname;
5442       n[2].f = param[0];
5443       n[3].f = param[1];
5444       n[4].f = param[2];
5445       n[5].f = param[3];
5446    }
5447    if (ctx->ExecuteFlag) {
5448       CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param));
5449    }
5450 }
5451
5452 static void GLAPIENTRY
5453 save_TexBumpParameterivATI(GLenum pname, const GLint *param)
5454 {
5455    GLfloat p[4];
5456    p[0] = INT_TO_FLOAT(param[0]);
5457    p[1] = INT_TO_FLOAT(param[1]);
5458    p[2] = INT_TO_FLOAT(param[2]);
5459    p[3] = INT_TO_FLOAT(param[3]);
5460    save_TexBumpParameterfvATI(pname, p);
5461 }
5462
5463 #if FEATURE_ATI_fragment_shader
5464 static void GLAPIENTRY
5465 save_BindFragmentShaderATI(GLuint id)
5466 {
5467    GET_CURRENT_CONTEXT(ctx);
5468    Node *n;
5469
5470    n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
5471    if (n) {
5472       n[1].ui = id;
5473    }
5474    if (ctx->ExecuteFlag) {
5475       CALL_BindFragmentShaderATI(ctx->Exec, (id));
5476    }
5477 }
5478
5479 static void GLAPIENTRY
5480 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
5481 {
5482    GET_CURRENT_CONTEXT(ctx);
5483    Node *n;
5484
5485    n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
5486    if (n) {
5487       n[1].ui = dst;
5488       n[2].f = value[0];
5489       n[3].f = value[1];
5490       n[4].f = value[2];
5491       n[5].f = value[3];
5492    }
5493    if (ctx->ExecuteFlag) {
5494       CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
5495    }
5496 }
5497 #endif
5498
5499 static void GLAPIENTRY
5500 save_Attr1fNV(GLenum attr, GLfloat x)
5501 {
5502    GET_CURRENT_CONTEXT(ctx);
5503    Node *n;
5504    SAVE_FLUSH_VERTICES(ctx);
5505    n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2);
5506    if (n) {
5507       n[1].e = attr;
5508       n[2].f = x;
5509    }
5510
5511    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5512    ctx->ListState.ActiveAttribSize[attr] = 1;
5513    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
5514
5515    if (ctx->ExecuteFlag) {
5516       CALL_VertexAttrib1fNV(ctx->Exec, (attr, x));
5517    }
5518 }
5519
5520 static void GLAPIENTRY
5521 save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
5522 {
5523    GET_CURRENT_CONTEXT(ctx);
5524    Node *n;
5525    SAVE_FLUSH_VERTICES(ctx);
5526    n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3);
5527    if (n) {
5528       n[1].e = attr;
5529       n[2].f = x;
5530       n[3].f = y;
5531    }
5532
5533    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5534    ctx->ListState.ActiveAttribSize[attr] = 2;
5535    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
5536
5537    if (ctx->ExecuteFlag) {
5538       CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y));
5539    }
5540 }
5541
5542 static void GLAPIENTRY
5543 save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
5544 {
5545    GET_CURRENT_CONTEXT(ctx);
5546    Node *n;
5547    SAVE_FLUSH_VERTICES(ctx);
5548    n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4);
5549    if (n) {
5550       n[1].e = attr;
5551       n[2].f = x;
5552       n[3].f = y;
5553       n[4].f = z;
5554    }
5555
5556    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5557    ctx->ListState.ActiveAttribSize[attr] = 3;
5558    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
5559
5560    if (ctx->ExecuteFlag) {
5561       CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z));
5562    }
5563 }
5564
5565 static void GLAPIENTRY
5566 save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5567 {
5568    GET_CURRENT_CONTEXT(ctx);
5569    Node *n;
5570    SAVE_FLUSH_VERTICES(ctx);
5571    n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5);
5572    if (n) {
5573       n[1].e = attr;
5574       n[2].f = x;
5575       n[3].f = y;
5576       n[4].f = z;
5577       n[5].f = w;
5578    }
5579
5580    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5581    ctx->ListState.ActiveAttribSize[attr] = 4;
5582    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5583
5584    if (ctx->ExecuteFlag) {
5585       CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w));
5586    }
5587 }
5588
5589
5590 static void GLAPIENTRY
5591 save_Attr1fARB(GLenum attr, GLfloat x)
5592 {
5593    GET_CURRENT_CONTEXT(ctx);
5594    Node *n;
5595    SAVE_FLUSH_VERTICES(ctx);
5596    n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2);
5597    if (n) {
5598       n[1].e = attr;
5599       n[2].f = x;
5600    }
5601
5602    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5603    ctx->ListState.ActiveAttribSize[attr] = 1;
5604    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
5605
5606    if (ctx->ExecuteFlag) {
5607       CALL_VertexAttrib1fARB(ctx->Exec, (attr, x));
5608    }
5609 }
5610
5611 static void GLAPIENTRY
5612 save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
5613 {
5614    GET_CURRENT_CONTEXT(ctx);
5615    Node *n;
5616    SAVE_FLUSH_VERTICES(ctx);
5617    n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3);
5618    if (n) {
5619       n[1].e = attr;
5620       n[2].f = x;
5621       n[3].f = y;
5622    }
5623
5624    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5625    ctx->ListState.ActiveAttribSize[attr] = 2;
5626    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
5627
5628    if (ctx->ExecuteFlag) {
5629       CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y));
5630    }
5631 }
5632
5633 static void GLAPIENTRY
5634 save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
5635 {
5636    GET_CURRENT_CONTEXT(ctx);
5637    Node *n;
5638    SAVE_FLUSH_VERTICES(ctx);
5639    n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4);
5640    if (n) {
5641       n[1].e = attr;
5642       n[2].f = x;
5643       n[3].f = y;
5644       n[4].f = z;
5645    }
5646
5647    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5648    ctx->ListState.ActiveAttribSize[attr] = 3;
5649    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
5650
5651    if (ctx->ExecuteFlag) {
5652       CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z));
5653    }
5654 }
5655
5656 static void GLAPIENTRY
5657 save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5658 {
5659    GET_CURRENT_CONTEXT(ctx);
5660    Node *n;
5661    SAVE_FLUSH_VERTICES(ctx);
5662    n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5);
5663    if (n) {
5664       n[1].e = attr;
5665       n[2].f = x;
5666       n[3].f = y;
5667       n[4].f = z;
5668       n[5].f = w;
5669    }
5670
5671    ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
5672    ctx->ListState.ActiveAttribSize[attr] = 4;
5673    ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
5674
5675    if (ctx->ExecuteFlag) {
5676       CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w));
5677    }
5678 }
5679
5680
5681 static void GLAPIENTRY
5682 save_EvalCoord1f(GLfloat x)
5683 {
5684    GET_CURRENT_CONTEXT(ctx);
5685    Node *n;
5686    SAVE_FLUSH_VERTICES(ctx);
5687    n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
5688    if (n) {
5689       n[1].f = x;
5690    }
5691    if (ctx->ExecuteFlag) {
5692       CALL_EvalCoord1f(ctx->Exec, (x));
5693    }
5694 }
5695
5696 static void GLAPIENTRY
5697 save_EvalCoord1fv(const GLfloat * v)
5698 {
5699    save_EvalCoord1f(v[0]);
5700 }
5701
5702 static void GLAPIENTRY
5703 save_EvalCoord2f(GLfloat x, GLfloat y)
5704 {
5705    GET_CURRENT_CONTEXT(ctx);
5706    Node *n;
5707    SAVE_FLUSH_VERTICES(ctx);
5708    n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
5709    if (n) {
5710       n[1].f = x;
5711       n[2].f = y;
5712    }
5713    if (ctx->ExecuteFlag) {
5714       CALL_EvalCoord2f(ctx->Exec, (x, y));
5715    }
5716 }
5717
5718 static void GLAPIENTRY
5719 save_EvalCoord2fv(const GLfloat * v)
5720 {
5721    save_EvalCoord2f(v[0], v[1]);
5722 }
5723
5724
5725 static void GLAPIENTRY
5726 save_EvalPoint1(GLint x)
5727 {
5728    GET_CURRENT_CONTEXT(ctx);
5729    Node *n;
5730    SAVE_FLUSH_VERTICES(ctx);
5731    n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
5732    if (n) {
5733       n[1].i = x;
5734    }
5735    if (ctx->ExecuteFlag) {
5736       CALL_EvalPoint1(ctx->Exec, (x));
5737    }
5738 }
5739
5740 static void GLAPIENTRY
5741 save_EvalPoint2(GLint x, GLint y)
5742 {
5743    GET_CURRENT_CONTEXT(ctx);
5744    Node *n;
5745    SAVE_FLUSH_VERTICES(ctx);
5746    n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
5747    if (n) {
5748       n[1].i = x;
5749       n[2].i = y;
5750    }
5751    if (ctx->ExecuteFlag) {
5752       CALL_EvalPoint2(ctx->Exec, (x, y));
5753    }
5754 }
5755
5756 static void GLAPIENTRY
5757 save_Indexf(GLfloat x)
5758 {
5759    save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x);
5760 }
5761
5762 static void GLAPIENTRY
5763 save_Indexfv(const GLfloat * v)
5764 {
5765    save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]);
5766 }
5767
5768 static void GLAPIENTRY
5769 save_EdgeFlag(GLboolean x)
5770 {
5771    save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0f : 0.0f);
5772 }
5773
5774
5775 /**
5776  * Compare 'count' elements of vectors 'a' and 'b'.
5777  * \return GL_TRUE if equal, GL_FALSE if different.
5778  */
5779 static inline GLboolean
5780 compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
5781 {
5782    return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5783 }
5784
5785
5786 /**
5787  * This glMaterial function is used for glMaterial calls that are outside
5788  * a glBegin/End pair.  For glMaterial inside glBegin/End, see the VBO code.
5789  */
5790 static void GLAPIENTRY
5791 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5792 {
5793    GET_CURRENT_CONTEXT(ctx);
5794    Node *n;
5795    int args, i;
5796    GLuint bitmask;
5797
5798    switch (face) {
5799    case GL_BACK:
5800    case GL_FRONT:
5801    case GL_FRONT_AND_BACK:
5802       break;
5803    default:
5804       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
5805       return;
5806    }
5807
5808    switch (pname) {
5809    case GL_EMISSION:
5810    case GL_AMBIENT:
5811    case GL_DIFFUSE:
5812    case GL_SPECULAR:
5813    case GL_AMBIENT_AND_DIFFUSE:
5814       args = 4;
5815       break;
5816    case GL_SHININESS:
5817       args = 1;
5818       break;
5819    case GL_COLOR_INDEXES:
5820       args = 3;
5821       break;
5822    default:
5823       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
5824       return;
5825    }
5826    
5827    if (ctx->ExecuteFlag) {
5828       CALL_Materialfv(ctx->Exec, (face, pname, param));
5829    }
5830
5831    bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5832
5833    /* Try to eliminate redundant statechanges.  Because it is legal to
5834     * call glMaterial even inside begin/end calls, don't need to worry
5835     * about ctx->Driver.CurrentSavePrimitive here.
5836     */
5837    for (i = 0; i < MAT_ATTRIB_MAX; i++) {
5838       if (bitmask & (1 << i)) {
5839          if (ctx->ListState.ActiveMaterialSize[i] == args &&
5840              compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
5841             /* no change in material value */
5842             bitmask &= ~(1 << i);
5843          }
5844          else {
5845             ctx->ListState.ActiveMaterialSize[i] = args;
5846             COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5847          }
5848       }
5849    }
5850
5851    /* If this call has no effect, return early */
5852    if (bitmask == 0)
5853       return;
5854
5855    SAVE_FLUSH_VERTICES(ctx);
5856
5857    n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
5858    if (n) {
5859       n[1].e = face;
5860       n[2].e = pname;
5861       for (i = 0; i < args; i++)
5862          n[3 + i].f = param[i];
5863    }
5864 }
5865
5866 static void GLAPIENTRY
5867 save_Begin(GLenum mode)
5868 {
5869    GET_CURRENT_CONTEXT(ctx);
5870    Node *n;
5871    GLboolean error = GL_FALSE;
5872
5873    if (mode > GL_POLYGON) {
5874       _mesa_error(ctx, GL_INVALID_ENUM, "glBegin(mode=%x)", mode);
5875       error = GL_TRUE;
5876    }
5877    if (ctx->ExecuteFlag) {
5878       if (!_mesa_valid_prim_mode(ctx, mode, "glBegin")) {
5879          error = GL_TRUE;
5880       }
5881    }
5882
5883    else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
5884       /* Typically the first begin.  This may raise an error on
5885        * playback, depending on whether CallList is issued from inside
5886        * a begin/end or not.
5887        */
5888       ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
5889    }
5890    else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
5891       ctx->Driver.CurrentSavePrimitive = mode;
5892    }
5893    else {
5894       _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin");
5895       error = GL_TRUE;
5896    }
5897
5898    if (!error) {
5899       /* Give the driver an opportunity to hook in an optimized
5900        * display list compiler.
5901        */
5902       if (ctx->Driver.NotifySaveBegin(ctx, mode))
5903          return;
5904
5905       SAVE_FLUSH_VERTICES(ctx);
5906       n = alloc_instruction(ctx, OPCODE_BEGIN, 1);
5907       if (n) {
5908          n[1].e = mode;
5909       }
5910    }
5911
5912    if (ctx->ExecuteFlag) {
5913       CALL_Begin(ctx->Exec, (mode));
5914    }
5915 }
5916
5917 static void GLAPIENTRY
5918 save_End(void)
5919 {
5920    GET_CURRENT_CONTEXT(ctx);
5921    SAVE_FLUSH_VERTICES(ctx);
5922    (void) alloc_instruction(ctx, OPCODE_END, 0);
5923    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
5924    if (ctx->ExecuteFlag) {
5925       CALL_End(ctx->Exec, ());
5926    }
5927 }
5928
5929 static void GLAPIENTRY
5930 save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d)
5931 {
5932    GET_CURRENT_CONTEXT(ctx);
5933    Node *n;
5934    SAVE_FLUSH_VERTICES(ctx);
5935    n = alloc_instruction(ctx, OPCODE_RECTF, 4);
5936    if (n) {
5937       n[1].f = a;
5938       n[2].f = b;
5939       n[3].f = c;
5940       n[4].f = d;
5941    }
5942    if (ctx->ExecuteFlag) {
5943       CALL_Rectf(ctx->Exec, (a, b, c, d));
5944    }
5945 }
5946
5947
5948 static void GLAPIENTRY
5949 save_Vertex2f(GLfloat x, GLfloat y)
5950 {
5951    save_Attr2fNV(VERT_ATTRIB_POS, x, y);
5952 }
5953
5954 static void GLAPIENTRY
5955 save_Vertex2fv(const GLfloat * v)
5956 {
5957    save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]);
5958 }
5959
5960 static void GLAPIENTRY
5961 save_Vertex3f(GLfloat x, GLfloat y, GLfloat z)
5962 {
5963    save_Attr3fNV(VERT_ATTRIB_POS, x, y, z);
5964 }
5965
5966 static void GLAPIENTRY
5967 save_Vertex3fv(const GLfloat * v)
5968 {
5969    save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]);
5970 }
5971
5972 static void GLAPIENTRY
5973 save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5974 {
5975    save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w);
5976 }
5977
5978 static void GLAPIENTRY
5979 save_Vertex4fv(const GLfloat * v)
5980 {
5981    save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]);
5982 }
5983
5984 static void GLAPIENTRY
5985 save_TexCoord1f(GLfloat x)
5986 {
5987    save_Attr1fNV(VERT_ATTRIB_TEX0, x);
5988 }
5989
5990 static void GLAPIENTRY
5991 save_TexCoord1fv(const GLfloat * v)
5992 {
5993    save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]);
5994 }
5995
5996 static void GLAPIENTRY
5997 save_TexCoord2f(GLfloat x, GLfloat y)
5998 {
5999    save_Attr2fNV(VERT_ATTRIB_TEX0, x, y);
6000 }
6001
6002 static void GLAPIENTRY
6003 save_TexCoord2fv(const GLfloat * v)
6004 {
6005    save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]);
6006 }
6007
6008 static void GLAPIENTRY
6009 save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z)
6010 {
6011    save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z);
6012 }
6013
6014 static void GLAPIENTRY
6015 save_TexCoord3fv(const GLfloat * v)
6016 {
6017    save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]);
6018 }
6019
6020 static void GLAPIENTRY
6021 save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6022 {
6023    save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w);
6024 }
6025
6026 static void GLAPIENTRY
6027 save_TexCoord4fv(const GLfloat * v)
6028 {
6029    save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]);
6030 }
6031
6032 static void GLAPIENTRY
6033 save_Normal3f(GLfloat x, GLfloat y, GLfloat z)
6034 {
6035    save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z);
6036 }
6037
6038 static void GLAPIENTRY
6039 save_Normal3fv(const GLfloat * v)
6040 {
6041    save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]);
6042 }
6043
6044 static void GLAPIENTRY
6045 save_FogCoordfEXT(GLfloat x)
6046 {
6047    save_Attr1fNV(VERT_ATTRIB_FOG, x);
6048 }
6049
6050 static void GLAPIENTRY
6051 save_FogCoordfvEXT(const GLfloat * v)
6052 {
6053    save_Attr1fNV(VERT_ATTRIB_FOG, v[0]);
6054 }
6055
6056 static void GLAPIENTRY
6057 save_Color3f(GLfloat x, GLfloat y, GLfloat z)
6058 {
6059    save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z);
6060 }
6061
6062 static void GLAPIENTRY
6063 save_Color3fv(const GLfloat * v)
6064 {
6065    save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]);
6066 }
6067
6068 static void GLAPIENTRY
6069 save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6070 {
6071    save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w);
6072 }
6073
6074 static void GLAPIENTRY
6075 save_Color4fv(const GLfloat * v)
6076 {
6077    save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]);
6078 }
6079
6080 static void GLAPIENTRY
6081 save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z)
6082 {
6083    save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z);
6084 }
6085
6086 static void GLAPIENTRY
6087 save_SecondaryColor3fvEXT(const GLfloat * v)
6088 {
6089    save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]);
6090 }
6091
6092
6093 /* Just call the respective ATTR for texcoord
6094  */
6095 static void GLAPIENTRY
6096 save_MultiTexCoord1f(GLenum target, GLfloat x)
6097 {
6098    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6099    save_Attr1fNV(attr, x);
6100 }
6101
6102 static void GLAPIENTRY
6103 save_MultiTexCoord1fv(GLenum target, const GLfloat * v)
6104 {
6105    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6106    save_Attr1fNV(attr, v[0]);
6107 }
6108
6109 static void GLAPIENTRY
6110 save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y)
6111 {
6112    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6113    save_Attr2fNV(attr, x, y);
6114 }
6115
6116 static void GLAPIENTRY
6117 save_MultiTexCoord2fv(GLenum target, const GLfloat * v)
6118 {
6119    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6120    save_Attr2fNV(attr, v[0], v[1]);
6121 }
6122
6123 static void GLAPIENTRY
6124 save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z)
6125 {
6126    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6127    save_Attr3fNV(attr, x, y, z);
6128 }
6129
6130 static void GLAPIENTRY
6131 save_MultiTexCoord3fv(GLenum target, const GLfloat * v)
6132 {
6133    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6134    save_Attr3fNV(attr, v[0], v[1], v[2]);
6135 }
6136
6137 static void GLAPIENTRY
6138 save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y,
6139                      GLfloat z, GLfloat w)
6140 {
6141    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6142    save_Attr4fNV(attr, x, y, z, w);
6143 }
6144
6145 static void GLAPIENTRY
6146 save_MultiTexCoord4fv(GLenum target, const GLfloat * v)
6147 {
6148    GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
6149    save_Attr4fNV(attr, v[0], v[1], v[2], v[3]);
6150 }
6151
6152
6153 /**
6154  * Record a GL_INVALID_VALUE error when a invalid vertex attribute
6155  * index is found.
6156  */
6157 static void
6158 index_error(void)
6159 {
6160    GET_CURRENT_CONTEXT(ctx);
6161    _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)");
6162 }
6163
6164
6165 /* First level for NV_vertex_program:
6166  *
6167  * Check for errors at compile time?.
6168  */
6169 static void GLAPIENTRY
6170 save_VertexAttrib1fNV(GLuint index, GLfloat x)
6171 {
6172    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6173       save_Attr1fNV(index, x);
6174    else
6175       index_error();
6176 }
6177
6178 static void GLAPIENTRY
6179 save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
6180 {
6181    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6182       save_Attr1fNV(index, v[0]);
6183    else
6184       index_error();
6185 }
6186
6187 static void GLAPIENTRY
6188 save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
6189 {
6190    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6191       save_Attr2fNV(index, x, y);
6192    else
6193       index_error();
6194 }
6195
6196 static void GLAPIENTRY
6197 save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
6198 {
6199    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6200       save_Attr2fNV(index, v[0], v[1]);
6201    else
6202       index_error();
6203 }
6204
6205 static void GLAPIENTRY
6206 save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
6207 {
6208    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6209       save_Attr3fNV(index, x, y, z);
6210    else
6211       index_error();
6212 }
6213
6214 static void GLAPIENTRY
6215 save_VertexAttrib3fvNV(GLuint index, const GLfloat * v)
6216 {
6217    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6218       save_Attr3fNV(index, v[0], v[1], v[2]);
6219    else
6220       index_error();
6221 }
6222
6223 static void GLAPIENTRY
6224 save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
6225                       GLfloat z, GLfloat w)
6226 {
6227    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6228       save_Attr4fNV(index, x, y, z, w);
6229    else
6230       index_error();
6231 }
6232
6233 static void GLAPIENTRY
6234 save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
6235 {
6236    if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
6237       save_Attr4fNV(index, v[0], v[1], v[2], v[3]);
6238    else
6239       index_error();
6240 }
6241
6242
6243
6244
6245 static void GLAPIENTRY
6246 save_VertexAttrib1fARB(GLuint index, GLfloat x)
6247 {
6248    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6249       save_Attr1fARB(index, x);
6250    else
6251       index_error();
6252 }
6253
6254 static void GLAPIENTRY
6255 save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
6256 {
6257    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6258       save_Attr1fARB(index, v[0]);
6259    else
6260       index_error();
6261 }
6262
6263 static void GLAPIENTRY
6264 save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
6265 {
6266    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6267       save_Attr2fARB(index, x, y);
6268    else
6269       index_error();
6270 }
6271
6272 static void GLAPIENTRY
6273 save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
6274 {
6275    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6276       save_Attr2fARB(index, v[0], v[1]);
6277    else
6278       index_error();
6279 }
6280
6281 static void GLAPIENTRY
6282 save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
6283 {
6284    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6285       save_Attr3fARB(index, x, y, z);
6286    else
6287       index_error();
6288 }
6289
6290 static void GLAPIENTRY
6291 save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
6292 {
6293    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6294       save_Attr3fARB(index, v[0], v[1], v[2]);
6295    else
6296       index_error();
6297 }
6298
6299 static void GLAPIENTRY
6300 save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
6301                        GLfloat w)
6302 {
6303    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6304       save_Attr4fARB(index, x, y, z, w);
6305    else
6306       index_error();
6307 }
6308
6309 static void GLAPIENTRY
6310 save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
6311 {
6312    if (index < MAX_VERTEX_GENERIC_ATTRIBS)
6313       save_Attr4fARB(index, v[0], v[1], v[2], v[3]);
6314    else
6315       index_error();
6316 }
6317
6318
6319 /* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
6320
6321 static void GLAPIENTRY
6322 exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name)
6323 {
6324    GET_CURRENT_CONTEXT(ctx);
6325    FLUSH_VERTICES(ctx, 0);
6326    CALL_BindAttribLocationARB(ctx->Exec, (program, index, name));
6327 }
6328
6329 static GLint GLAPIENTRY
6330 exec_GetAttribLocationARB(GLuint program, const GLchar *name)
6331 {
6332    GET_CURRENT_CONTEXT(ctx);
6333    FLUSH_VERTICES(ctx, 0);
6334    return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
6335 }
6336
6337 static GLint GLAPIENTRY
6338 exec_GetUniformLocationARB(GLuint program, const GLchar *name)
6339 {
6340    GET_CURRENT_CONTEXT(ctx);
6341    FLUSH_VERTICES(ctx, 0);
6342    return CALL_GetUniformLocationARB(ctx->Exec, (program, name));
6343 }
6344 /* XXX more shader functions needed here */
6345
6346
6347 #if FEATURE_EXT_framebuffer_blit
6348 static void GLAPIENTRY
6349 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
6350                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
6351                         GLbitfield mask, GLenum filter)
6352 {
6353    GET_CURRENT_CONTEXT(ctx);
6354    Node *n;
6355    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6356    n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
6357    if (n) {
6358       n[1].i = srcX0;
6359       n[2].i = srcY0;
6360       n[3].i = srcX1;
6361       n[4].i = srcY1;
6362       n[5].i = dstX0;
6363       n[6].i = dstY0;
6364       n[7].i = dstX1;
6365       n[8].i = dstY1;
6366       n[9].i = mask;
6367       n[10].e = filter;
6368    }
6369    if (ctx->ExecuteFlag) {
6370       CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
6371                                           dstX0, dstY0, dstX1, dstY1,
6372                                           mask, filter));
6373    }
6374 }
6375 #endif
6376
6377
6378 /** GL_EXT_provoking_vertex */
6379 static void GLAPIENTRY
6380 save_ProvokingVertexEXT(GLenum mode)
6381 {
6382    GET_CURRENT_CONTEXT(ctx);
6383    Node *n;
6384    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6385    n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
6386    if (n) {
6387       n[1].e = mode;
6388    }
6389    if (ctx->ExecuteFlag) {
6390       /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/
6391       _mesa_ProvokingVertexEXT(mode);
6392    }
6393 }
6394
6395
6396 /** GL_EXT_transform_feedback */
6397 static void GLAPIENTRY
6398 save_BeginTransformFeedback(GLenum mode)
6399 {
6400    GET_CURRENT_CONTEXT(ctx);
6401    Node *n;
6402    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6403    n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1);
6404    if (n) {
6405       n[1].e = mode;
6406    }
6407    if (ctx->ExecuteFlag) {
6408       CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode));
6409    }
6410 }
6411
6412
6413 /** GL_EXT_transform_feedback */
6414 static void GLAPIENTRY
6415 save_EndTransformFeedback(void)
6416 {
6417    GET_CURRENT_CONTEXT(ctx);
6418    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6419    (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0);
6420    if (ctx->ExecuteFlag) {
6421       CALL_EndTransformFeedbackEXT(ctx->Exec, ());
6422    }
6423 }
6424
6425 static void GLAPIENTRY
6426 save_BindTransformFeedback(GLenum target, GLuint name)
6427 {
6428    GET_CURRENT_CONTEXT(ctx);
6429    Node *n;
6430    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6431    n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2);
6432    if (n) {
6433       n[1].e = target;
6434       n[2].ui = name;
6435    }
6436    if (ctx->ExecuteFlag) {
6437       CALL_BindTransformFeedback(ctx->Exec, (target, name));
6438    }
6439 }
6440
6441 static void GLAPIENTRY
6442 save_PauseTransformFeedback(void)
6443 {
6444    GET_CURRENT_CONTEXT(ctx);
6445    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6446    (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0);
6447    if (ctx->ExecuteFlag) {
6448       CALL_PauseTransformFeedback(ctx->Exec, ());
6449    }
6450 }
6451
6452 static void GLAPIENTRY
6453 save_ResumeTransformFeedback(void)
6454 {
6455    GET_CURRENT_CONTEXT(ctx);
6456    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6457    (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0);
6458    if (ctx->ExecuteFlag) {
6459       CALL_ResumeTransformFeedback(ctx->Exec, ());
6460    }
6461 }
6462
6463 static void GLAPIENTRY
6464 save_DrawTransformFeedback(GLenum mode, GLuint name)
6465 {
6466    GET_CURRENT_CONTEXT(ctx);
6467    Node *n;
6468    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6469    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2);
6470    if (n) {
6471       n[1].e = mode;
6472       n[2].ui = name;
6473    }
6474    if (ctx->ExecuteFlag) {
6475       CALL_DrawTransformFeedback(ctx->Exec, (mode, name));
6476    }
6477 }
6478
6479
6480 /* aka UseProgram() */
6481 static void GLAPIENTRY
6482 save_UseProgramObjectARB(GLhandleARB program)
6483 {
6484    GET_CURRENT_CONTEXT(ctx);
6485    Node *n;
6486    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6487    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
6488    if (n) {
6489       n[1].ui = program;
6490    }
6491    if (ctx->ExecuteFlag) {
6492       CALL_UseProgramObjectARB(ctx->Exec, (program));
6493    }
6494 }
6495
6496
6497 static void GLAPIENTRY
6498 save_Uniform1fARB(GLint location, GLfloat x)
6499 {
6500    GET_CURRENT_CONTEXT(ctx);
6501    Node *n;
6502    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6503    n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
6504    if (n) {
6505       n[1].i = location;
6506       n[2].f = x;
6507    }
6508    if (ctx->ExecuteFlag) {
6509       CALL_Uniform1fARB(ctx->Exec, (location, x));
6510    }
6511 }
6512
6513
6514 static void GLAPIENTRY
6515 save_Uniform2fARB(GLint location, GLfloat x, GLfloat y)
6516 {
6517    GET_CURRENT_CONTEXT(ctx);
6518    Node *n;
6519    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6520    n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3);
6521    if (n) {
6522       n[1].i = location;
6523       n[2].f = x;
6524       n[3].f = y;
6525    }
6526    if (ctx->ExecuteFlag) {
6527       CALL_Uniform2fARB(ctx->Exec, (location, x, y));
6528    }
6529 }
6530
6531
6532 static void GLAPIENTRY
6533 save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z)
6534 {
6535    GET_CURRENT_CONTEXT(ctx);
6536    Node *n;
6537    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6538    n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
6539    if (n) {
6540       n[1].i = location;
6541       n[2].f = x;
6542       n[3].f = y;
6543       n[4].f = z;
6544    }
6545    if (ctx->ExecuteFlag) {
6546       CALL_Uniform3fARB(ctx->Exec, (location, x, y, z));
6547    }
6548 }
6549
6550
6551 static void GLAPIENTRY
6552 save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6553 {
6554    GET_CURRENT_CONTEXT(ctx);
6555    Node *n;
6556    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6557    n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
6558    if (n) {
6559       n[1].i = location;
6560       n[2].f = x;
6561       n[3].f = y;
6562       n[4].f = z;
6563       n[5].f = w;
6564    }
6565    if (ctx->ExecuteFlag) {
6566       CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w));
6567    }
6568 }
6569
6570
6571 /** Return copy of memory */
6572 static void *
6573 memdup(const void *src, GLsizei bytes)
6574 {
6575    void *b = bytes >= 0 ? malloc(bytes) : NULL;
6576    if (b)
6577       memcpy(b, src, bytes);
6578    return b;
6579 }
6580
6581
6582 static void GLAPIENTRY
6583 save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v)
6584 {
6585    GET_CURRENT_CONTEXT(ctx);
6586    Node *n;
6587    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6588    n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3);
6589    if (n) {
6590       n[1].i = location;
6591       n[2].i = count;
6592       n[3].data = memdup(v, count * 1 * sizeof(GLfloat));
6593    }
6594    if (ctx->ExecuteFlag) {
6595       CALL_Uniform1fvARB(ctx->Exec, (location, count, v));
6596    }
6597 }
6598
6599 static void GLAPIENTRY
6600 save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v)
6601 {
6602    GET_CURRENT_CONTEXT(ctx);
6603    Node *n;
6604    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6605    n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3);
6606    if (n) {
6607       n[1].i = location;
6608       n[2].i = count;
6609       n[3].data = memdup(v, count * 2 * sizeof(GLfloat));
6610    }
6611    if (ctx->ExecuteFlag) {
6612       CALL_Uniform2fvARB(ctx->Exec, (location, count, v));
6613    }
6614 }
6615
6616 static void GLAPIENTRY
6617 save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v)
6618 {
6619    GET_CURRENT_CONTEXT(ctx);
6620    Node *n;
6621    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6622    n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3);
6623    if (n) {
6624       n[1].i = location;
6625       n[2].i = count;
6626       n[3].data = memdup(v, count * 3 * sizeof(GLfloat));
6627    }
6628    if (ctx->ExecuteFlag) {
6629       CALL_Uniform3fvARB(ctx->Exec, (location, count, v));
6630    }
6631 }
6632
6633 static void GLAPIENTRY
6634 save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v)
6635 {
6636    GET_CURRENT_CONTEXT(ctx);
6637    Node *n;
6638    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6639    n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3);
6640    if (n) {
6641       n[1].i = location;
6642       n[2].i = count;
6643       n[3].data = memdup(v, count * 4 * sizeof(GLfloat));
6644    }
6645    if (ctx->ExecuteFlag) {
6646       CALL_Uniform4fvARB(ctx->Exec, (location, count, v));
6647    }
6648 }
6649
6650
6651 static void GLAPIENTRY
6652 save_Uniform1iARB(GLint location, GLint x)
6653 {
6654    GET_CURRENT_CONTEXT(ctx);
6655    Node *n;
6656    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6657    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
6658    if (n) {
6659       n[1].i = location;
6660       n[2].i = x;
6661    }
6662    if (ctx->ExecuteFlag) {
6663       CALL_Uniform1iARB(ctx->Exec, (location, x));
6664    }
6665 }
6666
6667 static void GLAPIENTRY
6668 save_Uniform2iARB(GLint location, GLint x, GLint y)
6669 {
6670    GET_CURRENT_CONTEXT(ctx);
6671    Node *n;
6672    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6673    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
6674    if (n) {
6675       n[1].i = location;
6676       n[2].i = x;
6677       n[3].i = y;
6678    }
6679    if (ctx->ExecuteFlag) {
6680       CALL_Uniform2iARB(ctx->Exec, (location, x, y));
6681    }
6682 }
6683
6684 static void GLAPIENTRY
6685 save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z)
6686 {
6687    GET_CURRENT_CONTEXT(ctx);
6688    Node *n;
6689    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6690    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
6691    if (n) {
6692       n[1].i = location;
6693       n[2].i = x;
6694       n[3].i = y;
6695       n[4].i = z;
6696    }
6697    if (ctx->ExecuteFlag) {
6698       CALL_Uniform3iARB(ctx->Exec, (location, x, y, z));
6699    }
6700 }
6701
6702 static void GLAPIENTRY
6703 save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w)
6704 {
6705    GET_CURRENT_CONTEXT(ctx);
6706    Node *n;
6707    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6708    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
6709    if (n) {
6710       n[1].i = location;
6711       n[2].i = x;
6712       n[3].i = y;
6713       n[4].i = z;
6714       n[5].i = w;
6715    }
6716    if (ctx->ExecuteFlag) {
6717       CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w));
6718    }
6719 }
6720
6721
6722
6723 static void GLAPIENTRY
6724 save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v)
6725 {
6726    GET_CURRENT_CONTEXT(ctx);
6727    Node *n;
6728    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6729    n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3);
6730    if (n) {
6731       n[1].i = location;
6732       n[2].i = count;
6733       n[3].data = memdup(v, count * 1 * sizeof(GLint));
6734    }
6735    if (ctx->ExecuteFlag) {
6736       CALL_Uniform1ivARB(ctx->Exec, (location, count, v));
6737    }
6738 }
6739
6740 static void GLAPIENTRY
6741 save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v)
6742 {
6743    GET_CURRENT_CONTEXT(ctx);
6744    Node *n;
6745    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6746    n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3);
6747    if (n) {
6748       n[1].i = location;
6749       n[2].i = count;
6750       n[3].data = memdup(v, count * 2 * sizeof(GLint));
6751    }
6752    if (ctx->ExecuteFlag) {
6753       CALL_Uniform2ivARB(ctx->Exec, (location, count, v));
6754    }
6755 }
6756
6757 static void GLAPIENTRY
6758 save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v)
6759 {
6760    GET_CURRENT_CONTEXT(ctx);
6761    Node *n;
6762    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6763    n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3);
6764    if (n) {
6765       n[1].i = location;
6766       n[2].i = count;
6767       n[3].data = memdup(v, count * 3 * sizeof(GLint));
6768    }
6769    if (ctx->ExecuteFlag) {
6770       CALL_Uniform3ivARB(ctx->Exec, (location, count, v));
6771    }
6772 }
6773
6774 static void GLAPIENTRY
6775 save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v)
6776 {
6777    GET_CURRENT_CONTEXT(ctx);
6778    Node *n;
6779    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6780    n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3);
6781    if (n) {
6782       n[1].i = location;
6783       n[2].i = count;
6784       n[3].data = memdup(v, count * 4 * sizeof(GLfloat));
6785    }
6786    if (ctx->ExecuteFlag) {
6787       CALL_Uniform4ivARB(ctx->Exec, (location, count, v));
6788    }
6789 }
6790
6791
6792
6793 static void GLAPIENTRY
6794 save_Uniform1ui(GLint location, GLuint x)
6795 {
6796    GET_CURRENT_CONTEXT(ctx);
6797    Node *n;
6798    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6799    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2);
6800    if (n) {
6801       n[1].i = location;
6802       n[2].i = x;
6803    }
6804    if (ctx->ExecuteFlag) {
6805       /*CALL_Uniform1ui(ctx->Exec, (location, x));*/
6806    }
6807 }
6808
6809 static void GLAPIENTRY
6810 save_Uniform2ui(GLint location, GLuint x, GLuint y)
6811 {
6812    GET_CURRENT_CONTEXT(ctx);
6813    Node *n;
6814    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6815    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3);
6816    if (n) {
6817       n[1].i = location;
6818       n[2].i = x;
6819       n[3].i = y;
6820    }
6821    if (ctx->ExecuteFlag) {
6822       /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/
6823    }
6824 }
6825
6826 static void GLAPIENTRY
6827 save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z)
6828 {
6829    GET_CURRENT_CONTEXT(ctx);
6830    Node *n;
6831    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6832    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4);
6833    if (n) {
6834       n[1].i = location;
6835       n[2].i = x;
6836       n[3].i = y;
6837       n[4].i = z;
6838    }
6839    if (ctx->ExecuteFlag) {
6840       /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/
6841    }
6842 }
6843
6844 static void GLAPIENTRY
6845 save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w)
6846 {
6847    GET_CURRENT_CONTEXT(ctx);
6848    Node *n;
6849    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6850    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5);
6851    if (n) {
6852       n[1].i = location;
6853       n[2].i = x;
6854       n[3].i = y;
6855       n[4].i = z;
6856       n[5].i = w;
6857    }
6858    if (ctx->ExecuteFlag) {
6859       /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/
6860    }
6861 }
6862
6863
6864
6865 static void GLAPIENTRY
6866 save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v)
6867 {
6868    GET_CURRENT_CONTEXT(ctx);
6869    Node *n;
6870    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6871    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3);
6872    if (n) {
6873       n[1].i = location;
6874       n[2].i = count;
6875       n[3].data = memdup(v, count * 1 * sizeof(*v));
6876    }
6877    if (ctx->ExecuteFlag) {
6878       /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/
6879    }
6880 }
6881
6882 static void GLAPIENTRY
6883 save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v)
6884 {
6885    GET_CURRENT_CONTEXT(ctx);
6886    Node *n;
6887    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6888    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3);
6889    if (n) {
6890       n[1].i = location;
6891       n[2].i = count;
6892       n[3].data = memdup(v, count * 2 * sizeof(*v));
6893    }
6894    if (ctx->ExecuteFlag) {
6895       /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/
6896    }
6897 }
6898
6899 static void GLAPIENTRY
6900 save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v)
6901 {
6902    GET_CURRENT_CONTEXT(ctx);
6903    Node *n;
6904    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6905    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3);
6906    if (n) {
6907       n[1].i = location;
6908       n[2].i = count;
6909       n[3].data = memdup(v, count * 3 * sizeof(*v));
6910    }
6911    if (ctx->ExecuteFlag) {
6912       /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/
6913    }
6914 }
6915
6916 static void GLAPIENTRY
6917 save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v)
6918 {
6919    GET_CURRENT_CONTEXT(ctx);
6920    Node *n;
6921    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6922    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3);
6923    if (n) {
6924       n[1].i = location;
6925       n[2].i = count;
6926       n[3].data = memdup(v, count * 4 * sizeof(*v));
6927    }
6928    if (ctx->ExecuteFlag) {
6929       /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/
6930    }
6931 }
6932
6933
6934
6935 static void GLAPIENTRY
6936 save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
6937                          const GLfloat *m)
6938 {
6939    GET_CURRENT_CONTEXT(ctx);
6940    Node *n;
6941    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6942    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4);
6943    if (n) {
6944       n[1].i = location;
6945       n[2].i = count;
6946       n[3].b = transpose;
6947       n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat));
6948    }
6949    if (ctx->ExecuteFlag) {
6950       CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m));
6951    }
6952 }
6953
6954 static void GLAPIENTRY
6955 save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
6956                          const GLfloat *m)
6957 {
6958    GET_CURRENT_CONTEXT(ctx);
6959    Node *n;
6960    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6961    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4);
6962    if (n) {
6963       n[1].i = location;
6964       n[2].i = count;
6965       n[3].b = transpose;
6966       n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat));
6967    }
6968    if (ctx->ExecuteFlag) {
6969       CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m));
6970    }
6971 }
6972
6973 static void GLAPIENTRY
6974 save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
6975                          const GLfloat *m)
6976 {
6977    GET_CURRENT_CONTEXT(ctx);
6978    Node *n;
6979    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6980    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4);
6981    if (n) {
6982       n[1].i = location;
6983       n[2].i = count;
6984       n[3].b = transpose;
6985       n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat));
6986    }
6987    if (ctx->ExecuteFlag) {
6988       CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m));
6989    }
6990 }
6991
6992
6993 static void GLAPIENTRY
6994 save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
6995                         const GLfloat *m)
6996 {
6997    GET_CURRENT_CONTEXT(ctx);
6998    Node *n;
6999    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7000    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4);
7001    if (n) {
7002       n[1].i = location;
7003       n[2].i = count;
7004       n[3].b = transpose;
7005       n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat));
7006    }
7007    if (ctx->ExecuteFlag) {
7008       CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m));
7009    }
7010 }
7011
7012 static void GLAPIENTRY
7013 save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
7014                         const GLfloat *m)
7015 {
7016    GET_CURRENT_CONTEXT(ctx);
7017    Node *n;
7018    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7019    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4);
7020    if (n) {
7021       n[1].i = location;
7022       n[2].i = count;
7023       n[3].b = transpose;
7024       n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat));
7025    }
7026    if (ctx->ExecuteFlag) {
7027       CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m));
7028    }
7029 }
7030
7031
7032 static void GLAPIENTRY
7033 save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
7034                         const GLfloat *m)
7035 {
7036    GET_CURRENT_CONTEXT(ctx);
7037    Node *n;
7038    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7039    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4);
7040    if (n) {
7041       n[1].i = location;
7042       n[2].i = count;
7043       n[3].b = transpose;
7044       n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat));
7045    }
7046    if (ctx->ExecuteFlag) {
7047       CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m));
7048    }
7049 }
7050
7051 static void GLAPIENTRY
7052 save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
7053                         const GLfloat *m)
7054 {
7055    GET_CURRENT_CONTEXT(ctx);
7056    Node *n;
7057    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7058    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4);
7059    if (n) {
7060       n[1].i = location;
7061       n[2].i = count;
7062       n[3].b = transpose;
7063       n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat));
7064    }
7065    if (ctx->ExecuteFlag) {
7066       CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m));
7067    }
7068 }
7069
7070
7071 static void GLAPIENTRY
7072 save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
7073                         const GLfloat *m)
7074 {
7075    GET_CURRENT_CONTEXT(ctx);
7076    Node *n;
7077    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7078    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4);
7079    if (n) {
7080       n[1].i = location;
7081       n[2].i = count;
7082       n[3].b = transpose;
7083       n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat));
7084    }
7085    if (ctx->ExecuteFlag) {
7086       CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m));
7087    }
7088 }
7089
7090 static void GLAPIENTRY
7091 save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
7092                         const GLfloat *m)
7093 {
7094    GET_CURRENT_CONTEXT(ctx);
7095    Node *n;
7096    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7097    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4);
7098    if (n) {
7099       n[1].i = location;
7100       n[2].i = count;
7101       n[3].b = transpose;
7102       n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat));
7103    }
7104    if (ctx->ExecuteFlag) {
7105       CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m));
7106    }
7107 }
7108
7109 static void GLAPIENTRY
7110 save_ClampColorARB(GLenum target, GLenum clamp)
7111 {
7112    GET_CURRENT_CONTEXT(ctx);
7113    Node *n;
7114    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7115    n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2);
7116    if (n) {
7117       n[1].e = target;
7118       n[2].e = clamp;
7119    }
7120    if (ctx->ExecuteFlag) {
7121       CALL_ClampColorARB(ctx->Exec, (target, clamp));
7122    }
7123 }
7124
7125 static void GLAPIENTRY
7126 save_UseShaderProgramEXT(GLenum type, GLuint program)
7127 {
7128    GET_CURRENT_CONTEXT(ctx);
7129    Node *n;
7130    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7131    n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2);
7132    if (n) {
7133       n[1].ui = type;
7134       n[2].ui = program;
7135    }
7136    if (ctx->ExecuteFlag) {
7137       CALL_UseShaderProgramEXT(ctx->Exec, (type, program));
7138    }
7139 }
7140
7141 static void GLAPIENTRY
7142 save_ActiveProgramEXT(GLuint program)
7143 {
7144    GET_CURRENT_CONTEXT(ctx);
7145    Node *n;
7146    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7147    n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1);
7148    if (n) {
7149       n[1].ui = program;
7150    }
7151    if (ctx->ExecuteFlag) {
7152       CALL_ActiveProgramEXT(ctx->Exec, (program));
7153    }
7154 }
7155
7156 /** GL_EXT_texture_integer */
7157 static void GLAPIENTRY
7158 save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha)
7159 {
7160    GET_CURRENT_CONTEXT(ctx);
7161    Node *n;
7162    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7163    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4);
7164    if (n) {
7165       n[1].i = red;
7166       n[2].i = green;
7167       n[3].i = blue;
7168       n[4].i = alpha;
7169    }
7170    if (ctx->ExecuteFlag) {
7171       CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha));
7172    }
7173 }
7174
7175 /** GL_EXT_texture_integer */
7176 static void GLAPIENTRY
7177 save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
7178 {
7179    GET_CURRENT_CONTEXT(ctx);
7180    Node *n;
7181    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7182    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4);
7183    if (n) {
7184       n[1].ui = red;
7185       n[2].ui = green;
7186       n[3].ui = blue;
7187       n[4].ui = alpha;
7188    }
7189    if (ctx->ExecuteFlag) {
7190       CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha));
7191    }
7192 }
7193
7194 /** GL_EXT_texture_integer */
7195 static void GLAPIENTRY
7196 save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
7197 {
7198    GET_CURRENT_CONTEXT(ctx);
7199    Node *n;
7200    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7201    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6);
7202    if (n) {
7203       n[1].e = target;
7204       n[2].e = pname;
7205       n[3].i = params[0];
7206       n[4].i = params[1];
7207       n[5].i = params[2];
7208       n[6].i = params[3];
7209    }
7210    if (ctx->ExecuteFlag) {
7211       CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params));
7212    }
7213 }
7214
7215 /** GL_EXT_texture_integer */
7216 static void GLAPIENTRY
7217 save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
7218 {
7219    GET_CURRENT_CONTEXT(ctx);
7220    Node *n;
7221    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7222    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6);
7223    if (n) {
7224       n[1].e = target;
7225       n[2].e = pname;
7226       n[3].ui = params[0];
7227       n[4].ui = params[1];
7228       n[5].ui = params[2];
7229       n[6].ui = params[3];
7230    }
7231    if (ctx->ExecuteFlag) {
7232       CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params));
7233    }
7234 }
7235
7236 /** GL_EXT_texture_integer */
7237 static void GLAPIENTRY
7238 exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
7239 {
7240    GET_CURRENT_CONTEXT(ctx);
7241    FLUSH_VERTICES(ctx, 0);
7242    CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params));
7243 }
7244
7245 /** GL_EXT_texture_integer */
7246 static void GLAPIENTRY
7247 exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
7248 {
7249    GET_CURRENT_CONTEXT(ctx);
7250    FLUSH_VERTICES(ctx, 0);
7251    CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params));
7252 }
7253
7254
7255 /* GL_ARB_instanced_arrays */
7256 static void GLAPIENTRY
7257 save_VertexAttribDivisor(GLuint index, GLuint divisor)
7258 {
7259    GET_CURRENT_CONTEXT(ctx);
7260    Node *n;
7261    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7262    n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2);
7263    if (n) {
7264       n[1].ui = index;
7265       n[2].ui = divisor;
7266    }
7267    if (ctx->ExecuteFlag) {
7268       CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor));
7269    }
7270 }
7271
7272
7273 /* GL_NV_texture_barrier */
7274 static void GLAPIENTRY
7275 save_TextureBarrierNV(void)
7276 {
7277    GET_CURRENT_CONTEXT(ctx);
7278    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7279    alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0);
7280    if (ctx->ExecuteFlag) {
7281       CALL_TextureBarrierNV(ctx->Exec, ());
7282    }
7283 }
7284
7285
7286 /* GL_ARB_sampler_objects */
7287 static void GLAPIENTRY
7288 save_BindSampler(GLuint unit, GLuint sampler)
7289 {
7290    Node *n;
7291    GET_CURRENT_CONTEXT(ctx);
7292    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7293    n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2);
7294    if (n) {
7295       n[1].ui = unit;
7296       n[2].ui = sampler;
7297    }
7298    if (ctx->ExecuteFlag) {
7299       CALL_BindSampler(ctx->Exec, (unit, sampler));
7300    }
7301 }
7302
7303 static void GLAPIENTRY
7304 save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
7305 {
7306    Node *n;
7307    GET_CURRENT_CONTEXT(ctx);
7308    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7309    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6);
7310    if (n) {
7311       n[1].ui = sampler;
7312       n[2].e = pname;
7313       n[3].i = params[0];
7314       if (pname == GL_TEXTURE_BORDER_COLOR) {
7315          n[4].i = params[1];
7316          n[5].i = params[2];
7317          n[6].i = params[3];
7318       }
7319       else {
7320          n[4].i = n[5].i = n[6].i = 0;
7321       }
7322    }
7323    if (ctx->ExecuteFlag) {
7324       CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params));
7325    }
7326 }
7327
7328 static void GLAPIENTRY
7329 save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
7330 {
7331    save_SamplerParameteriv(sampler, pname, &param);
7332 }
7333
7334 static void GLAPIENTRY
7335 save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
7336 {
7337    Node *n;
7338    GET_CURRENT_CONTEXT(ctx);
7339    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7340    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6);
7341    if (n) {
7342       n[1].ui = sampler;
7343       n[2].e = pname;
7344       n[3].f = params[0];
7345       if (pname == GL_TEXTURE_BORDER_COLOR) {
7346          n[4].f = params[1];
7347          n[5].f = params[2];
7348          n[6].f = params[3];
7349       }
7350       else {
7351          n[4].f = n[5].f = n[6].f = 0.0F;
7352       }
7353    }
7354    if (ctx->ExecuteFlag) {
7355       CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params));
7356    }
7357 }
7358
7359 static void GLAPIENTRY
7360 save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
7361 {
7362    save_SamplerParameterfv(sampler, pname, &param);
7363 }
7364
7365 static void GLAPIENTRY
7366 save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
7367 {
7368    Node *n;
7369    GET_CURRENT_CONTEXT(ctx);
7370    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7371    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6);
7372    if (n) {
7373       n[1].ui = sampler;
7374       n[2].e = pname;
7375       n[3].i = params[0];
7376       if (pname == GL_TEXTURE_BORDER_COLOR) {
7377          n[4].i = params[1];
7378          n[5].i = params[2];
7379          n[6].i = params[3];
7380       }
7381       else {
7382          n[4].i = n[5].i = n[6].i = 0;
7383       }
7384    }
7385    if (ctx->ExecuteFlag) {
7386       CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params));
7387    }
7388 }
7389
7390 static void GLAPIENTRY
7391 save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
7392 {
7393    Node *n;
7394    GET_CURRENT_CONTEXT(ctx);
7395    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7396    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6);
7397    if (n) {
7398       n[1].ui = sampler;
7399       n[2].e = pname;
7400       n[3].ui = params[0];
7401       if (pname == GL_TEXTURE_BORDER_COLOR) {
7402          n[4].ui = params[1];
7403          n[5].ui = params[2];
7404          n[6].ui = params[3];
7405       }
7406       else {
7407          n[4].ui = n[5].ui = n[6].ui = 0;
7408       }
7409    }
7410    if (ctx->ExecuteFlag) {
7411       CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params));
7412    }
7413 }
7414
7415 /* GL_ARB_geometry_shader4 */
7416 static void GLAPIENTRY
7417 save_ProgramParameteri(GLuint program, GLenum pname, GLint value)
7418 {
7419    Node *n;
7420    GET_CURRENT_CONTEXT(ctx);
7421    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7422    n = alloc_instruction(ctx, OPCODE_PROGRAM_PARAMETERI, 3);
7423    if (n) {
7424       n[1].ui = program;
7425       n[2].e = pname;
7426       n[3].i = value;
7427    }
7428    if (ctx->ExecuteFlag) {
7429       CALL_ProgramParameteriARB(ctx->Exec, (program, pname, value));
7430    }
7431 }
7432
7433 static void GLAPIENTRY
7434 save_FramebufferTexture(GLenum target, GLenum attachment,
7435                         GLuint texture, GLint level)
7436 {
7437    Node *n;
7438    GET_CURRENT_CONTEXT(ctx);
7439    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7440    n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE, 4);
7441    if (n) {
7442       n[1].e = target;
7443       n[2].e = attachment;
7444       n[3].ui = texture;
7445       n[4].i = level;
7446    }
7447    if (ctx->ExecuteFlag) {
7448       CALL_FramebufferTextureARB(ctx->Exec, (target, attachment, texture, level));
7449    }
7450 }
7451
7452 static void GLAPIENTRY
7453 save_FramebufferTextureFace(GLenum target, GLenum attachment,
7454                             GLuint texture, GLint level, GLenum face)
7455 {
7456    Node *n;
7457    GET_CURRENT_CONTEXT(ctx);
7458    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7459    n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE_FACE, 5);
7460    if (n) {
7461       n[1].e = target;
7462       n[2].e = attachment;
7463       n[3].ui = texture;
7464       n[4].i = level;
7465       n[5].e = face;
7466    }
7467    if (ctx->ExecuteFlag) {
7468       CALL_FramebufferTextureFaceARB(ctx->Exec, (target, attachment, texture,
7469                                                  level, face));
7470    }
7471 }
7472
7473
7474
7475 static void GLAPIENTRY
7476 save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
7477 {
7478    Node *n;
7479    GET_CURRENT_CONTEXT(ctx);
7480    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7481    n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4);
7482    if (n) {
7483       union uint64_pair p;
7484       p.uint64 = timeout;
7485       n[1].data = sync;
7486       n[2].e = flags;
7487       n[3].ui = p.uint32[0];
7488       n[4].ui = p.uint32[1];
7489    }
7490    if (ctx->ExecuteFlag) {
7491       CALL_WaitSync(ctx->Exec, (sync, flags, timeout));
7492    }
7493 }
7494
7495
7496 /** GL_NV_conditional_render */
7497 static void GLAPIENTRY
7498 save_BeginConditionalRender(GLuint queryId, GLenum mode)
7499 {
7500    GET_CURRENT_CONTEXT(ctx);
7501    Node *n;
7502    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7503    n = alloc_instruction(ctx, OPCODE_BEGIN_CONDITIONAL_RENDER, 2);
7504    if (n) {
7505       n[1].i = queryId;
7506       n[2].e = mode;
7507    }
7508    if (ctx->ExecuteFlag) {
7509       CALL_BeginConditionalRenderNV(ctx->Exec, (queryId, mode));
7510    }
7511 }
7512
7513 static void GLAPIENTRY
7514 save_EndConditionalRender(void)
7515 {
7516    GET_CURRENT_CONTEXT(ctx);
7517    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7518    alloc_instruction(ctx, OPCODE_END_CONDITIONAL_RENDER, 0);
7519    if (ctx->ExecuteFlag) {
7520       CALL_EndConditionalRenderNV(ctx->Exec, ());
7521    }
7522 }
7523
7524
7525 /**
7526  * Save an error-generating command into display list.
7527  *
7528  * KW: Will appear in the list before the vertex buffer containing the
7529  * command that provoked the error.  I don't see this as a problem.
7530  */
7531 static void
7532 save_error(struct gl_context *ctx, GLenum error, const char *s)
7533 {
7534    Node *n;
7535    n = alloc_instruction(ctx, OPCODE_ERROR, 2);
7536    if (n) {
7537       n[1].e = error;
7538       n[2].data = (void *) s;
7539    }
7540 }
7541
7542
7543 /**
7544  * Compile an error into current display list.
7545  */
7546 void
7547 _mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s)
7548 {
7549    if (ctx->CompileFlag)
7550       save_error(ctx, error, s);
7551    if (ctx->ExecuteFlag)
7552       _mesa_error(ctx, error, "%s", s);
7553 }
7554
7555
7556 /**
7557  * Test if ID names a display list.
7558  */
7559 static GLboolean
7560 islist(struct gl_context *ctx, GLuint list)
7561 {
7562    if (list > 0 && lookup_list(ctx, list)) {
7563       return GL_TRUE;
7564    }
7565    else {
7566       return GL_FALSE;
7567    }
7568 }
7569
7570
7571
7572 /**********************************************************************/
7573 /*                     Display list execution                         */
7574 /**********************************************************************/
7575
7576
7577 /*
7578  * Execute a display list.  Note that the ListBase offset must have already
7579  * been added before calling this function.  I.e. the list argument is
7580  * the absolute list number, not relative to ListBase.
7581  * \param list - display list number
7582  */
7583 static void
7584 execute_list(struct gl_context *ctx, GLuint list)
7585 {
7586    struct gl_display_list *dlist;
7587    Node *n;
7588    GLboolean done;
7589
7590    if (list == 0 || !islist(ctx, list))
7591       return;
7592
7593    if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
7594       /* raise an error? */
7595       return;
7596    }
7597
7598    dlist = lookup_list(ctx, list);
7599    if (!dlist)
7600       return;
7601
7602    ctx->ListState.CallDepth++;
7603
7604    if (ctx->Driver.BeginCallList)
7605       ctx->Driver.BeginCallList(ctx, dlist);
7606
7607    n = dlist->Head;
7608
7609    done = GL_FALSE;
7610    while (!done) {
7611       const OpCode opcode = n[0].opcode;
7612
7613       if (is_ext_opcode(opcode)) {
7614          n += ext_opcode_execute(ctx, n);
7615       }
7616       else {
7617          switch (opcode) {
7618          case OPCODE_ERROR:
7619             _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data);
7620             break;
7621          case OPCODE_ACCUM:
7622             CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
7623             break;
7624          case OPCODE_ALPHA_FUNC:
7625             CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
7626             break;
7627          case OPCODE_BIND_TEXTURE:
7628             CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
7629             break;
7630          case OPCODE_BITMAP:
7631             {
7632                const struct gl_pixelstore_attrib save = ctx->Unpack;
7633                ctx->Unpack = ctx->DefaultPacking;
7634                CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i,
7635                                        n[3].f, n[4].f, n[5].f, n[6].f,
7636                                        (const GLubyte *) n[7].data));
7637                ctx->Unpack = save;      /* restore */
7638             }
7639             break;
7640          case OPCODE_BLEND_COLOR:
7641             CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
7642             break;
7643          case OPCODE_BLEND_EQUATION:
7644             CALL_BlendEquation(ctx->Exec, (n[1].e));
7645             break;
7646          case OPCODE_BLEND_EQUATION_SEPARATE:
7647             CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e));
7648             break;
7649          case OPCODE_BLEND_FUNC_SEPARATE:
7650             CALL_BlendFuncSeparateEXT(ctx->Exec,
7651                                       (n[1].e, n[2].e, n[3].e, n[4].e));
7652             break;
7653
7654          case OPCODE_BLEND_FUNC_I:
7655             /* GL_ARB_draw_buffers_blend */
7656             CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e));
7657             break;
7658          case OPCODE_BLEND_FUNC_SEPARATE_I:
7659             /* GL_ARB_draw_buffers_blend */
7660             CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e,
7661                                                    n[4].e, n[5].e));
7662             break;
7663          case OPCODE_BLEND_EQUATION_I:
7664             /* GL_ARB_draw_buffers_blend */
7665             CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e));
7666             break;
7667          case OPCODE_BLEND_EQUATION_SEPARATE_I:
7668             /* GL_ARB_draw_buffers_blend */
7669             CALL_BlendEquationSeparateiARB(ctx->Exec,
7670                                            (n[1].ui, n[2].e, n[3].e));
7671             break;
7672
7673          case OPCODE_CALL_LIST:
7674             /* Generated by glCallList(), don't add ListBase */
7675             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
7676                execute_list(ctx, n[1].ui);
7677             }
7678             break;
7679          case OPCODE_CALL_LIST_OFFSET:
7680             /* Generated by glCallLists() so we must add ListBase */
7681             if (n[2].b) {
7682                /* user specified a bad data type at compile time */
7683                _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
7684             }
7685             else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
7686                GLuint list = (GLuint) (ctx->List.ListBase + n[1].i);
7687                execute_list(ctx, list);
7688             }
7689             break;
7690          case OPCODE_CLEAR:
7691             CALL_Clear(ctx->Exec, (n[1].bf));
7692             break;
7693          case OPCODE_CLEAR_BUFFER_IV:
7694             {
7695                GLint value[4];
7696                value[0] = n[3].i;
7697                value[1] = n[4].i;
7698                value[2] = n[5].i;
7699                value[3] = n[6].i;
7700                CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));
7701             }
7702             break;
7703          case OPCODE_CLEAR_BUFFER_UIV:
7704             {
7705                GLuint value[4];
7706                value[0] = n[3].ui;
7707                value[1] = n[4].ui;
7708                value[2] = n[5].ui;
7709                value[3] = n[6].ui;
7710                CALL_ClearBufferuiv(ctx->Exec, (n[1].e, n[2].i, value));
7711             }
7712             break;
7713          case OPCODE_CLEAR_BUFFER_FV:
7714             {
7715                GLfloat value[4];
7716                value[0] = n[3].f;
7717                value[1] = n[4].f;
7718                value[2] = n[5].f;
7719                value[3] = n[6].f;
7720                CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));
7721             }
7722             break;
7723          case OPCODE_CLEAR_BUFFER_FI:
7724             CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));
7725             break;
7726          case OPCODE_CLEAR_COLOR:
7727             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
7728             break;
7729          case OPCODE_CLEAR_ACCUM:
7730             CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
7731             break;
7732          case OPCODE_CLEAR_DEPTH:
7733             CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
7734             break;
7735          case OPCODE_CLEAR_INDEX:
7736             CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
7737             break;
7738          case OPCODE_CLEAR_STENCIL:
7739             CALL_ClearStencil(ctx->Exec, (n[1].i));
7740             break;
7741          case OPCODE_CLIP_PLANE:
7742             {
7743                GLdouble eq[4];
7744                eq[0] = n[2].f;
7745                eq[1] = n[3].f;
7746                eq[2] = n[4].f;
7747                eq[3] = n[5].f;
7748                CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
7749             }
7750             break;
7751          case OPCODE_COLOR_MASK:
7752             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
7753             break;
7754          case OPCODE_COLOR_MASK_INDEXED:
7755             CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
7756                                                  n[4].b, n[5].b));
7757             break;
7758          case OPCODE_COLOR_MATERIAL:
7759             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
7760             break;
7761          case OPCODE_COLOR_TABLE:
7762             {
7763                const struct gl_pixelstore_attrib save = ctx->Unpack;
7764                ctx->Unpack = ctx->DefaultPacking;
7765                CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e,
7766                                            n[5].e, n[6].data));
7767                ctx->Unpack = save;      /* restore */
7768             }
7769             break;
7770          case OPCODE_COLOR_TABLE_PARAMETER_FV:
7771             {
7772                GLfloat params[4];
7773                params[0] = n[3].f;
7774                params[1] = n[4].f;
7775                params[2] = n[5].f;
7776                params[3] = n[6].f;
7777                CALL_ColorTableParameterfv(ctx->Exec,
7778                                           (n[1].e, n[2].e, params));
7779             }
7780             break;
7781          case OPCODE_COLOR_TABLE_PARAMETER_IV:
7782             {
7783                GLint params[4];
7784                params[0] = n[3].i;
7785                params[1] = n[4].i;
7786                params[2] = n[5].i;
7787                params[3] = n[6].i;
7788                CALL_ColorTableParameteriv(ctx->Exec,
7789                                           (n[1].e, n[2].e, params));
7790             }
7791             break;
7792          case OPCODE_COLOR_SUB_TABLE:
7793             {
7794                const struct gl_pixelstore_attrib save = ctx->Unpack;
7795                ctx->Unpack = ctx->DefaultPacking;
7796                CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7797                                               n[4].e, n[5].e, n[6].data));
7798                ctx->Unpack = save;      /* restore */
7799             }
7800             break;
7801          case OPCODE_CONVOLUTION_FILTER_1D:
7802             {
7803                const struct gl_pixelstore_attrib save = ctx->Unpack;
7804                ctx->Unpack = ctx->DefaultPacking;
7805                CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7806                                                     n[4].e, n[5].e,
7807                                                     n[6].data));
7808                ctx->Unpack = save;      /* restore */
7809             }
7810             break;
7811          case OPCODE_CONVOLUTION_FILTER_2D:
7812             {
7813                const struct gl_pixelstore_attrib save = ctx->Unpack;
7814                ctx->Unpack = ctx->DefaultPacking;
7815                CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7816                                                     n[4].i, n[5].e, n[6].e,
7817                                                     n[7].data));
7818                ctx->Unpack = save;      /* restore */
7819             }
7820             break;
7821          case OPCODE_CONVOLUTION_PARAMETER_I:
7822             CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i));
7823             break;
7824          case OPCODE_CONVOLUTION_PARAMETER_IV:
7825             {
7826                GLint params[4];
7827                params[0] = n[3].i;
7828                params[1] = n[4].i;
7829                params[2] = n[5].i;
7830                params[3] = n[6].i;
7831                CALL_ConvolutionParameteriv(ctx->Exec,
7832                                            (n[1].e, n[2].e, params));
7833             }
7834             break;
7835          case OPCODE_CONVOLUTION_PARAMETER_F:
7836             CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f));
7837             break;
7838          case OPCODE_CONVOLUTION_PARAMETER_FV:
7839             {
7840                GLfloat params[4];
7841                params[0] = n[3].f;
7842                params[1] = n[4].f;
7843                params[2] = n[5].f;
7844                params[3] = n[6].f;
7845                CALL_ConvolutionParameterfv(ctx->Exec,
7846                                            (n[1].e, n[2].e, params));
7847             }
7848             break;
7849          case OPCODE_COPY_COLOR_SUB_TABLE:
7850             CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
7851                                                n[3].i, n[4].i, n[5].i));
7852             break;
7853          case OPCODE_COPY_COLOR_TABLE:
7854             CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i,
7855                                                n[3].i, n[4].i, n[5].i));
7856             break;
7857          case OPCODE_COPY_PIXELS:
7858             CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
7859                                         (GLsizei) n[3].i, (GLsizei) n[4].i,
7860                                         n[5].e));
7861             break;
7862          case OPCODE_COPY_TEX_IMAGE1D:
7863             CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
7864                                             n[5].i, n[6].i, n[7].i));
7865             break;
7866          case OPCODE_COPY_TEX_IMAGE2D:
7867             CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
7868                                             n[5].i, n[6].i, n[7].i, n[8].i));
7869             break;
7870          case OPCODE_COPY_TEX_SUB_IMAGE1D:
7871             CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7872                                                n[4].i, n[5].i, n[6].i));
7873             break;
7874          case OPCODE_COPY_TEX_SUB_IMAGE2D:
7875             CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7876                                                n[4].i, n[5].i, n[6].i, n[7].i,
7877                                                n[8].i));
7878             break;
7879          case OPCODE_COPY_TEX_SUB_IMAGE3D:
7880             CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
7881                                                n[4].i, n[5].i, n[6].i, n[7].i,
7882                                                n[8].i, n[9].i));
7883             break;
7884          case OPCODE_CULL_FACE:
7885             CALL_CullFace(ctx->Exec, (n[1].e));
7886             break;
7887          case OPCODE_DEPTH_FUNC:
7888             CALL_DepthFunc(ctx->Exec, (n[1].e));
7889             break;
7890          case OPCODE_DEPTH_MASK:
7891             CALL_DepthMask(ctx->Exec, (n[1].b));
7892             break;
7893          case OPCODE_DEPTH_RANGE:
7894             CALL_DepthRange(ctx->Exec,
7895                             ((GLclampd) n[1].f, (GLclampd) n[2].f));
7896             break;
7897          case OPCODE_DISABLE:
7898             CALL_Disable(ctx->Exec, (n[1].e));
7899             break;
7900          case OPCODE_DISABLE_INDEXED:
7901             CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
7902             break;
7903          case OPCODE_DRAW_BUFFER:
7904             CALL_DrawBuffer(ctx->Exec, (n[1].e));
7905             break;
7906          case OPCODE_DRAW_PIXELS:
7907             {
7908                const struct gl_pixelstore_attrib save = ctx->Unpack;
7909                ctx->Unpack = ctx->DefaultPacking;
7910                CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
7911                                            n[5].data));
7912                ctx->Unpack = save;      /* restore */
7913             }
7914             break;
7915          case OPCODE_ENABLE:
7916             CALL_Enable(ctx->Exec, (n[1].e));
7917             break;
7918          case OPCODE_ENABLE_INDEXED:
7919             CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e));
7920             break;
7921          case OPCODE_EVALMESH1:
7922             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
7923             break;
7924          case OPCODE_EVALMESH2:
7925             CALL_EvalMesh2(ctx->Exec,
7926                            (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
7927             break;
7928          case OPCODE_FOG:
7929             {
7930                GLfloat p[4];
7931                p[0] = n[2].f;
7932                p[1] = n[3].f;
7933                p[2] = n[4].f;
7934                p[3] = n[5].f;
7935                CALL_Fogfv(ctx->Exec, (n[1].e, p));
7936             }
7937             break;
7938          case OPCODE_FRONT_FACE:
7939             CALL_FrontFace(ctx->Exec, (n[1].e));
7940             break;
7941          case OPCODE_FRUSTUM:
7942             CALL_Frustum(ctx->Exec,
7943                          (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
7944             break;
7945          case OPCODE_HINT:
7946             CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
7947             break;
7948          case OPCODE_HISTOGRAM:
7949             CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b));
7950             break;
7951          case OPCODE_INDEX_MASK:
7952             CALL_IndexMask(ctx->Exec, (n[1].ui));
7953             break;
7954          case OPCODE_INIT_NAMES:
7955             CALL_InitNames(ctx->Exec, ());
7956             break;
7957          case OPCODE_LIGHT:
7958             {
7959                GLfloat p[4];
7960                p[0] = n[3].f;
7961                p[1] = n[4].f;
7962                p[2] = n[5].f;
7963                p[3] = n[6].f;
7964                CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
7965             }
7966             break;
7967          case OPCODE_LIGHT_MODEL:
7968             {
7969                GLfloat p[4];
7970                p[0] = n[2].f;
7971                p[1] = n[3].f;
7972                p[2] = n[4].f;
7973                p[3] = n[5].f;
7974                CALL_LightModelfv(ctx->Exec, (n[1].e, p));
7975             }
7976             break;
7977          case OPCODE_LINE_STIPPLE:
7978             CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
7979             break;
7980          case OPCODE_LINE_WIDTH:
7981             CALL_LineWidth(ctx->Exec, (n[1].f));
7982             break;
7983          case OPCODE_LIST_BASE:
7984             CALL_ListBase(ctx->Exec, (n[1].ui));
7985             break;
7986          case OPCODE_LOAD_IDENTITY:
7987             CALL_LoadIdentity(ctx->Exec, ());
7988             break;
7989          case OPCODE_LOAD_MATRIX:
7990             if (sizeof(Node) == sizeof(GLfloat)) {
7991                CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
7992             }
7993             else {
7994                GLfloat m[16];
7995                GLuint i;
7996                for (i = 0; i < 16; i++) {
7997                   m[i] = n[1 + i].f;
7998                }
7999                CALL_LoadMatrixf(ctx->Exec, (m));
8000             }
8001             break;
8002          case OPCODE_LOAD_NAME:
8003             CALL_LoadName(ctx->Exec, (n[1].ui));
8004             break;
8005          case OPCODE_LOGIC_OP:
8006             CALL_LogicOp(ctx->Exec, (n[1].e));
8007             break;
8008          case OPCODE_MAP1:
8009             {
8010                GLenum target = n[1].e;
8011                GLint ustride = _mesa_evaluator_components(target);
8012                GLint uorder = n[5].i;
8013                GLfloat u1 = n[2].f;
8014                GLfloat u2 = n[3].f;
8015                CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
8016                                       (GLfloat *) n[6].data));
8017             }
8018             break;
8019          case OPCODE_MAP2:
8020             {
8021                GLenum target = n[1].e;
8022                GLfloat u1 = n[2].f;
8023                GLfloat u2 = n[3].f;
8024                GLfloat v1 = n[4].f;
8025                GLfloat v2 = n[5].f;
8026                GLint ustride = n[6].i;
8027                GLint vstride = n[7].i;
8028                GLint uorder = n[8].i;
8029                GLint vorder = n[9].i;
8030                CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
8031                                       v1, v2, vstride, vorder,
8032                                       (GLfloat *) n[10].data));
8033             }
8034             break;
8035          case OPCODE_MAPGRID1:
8036             CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
8037             break;
8038          case OPCODE_MAPGRID2:
8039             CALL_MapGrid2f(ctx->Exec,
8040                            (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
8041             break;
8042          case OPCODE_MATRIX_MODE:
8043             CALL_MatrixMode(ctx->Exec, (n[1].e));
8044             break;
8045          case OPCODE_MIN_MAX:
8046             CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b));
8047             break;
8048          case OPCODE_MULT_MATRIX:
8049             if (sizeof(Node) == sizeof(GLfloat)) {
8050                CALL_MultMatrixf(ctx->Exec, (&n[1].f));
8051             }
8052             else {
8053                GLfloat m[16];
8054                GLuint i;
8055                for (i = 0; i < 16; i++) {
8056                   m[i] = n[1 + i].f;
8057                }
8058                CALL_MultMatrixf(ctx->Exec, (m));
8059             }
8060             break;
8061          case OPCODE_ORTHO:
8062             CALL_Ortho(ctx->Exec,
8063                        (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
8064             break;
8065          case OPCODE_PASSTHROUGH:
8066             CALL_PassThrough(ctx->Exec, (n[1].f));
8067             break;
8068          case OPCODE_PIXEL_MAP:
8069             CALL_PixelMapfv(ctx->Exec,
8070                             (n[1].e, n[2].i, (GLfloat *) n[3].data));
8071             break;
8072          case OPCODE_PIXEL_TRANSFER:
8073             CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
8074             break;
8075          case OPCODE_PIXEL_ZOOM:
8076             CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
8077             break;
8078          case OPCODE_POINT_SIZE:
8079             CALL_PointSize(ctx->Exec, (n[1].f));
8080             break;
8081          case OPCODE_POINT_PARAMETERS:
8082             {
8083                GLfloat params[3];
8084                params[0] = n[2].f;
8085                params[1] = n[3].f;
8086                params[2] = n[4].f;
8087                CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params));
8088             }
8089             break;
8090          case OPCODE_POLYGON_MODE:
8091             CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
8092             break;
8093          case OPCODE_POLYGON_STIPPLE:
8094             {
8095                const struct gl_pixelstore_attrib save = ctx->Unpack;
8096                ctx->Unpack = ctx->DefaultPacking;
8097                CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data));
8098                ctx->Unpack = save;      /* restore */
8099             }
8100             break;
8101          case OPCODE_POLYGON_OFFSET:
8102             CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
8103             break;
8104          case OPCODE_POP_ATTRIB:
8105             CALL_PopAttrib(ctx->Exec, ());
8106             break;
8107          case OPCODE_POP_MATRIX:
8108             CALL_PopMatrix(ctx->Exec, ());
8109             break;
8110          case OPCODE_POP_NAME:
8111             CALL_PopName(ctx->Exec, ());
8112             break;
8113          case OPCODE_PRIORITIZE_TEXTURE:
8114             CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
8115             break;
8116          case OPCODE_PUSH_ATTRIB:
8117             CALL_PushAttrib(ctx->Exec, (n[1].bf));
8118             break;
8119          case OPCODE_PUSH_MATRIX:
8120             CALL_PushMatrix(ctx->Exec, ());
8121             break;
8122          case OPCODE_PUSH_NAME:
8123             CALL_PushName(ctx->Exec, (n[1].ui));
8124             break;
8125          case OPCODE_RASTER_POS:
8126             CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
8127             break;
8128          case OPCODE_READ_BUFFER:
8129             CALL_ReadBuffer(ctx->Exec, (n[1].e));
8130             break;
8131          case OPCODE_RESET_HISTOGRAM:
8132             CALL_ResetHistogram(ctx->Exec, (n[1].e));
8133             break;
8134          case OPCODE_RESET_MIN_MAX:
8135             CALL_ResetMinmax(ctx->Exec, (n[1].e));
8136             break;
8137          case OPCODE_ROTATE:
8138             CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
8139             break;
8140          case OPCODE_SCALE:
8141             CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
8142             break;
8143          case OPCODE_SCISSOR:
8144             CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
8145             break;
8146          case OPCODE_SHADE_MODEL:
8147             CALL_ShadeModel(ctx->Exec, (n[1].e));
8148             break;
8149          case OPCODE_PROVOKING_VERTEX:
8150             CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e));
8151             break;
8152          case OPCODE_STENCIL_FUNC:
8153             CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
8154             break;
8155          case OPCODE_STENCIL_MASK:
8156             CALL_StencilMask(ctx->Exec, (n[1].ui));
8157             break;
8158          case OPCODE_STENCIL_OP:
8159             CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
8160             break;
8161          case OPCODE_STENCIL_FUNC_SEPARATE:
8162             CALL_StencilFuncSeparate(ctx->Exec,
8163                                      (n[1].e, n[2].e, n[3].i, n[4].ui));
8164             break;
8165          case OPCODE_STENCIL_MASK_SEPARATE:
8166             CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
8167             break;
8168          case OPCODE_STENCIL_OP_SEPARATE:
8169             CALL_StencilOpSeparate(ctx->Exec,
8170                                    (n[1].e, n[2].e, n[3].e, n[4].e));
8171             break;
8172          case OPCODE_TEXENV:
8173             {
8174                GLfloat params[4];
8175                params[0] = n[3].f;
8176                params[1] = n[4].f;
8177                params[2] = n[5].f;
8178                params[3] = n[6].f;
8179                CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
8180             }
8181             break;
8182          case OPCODE_TEXGEN:
8183             {
8184                GLfloat params[4];
8185                params[0] = n[3].f;
8186                params[1] = n[4].f;
8187                params[2] = n[5].f;
8188                params[3] = n[6].f;
8189                CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
8190             }
8191             break;
8192          case OPCODE_TEXPARAMETER:
8193             {
8194                GLfloat params[4];
8195                params[0] = n[3].f;
8196                params[1] = n[4].f;
8197                params[2] = n[5].f;
8198                params[3] = n[6].f;
8199                CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
8200             }
8201             break;
8202          case OPCODE_TEX_IMAGE1D:
8203             {
8204                const struct gl_pixelstore_attrib save = ctx->Unpack;
8205                ctx->Unpack = ctx->DefaultPacking;
8206                CALL_TexImage1D(ctx->Exec, (n[1].e,      /* target */
8207                                            n[2].i,      /* level */
8208                                            n[3].i,      /* components */
8209                                            n[4].i,      /* width */
8210                                            n[5].e,      /* border */
8211                                            n[6].e,      /* format */
8212                                            n[7].e,      /* type */
8213                                            n[8].data));
8214                ctx->Unpack = save;      /* restore */
8215             }
8216             break;
8217          case OPCODE_TEX_IMAGE2D:
8218             {
8219                const struct gl_pixelstore_attrib save = ctx->Unpack;
8220                ctx->Unpack = ctx->DefaultPacking;
8221                CALL_TexImage2D(ctx->Exec, (n[1].e,      /* target */
8222                                            n[2].i,      /* level */
8223                                            n[3].i,      /* components */
8224                                            n[4].i,      /* width */
8225                                            n[5].i,      /* height */
8226                                            n[6].e,      /* border */
8227                                            n[7].e,      /* format */
8228                                            n[8].e,      /* type */
8229                                            n[9].data));
8230                ctx->Unpack = save;      /* restore */
8231             }
8232             break;
8233          case OPCODE_TEX_IMAGE3D:
8234             {
8235                const struct gl_pixelstore_attrib save = ctx->Unpack;
8236                ctx->Unpack = ctx->DefaultPacking;
8237                CALL_TexImage3D(ctx->Exec, (n[1].e,      /* target */
8238                                            n[2].i,      /* level */
8239                                            n[3].i,      /* components */
8240                                            n[4].i,      /* width */
8241                                            n[5].i,      /* height */
8242                                            n[6].i,      /* depth  */
8243                                            n[7].e,      /* border */
8244                                            n[8].e,      /* format */
8245                                            n[9].e,      /* type */
8246                                            n[10].data));
8247                ctx->Unpack = save;      /* restore */
8248             }
8249             break;
8250          case OPCODE_TEX_SUB_IMAGE1D:
8251             {
8252                const struct gl_pixelstore_attrib save = ctx->Unpack;
8253                ctx->Unpack = ctx->DefaultPacking;
8254                CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
8255                                               n[4].i, n[5].e,
8256                                               n[6].e, n[7].data));
8257                ctx->Unpack = save;      /* restore */
8258             }
8259             break;
8260          case OPCODE_TEX_SUB_IMAGE2D:
8261             {
8262                const struct gl_pixelstore_attrib save = ctx->Unpack;
8263                ctx->Unpack = ctx->DefaultPacking;
8264                CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
8265                                               n[4].i, n[5].e,
8266                                               n[6].i, n[7].e, n[8].e,
8267                                               n[9].data));
8268                ctx->Unpack = save;      /* restore */
8269             }
8270             break;
8271          case OPCODE_TEX_SUB_IMAGE3D:
8272             {
8273                const struct gl_pixelstore_attrib save = ctx->Unpack;
8274                ctx->Unpack = ctx->DefaultPacking;
8275                CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
8276                                               n[4].i, n[5].i, n[6].i, n[7].i,
8277                                               n[8].i, n[9].e, n[10].e,
8278                                               n[11].data));
8279                ctx->Unpack = save;      /* restore */
8280             }
8281             break;
8282          case OPCODE_TRANSLATE:
8283             CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
8284             break;
8285          case OPCODE_VIEWPORT:
8286             CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
8287                                       (GLsizei) n[3].i, (GLsizei) n[4].i));
8288             break;
8289          case OPCODE_WINDOW_POS:
8290             CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
8291             break;
8292          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
8293             CALL_ActiveTextureARB(ctx->Exec, (n[1].e));
8294             break;
8295          case OPCODE_COMPRESSED_TEX_IMAGE_1D:  /* GL_ARB_texture_compression */
8296             CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
8297                                                      n[4].i, n[5].i, n[6].i,
8298                                                      n[7].data));
8299             break;
8300          case OPCODE_COMPRESSED_TEX_IMAGE_2D:  /* GL_ARB_texture_compression */
8301             CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
8302                                                      n[4].i, n[5].i, n[6].i,
8303                                                      n[7].i, n[8].data));
8304             break;
8305          case OPCODE_COMPRESSED_TEX_IMAGE_3D:  /* GL_ARB_texture_compression */
8306             CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e,
8307                                                      n[4].i, n[5].i, n[6].i,
8308                                                      n[7].i, n[8].i,
8309                                                      n[9].data));
8310             break;
8311          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:      /* GL_ARB_texture_compress */
8312             CALL_CompressedTexSubImage1DARB(ctx->Exec,
8313                                             (n[1].e, n[2].i, n[3].i, n[4].i,
8314                                              n[5].e, n[6].i, n[7].data));
8315             break;
8316          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:      /* GL_ARB_texture_compress */
8317             CALL_CompressedTexSubImage2DARB(ctx->Exec,
8318                                             (n[1].e, n[2].i, n[3].i, n[4].i,
8319                                              n[5].i, n[6].i, n[7].e, n[8].i,
8320                                              n[9].data));
8321             break;
8322          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:      /* GL_ARB_texture_compress */
8323             CALL_CompressedTexSubImage3DARB(ctx->Exec,
8324                                             (n[1].e, n[2].i, n[3].i, n[4].i,
8325                                              n[5].i, n[6].i, n[7].i, n[8].i,
8326                                              n[9].e, n[10].i, n[11].data));
8327             break;
8328          case OPCODE_SAMPLE_COVERAGE:  /* GL_ARB_multisample */
8329             CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b));
8330             break;
8331          case OPCODE_WINDOW_POS_ARB:   /* GL_ARB_window_pos */
8332             CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f));
8333             break;
8334 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8335          case OPCODE_BIND_PROGRAM_NV:  /* GL_NV_vertex_program */
8336             CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui));
8337             break;
8338 #endif
8339 #if FEATURE_NV_vertex_program
8340          case OPCODE_EXECUTE_PROGRAM_NV:
8341             {
8342                GLfloat v[4];
8343                v[0] = n[3].f;
8344                v[1] = n[4].f;
8345                v[2] = n[5].f;
8346                v[3] = n[6].f;
8347                CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v));
8348             }
8349             break;
8350          case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
8351             CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui,
8352                                                        (GLuint *) n[2].data));
8353             break;
8354          case OPCODE_LOAD_PROGRAM_NV:
8355             CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
8356                                            (const GLubyte *) n[4].data));
8357             break;
8358          case OPCODE_TRACK_MATRIX_NV:
8359             CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
8360             break;
8361 #endif
8362
8363 #if FEATURE_NV_fragment_program
8364          case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
8365             CALL_ProgramLocalParameter4fARB(ctx->Exec,
8366                                             (n[1].e, n[2].ui, n[3].f, n[4].f,
8367                                              n[5].f, n[6].f));
8368             break;
8369          case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
8370             CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i,
8371                                                        (const GLubyte *) n[3].
8372                                                        data, n[4].f, n[5].f,
8373                                                        n[6].f, n[7].f));
8374             break;
8375 #endif
8376
8377          case OPCODE_ACTIVE_STENCIL_FACE_EXT:
8378             CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
8379             break;
8380          case OPCODE_DEPTH_BOUNDS_EXT:
8381             CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
8382             break;
8383 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
8384          case OPCODE_PROGRAM_STRING_ARB:
8385             CALL_ProgramStringARB(ctx->Exec,
8386                                   (n[1].e, n[2].e, n[3].i, n[4].data));
8387             break;
8388 #endif
8389 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program
8390          case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
8391             CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
8392                                                       n[4].f, n[5].f,
8393                                                       n[6].f));
8394             break;
8395 #endif
8396 #if FEATURE_queryobj
8397          case OPCODE_BEGIN_QUERY_ARB:
8398             CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui));
8399             break;
8400          case OPCODE_END_QUERY_ARB:
8401             CALL_EndQueryARB(ctx->Exec, (n[1].e));
8402             break;
8403          case OPCODE_QUERY_COUNTER:
8404             CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e));
8405             break;
8406          case OPCODE_BEGIN_QUERY_INDEXED:
8407             CALL_BeginQueryIndexed(ctx->Exec, (n[1].e, n[2].ui, n[3].ui));
8408             break;
8409          case OPCODE_END_QUERY_INDEXED:
8410             CALL_EndQueryIndexed(ctx->Exec, (n[1].e, n[2].ui));
8411             break;
8412 #endif
8413          case OPCODE_DRAW_BUFFERS_ARB:
8414             {
8415                GLenum buffers[MAX_DRAW_BUFFERS];
8416                GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
8417                for (i = 0; i < count; i++)
8418                   buffers[i] = n[2 + i].e;
8419                CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers));
8420             }
8421             break;
8422 #if FEATURE_EXT_framebuffer_blit
8423          case OPCODE_BLIT_FRAMEBUFFER:
8424             CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
8425                                                 n[5].i, n[6].i, n[7].i, n[8].i,
8426                                                 n[9].i, n[10].e));
8427             break;
8428 #endif
8429
8430          case OPCODE_USE_PROGRAM:
8431             CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui));
8432             break;
8433          case OPCODE_USE_SHADER_PROGRAM_EXT:
8434             CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui));
8435             break;
8436          case OPCODE_ACTIVE_PROGRAM_EXT:
8437             CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui));
8438             break;
8439          case OPCODE_UNIFORM_1F:
8440             CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f));
8441             break;
8442          case OPCODE_UNIFORM_2F:
8443             CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f));
8444             break;
8445          case OPCODE_UNIFORM_3F:
8446             CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f));
8447             break;
8448          case OPCODE_UNIFORM_4F:
8449             CALL_Uniform4fARB(ctx->Exec,
8450                               (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f));
8451             break;
8452          case OPCODE_UNIFORM_1FV:
8453             CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8454             break;
8455          case OPCODE_UNIFORM_2FV:
8456             CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8457             break;
8458          case OPCODE_UNIFORM_3FV:
8459             CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8460             break;
8461          case OPCODE_UNIFORM_4FV:
8462             CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8463             break;
8464          case OPCODE_UNIFORM_1I:
8465             CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i));
8466             break;
8467          case OPCODE_UNIFORM_2I:
8468             CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));
8469             break;
8470          case OPCODE_UNIFORM_3I:
8471             CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
8472             break;
8473          case OPCODE_UNIFORM_4I:
8474             CALL_Uniform4iARB(ctx->Exec,
8475                               (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
8476             break;
8477          case OPCODE_UNIFORM_1IV:
8478             CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8479             break;
8480          case OPCODE_UNIFORM_2IV:
8481             CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8482             break;
8483          case OPCODE_UNIFORM_3IV:
8484             CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8485             break;
8486          case OPCODE_UNIFORM_4IV:
8487             CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));
8488             break;
8489          case OPCODE_UNIFORM_1UI:
8490             /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/
8491             break;
8492          case OPCODE_UNIFORM_2UI:
8493             /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/
8494             break;
8495          case OPCODE_UNIFORM_3UI:
8496             /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/
8497             break;
8498          case OPCODE_UNIFORM_4UI:
8499             /*CALL_Uniform4uiARB(ctx->Exec,
8500                               (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
8501             */
8502             break;
8503          case OPCODE_UNIFORM_1UIV:
8504             /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/
8505             break;
8506          case OPCODE_UNIFORM_2UIV:
8507             /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/
8508             break;
8509          case OPCODE_UNIFORM_3UIV:
8510             /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/
8511             break;
8512          case OPCODE_UNIFORM_4UIV:
8513             /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/
8514             break;
8515          case OPCODE_UNIFORM_MATRIX22:
8516             CALL_UniformMatrix2fvARB(ctx->Exec,
8517                                      (n[1].i, n[2].i, n[3].b, n[4].data));
8518             break;
8519          case OPCODE_UNIFORM_MATRIX33:
8520             CALL_UniformMatrix3fvARB(ctx->Exec,
8521                                      (n[1].i, n[2].i, n[3].b, n[4].data));
8522             break;
8523          case OPCODE_UNIFORM_MATRIX44:
8524             CALL_UniformMatrix4fvARB(ctx->Exec,
8525                                      (n[1].i, n[2].i, n[3].b, n[4].data));
8526             break;
8527          case OPCODE_UNIFORM_MATRIX23:
8528             CALL_UniformMatrix2x3fv(ctx->Exec,
8529                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8530             break;
8531          case OPCODE_UNIFORM_MATRIX32:
8532             CALL_UniformMatrix3x2fv(ctx->Exec,
8533                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8534             break;
8535          case OPCODE_UNIFORM_MATRIX24:
8536             CALL_UniformMatrix2x4fv(ctx->Exec,
8537                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8538             break;
8539          case OPCODE_UNIFORM_MATRIX42:
8540             CALL_UniformMatrix4x2fv(ctx->Exec,
8541                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8542             break;
8543          case OPCODE_UNIFORM_MATRIX34:
8544             CALL_UniformMatrix3x4fv(ctx->Exec,
8545                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8546             break;
8547          case OPCODE_UNIFORM_MATRIX43:
8548             CALL_UniformMatrix4x3fv(ctx->Exec,
8549                                     (n[1].i, n[2].i, n[3].b, n[4].data));
8550             break;
8551
8552          case OPCODE_CLAMP_COLOR:
8553             CALL_ClampColorARB(ctx->Exec, (n[1].e, n[2].e));
8554             break;
8555
8556          case OPCODE_TEX_BUMP_PARAMETER_ATI:
8557             {
8558                GLfloat values[4];
8559                GLuint i, pname = n[1].ui;
8560
8561                for (i = 0; i < 4; i++)
8562                   values[i] = n[1 + i].f;
8563                CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values));
8564             }
8565             break;
8566 #if FEATURE_ATI_fragment_shader
8567          case OPCODE_BIND_FRAGMENT_SHADER_ATI:
8568             CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
8569             break;
8570          case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
8571             {
8572                GLfloat values[4];
8573                GLuint i, dst = n[1].ui;
8574
8575                for (i = 0; i < 4; i++)
8576                   values[i] = n[1 + i].f;
8577                CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values));
8578             }
8579             break;
8580 #endif
8581          case OPCODE_ATTR_1F_NV:
8582             CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
8583             break;
8584          case OPCODE_ATTR_2F_NV:
8585             /* Really shouldn't have to do this - the Node structure
8586              * is convenient, but it would be better to store the data
8587              * packed appropriately so that it can be sent directly
8588              * on.  With x86_64 becoming common, this will start to
8589              * matter more.
8590              */
8591             if (sizeof(Node) == sizeof(GLfloat))
8592                CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
8593             else
8594                CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f));
8595             break;
8596          case OPCODE_ATTR_3F_NV:
8597             if (sizeof(Node) == sizeof(GLfloat))
8598                CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
8599             else
8600                CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
8601                                                  n[4].f));
8602             break;
8603          case OPCODE_ATTR_4F_NV:
8604             if (sizeof(Node) == sizeof(GLfloat))
8605                CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
8606             else
8607                CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
8608                                                  n[4].f, n[5].f));
8609             break;
8610          case OPCODE_ATTR_1F_ARB:
8611             CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
8612             break;
8613          case OPCODE_ATTR_2F_ARB:
8614             /* Really shouldn't have to do this - the Node structure
8615              * is convenient, but it would be better to store the data
8616              * packed appropriately so that it can be sent directly
8617              * on.  With x86_64 becoming common, this will start to
8618              * matter more.
8619              */
8620             if (sizeof(Node) == sizeof(GLfloat))
8621                CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
8622             else
8623                CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f));
8624             break;
8625          case OPCODE_ATTR_3F_ARB:
8626             if (sizeof(Node) == sizeof(GLfloat))
8627                CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
8628             else
8629                CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
8630                                                   n[4].f));
8631             break;
8632          case OPCODE_ATTR_4F_ARB:
8633             if (sizeof(Node) == sizeof(GLfloat))
8634                CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
8635             else
8636                CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
8637                                                   n[4].f, n[5].f));
8638             break;
8639          case OPCODE_MATERIAL:
8640             if (sizeof(Node) == sizeof(GLfloat))
8641                CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
8642             else {
8643                GLfloat f[4];
8644                f[0] = n[3].f;
8645                f[1] = n[4].f;
8646                f[2] = n[5].f;
8647                f[3] = n[6].f;
8648                CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f));
8649             }
8650             break;
8651          case OPCODE_BEGIN:
8652             CALL_Begin(ctx->Exec, (n[1].e));
8653             break;
8654          case OPCODE_END:
8655             CALL_End(ctx->Exec, ());
8656             break;
8657          case OPCODE_RECTF:
8658             CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
8659             break;
8660          case OPCODE_EVAL_C1:
8661             CALL_EvalCoord1f(ctx->Exec, (n[1].f));
8662             break;
8663          case OPCODE_EVAL_C2:
8664             CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
8665             break;
8666          case OPCODE_EVAL_P1:
8667             CALL_EvalPoint1(ctx->Exec, (n[1].i));
8668             break;
8669          case OPCODE_EVAL_P2:
8670             CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
8671             break;
8672
8673          /* GL_EXT_texture_integer */
8674          case OPCODE_CLEARCOLOR_I:
8675             CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
8676             break;
8677          case OPCODE_CLEARCOLOR_UI:
8678             CALL_ClearColorIuiEXT(ctx->Exec,
8679                                   (n[1].ui, n[2].ui, n[3].ui, n[4].ui));
8680             break;
8681          case OPCODE_TEXPARAMETER_I:
8682             {
8683                GLint params[4];
8684                params[0] = n[3].i;
8685                params[1] = n[4].i;
8686                params[2] = n[5].i;
8687                params[3] = n[6].i;
8688                CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params));
8689             }
8690             break;
8691          case OPCODE_TEXPARAMETER_UI:
8692             {
8693                GLuint params[4];
8694                params[0] = n[3].ui;
8695                params[1] = n[4].ui;
8696                params[2] = n[5].ui;
8697                params[3] = n[6].ui;
8698                CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params));
8699             }
8700             break;
8701
8702          case OPCODE_VERTEX_ATTRIB_DIVISOR:
8703             /* GL_ARB_instanced_arrays */
8704             CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui));
8705             break;
8706
8707          case OPCODE_TEXTURE_BARRIER_NV:
8708             CALL_TextureBarrierNV(ctx->Exec, ());
8709             break;
8710
8711          /* GL_EXT/ARB_transform_feedback */
8712          case OPCODE_BEGIN_TRANSFORM_FEEDBACK:
8713             CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e));
8714             break;
8715          case OPCODE_END_TRANSFORM_FEEDBACK:
8716             CALL_EndTransformFeedbackEXT(ctx->Exec, ());
8717             break;
8718          case OPCODE_BIND_TRANSFORM_FEEDBACK:
8719             CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
8720             break;
8721          case OPCODE_PAUSE_TRANSFORM_FEEDBACK:
8722             CALL_PauseTransformFeedback(ctx->Exec, ());
8723             break;
8724          case OPCODE_RESUME_TRANSFORM_FEEDBACK:
8725             CALL_ResumeTransformFeedback(ctx->Exec, ());
8726             break;
8727          case OPCODE_DRAW_TRANSFORM_FEEDBACK:
8728             CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
8729             break;
8730
8731
8732          case OPCODE_BIND_SAMPLER:
8733             CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui));
8734             break;
8735          case OPCODE_SAMPLER_PARAMETERIV:
8736             {
8737                GLint params[4];
8738                params[0] = n[3].i;
8739                params[1] = n[4].i;
8740                params[2] = n[5].i;
8741                params[3] = n[6].i;
8742                CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params));
8743             }
8744             break;
8745          case OPCODE_SAMPLER_PARAMETERFV:
8746             {
8747                GLfloat params[4];
8748                params[0] = n[3].f;
8749                params[1] = n[4].f;
8750                params[2] = n[5].f;
8751                params[3] = n[6].f;
8752                CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params));
8753             }
8754             break;
8755          case OPCODE_SAMPLER_PARAMETERIIV:
8756             {
8757                GLint params[4];
8758                params[0] = n[3].i;
8759                params[1] = n[4].i;
8760                params[2] = n[5].i;
8761                params[3] = n[6].i;
8762                CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params));
8763             }
8764             break;
8765          case OPCODE_SAMPLER_PARAMETERUIV:
8766             {
8767                GLuint params[4];
8768                params[0] = n[3].ui;
8769                params[1] = n[4].ui;
8770                params[2] = n[5].ui;
8771                params[3] = n[6].ui;
8772                CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params));
8773             }
8774             break;
8775
8776          /* GL_ARB_geometry_shader4 */
8777          case OPCODE_PROGRAM_PARAMETERI:
8778             CALL_ProgramParameteriARB(ctx->Exec, (n[1].ui, n[2].e, n[3].i));
8779             break;
8780          case OPCODE_FRAMEBUFFER_TEXTURE:
8781             CALL_FramebufferTextureARB(ctx->Exec, (n[1].e, n[2].e,
8782                                                    n[3].ui, n[4].i));
8783             break;
8784          case OPCODE_FRAMEBUFFER_TEXTURE_FACE:
8785             CALL_FramebufferTextureFaceARB(ctx->Exec, (n[1].e, n[2].e,
8786                                                        n[3].ui, n[4].i, n[5].e));
8787             break;
8788
8789          /* GL_ARB_sync */
8790          case OPCODE_WAIT_SYNC:
8791             {
8792                union uint64_pair p;
8793                p.uint32[0] = n[3].ui;
8794                p.uint32[1] = n[4].ui;
8795                CALL_WaitSync(ctx->Exec, (n[1].data, n[2].bf, p.uint64));
8796             }
8797             break;
8798
8799          /* GL_NV_conditional_render */
8800          case OPCODE_BEGIN_CONDITIONAL_RENDER:
8801             CALL_BeginConditionalRenderNV(ctx->Exec, (n[1].i, n[2].e));
8802             break;
8803          case OPCODE_END_CONDITIONAL_RENDER:
8804             CALL_EndConditionalRenderNV(ctx->Exec, ());
8805             break;
8806
8807          case OPCODE_CONTINUE:
8808             n = (Node *) n[1].next;
8809             break;
8810          case OPCODE_END_OF_LIST:
8811             done = GL_TRUE;
8812             break;
8813          default:
8814             {
8815                char msg[1000];
8816                _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d",
8817                              (int) opcode);
8818                _mesa_problem(ctx, "%s", msg);
8819             }
8820             done = GL_TRUE;
8821          }
8822
8823          /* increment n to point to next compiled command */
8824          if (opcode != OPCODE_CONTINUE) {
8825             n += InstSize[opcode];
8826          }
8827       }
8828    }
8829
8830    if (ctx->Driver.EndCallList)
8831       ctx->Driver.EndCallList(ctx);
8832
8833    ctx->ListState.CallDepth--;
8834 }
8835
8836
8837
8838 /**********************************************************************/
8839 /*                           GL functions                             */
8840 /**********************************************************************/
8841
8842 /**
8843  * Test if a display list number is valid.
8844  */
8845 static GLboolean GLAPIENTRY
8846 _mesa_IsList(GLuint list)
8847 {
8848    GET_CURRENT_CONTEXT(ctx);
8849    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
8850    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
8851    return islist(ctx, list);
8852 }
8853
8854
8855 /**
8856  * Delete a sequence of consecutive display lists.
8857  */
8858 static void GLAPIENTRY
8859 _mesa_DeleteLists(GLuint list, GLsizei range)
8860 {
8861    GET_CURRENT_CONTEXT(ctx);
8862    GLuint i;
8863    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
8864    ASSERT_OUTSIDE_BEGIN_END(ctx);
8865
8866    if (range < 0) {
8867       _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
8868       return;
8869    }
8870    for (i = list; i < list + range; i++) {
8871       destroy_list(ctx, i);
8872    }
8873 }
8874
8875
8876 /**
8877  * Return a display list number, n, such that lists n through n+range-1
8878  * are free.
8879  */
8880 static GLuint GLAPIENTRY
8881 _mesa_GenLists(GLsizei range)
8882 {
8883    GET_CURRENT_CONTEXT(ctx);
8884    GLuint base;
8885    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
8886    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
8887
8888    if (range < 0) {
8889       _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
8890       return 0;
8891    }
8892    if (range == 0) {
8893       return 0;
8894    }
8895
8896    /*
8897     * Make this an atomic operation
8898     */
8899    _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
8900
8901    base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
8902    if (base) {
8903       /* reserve the list IDs by with empty/dummy lists */
8904       GLint i;
8905       for (i = 0; i < range; i++) {
8906          _mesa_HashInsert(ctx->Shared->DisplayList, base + i,
8907                           make_list(base + i, 1));
8908       }
8909    }
8910
8911    _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
8912
8913    return base;
8914 }
8915
8916
8917 /**
8918  * Begin a new display list.
8919  */
8920 static void GLAPIENTRY
8921 _mesa_NewList(GLuint name, GLenum mode)
8922 {
8923    GET_CURRENT_CONTEXT(ctx);
8924
8925    FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
8926    ASSERT_OUTSIDE_BEGIN_END(ctx);
8927
8928    if (MESA_VERBOSE & VERBOSE_API)
8929       _mesa_debug(ctx, "glNewList %u %s\n", name,
8930                   _mesa_lookup_enum_by_nr(mode));
8931
8932    if (name == 0) {
8933       _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
8934       return;
8935    }
8936
8937    if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
8938       _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
8939       return;
8940    }
8941
8942    if (ctx->ListState.CurrentList) {
8943       /* already compiling a display list */
8944       _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
8945       return;
8946    }
8947
8948    ctx->CompileFlag = GL_TRUE;
8949    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
8950
8951    /* Reset acumulated list state:
8952     */
8953    invalidate_saved_current_state( ctx );
8954
8955    /* Allocate new display list */
8956    ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
8957    ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
8958    ctx->ListState.CurrentPos = 0;
8959
8960    ctx->Driver.NewList(ctx, name, mode);
8961
8962    ctx->CurrentDispatch = ctx->Save;
8963    _glapi_set_dispatch(ctx->CurrentDispatch);
8964 }
8965
8966
8967 /**
8968  * End definition of current display list. 
8969  */
8970 static void GLAPIENTRY
8971 _mesa_EndList(void)
8972 {
8973    GET_CURRENT_CONTEXT(ctx);
8974    SAVE_FLUSH_VERTICES(ctx);
8975    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
8976
8977    if (MESA_VERBOSE & VERBOSE_API)
8978       _mesa_debug(ctx, "glEndList\n");
8979
8980    /* Check that a list is under construction */
8981    if (!ctx->ListState.CurrentList) {
8982       _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
8983       return;
8984    }
8985    
8986    /* Call before emitting END_OF_LIST, in case the driver wants to
8987     * emit opcodes itself.
8988     */
8989    ctx->Driver.EndList(ctx);
8990
8991    (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
8992
8993    /* Destroy old list, if any */
8994    destroy_list(ctx, ctx->ListState.CurrentList->Name);
8995
8996    /* Install the new list */
8997    _mesa_HashInsert(ctx->Shared->DisplayList,
8998                     ctx->ListState.CurrentList->Name,
8999                     ctx->ListState.CurrentList);
9000
9001
9002    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
9003       mesa_print_display_list(ctx->ListState.CurrentList->Name);
9004
9005    ctx->ListState.CurrentList = NULL;
9006    ctx->ExecuteFlag = GL_TRUE;
9007    ctx->CompileFlag = GL_FALSE;
9008
9009    ctx->CurrentDispatch = ctx->Exec;
9010    _glapi_set_dispatch(ctx->CurrentDispatch);
9011 }
9012
9013
9014 void GLAPIENTRY
9015 _mesa_CallList(GLuint list)
9016 {
9017    GLboolean save_compile_flag;
9018    GET_CURRENT_CONTEXT(ctx);
9019    FLUSH_CURRENT(ctx, 0);
9020
9021    if (MESA_VERBOSE & VERBOSE_API)
9022       _mesa_debug(ctx, "glCallList %d\n", list);
9023
9024    if (list == 0) {
9025       _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
9026       return;
9027    }
9028
9029    if (0)
9030       mesa_print_display_list( list );
9031
9032    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off,
9033     * execute the display list, and restore the CompileFlag.
9034     */
9035    save_compile_flag = ctx->CompileFlag;
9036    if (save_compile_flag) {
9037       ctx->CompileFlag = GL_FALSE;
9038    }
9039
9040    execute_list(ctx, list);
9041    ctx->CompileFlag = save_compile_flag;
9042
9043    /* also restore API function pointers to point to "save" versions */
9044    if (save_compile_flag) {
9045       ctx->CurrentDispatch = ctx->Save;
9046       _glapi_set_dispatch(ctx->CurrentDispatch);
9047    }
9048 }
9049
9050
9051 /**
9052  * Execute glCallLists:  call multiple display lists.
9053  */
9054 void GLAPIENTRY
9055 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
9056 {
9057    GET_CURRENT_CONTEXT(ctx);
9058    GLint i;
9059    GLboolean save_compile_flag;
9060
9061    if (MESA_VERBOSE & VERBOSE_API)
9062       _mesa_debug(ctx, "glCallLists %d\n", n);
9063
9064    switch (type) {
9065    case GL_BYTE:
9066    case GL_UNSIGNED_BYTE:
9067    case GL_SHORT:
9068    case GL_UNSIGNED_SHORT:
9069    case GL_INT:
9070    case GL_UNSIGNED_INT:
9071    case GL_FLOAT:
9072    case GL_2_BYTES:
9073    case GL_3_BYTES:
9074    case GL_4_BYTES:
9075       /* OK */
9076       break;
9077    default:
9078       _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
9079       return;
9080    }
9081
9082    /* Save the CompileFlag status, turn it off, execute display list,
9083     * and restore the CompileFlag.
9084     */
9085    save_compile_flag = ctx->CompileFlag;
9086    ctx->CompileFlag = GL_FALSE;
9087
9088    for (i = 0; i < n; i++) {
9089       GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
9090       execute_list(ctx, list);
9091    }
9092
9093    ctx->CompileFlag = save_compile_flag;
9094
9095    /* also restore API function pointers to point to "save" versions */
9096    if (save_compile_flag) {
9097       ctx->CurrentDispatch = ctx->Save;
9098       _glapi_set_dispatch(ctx->CurrentDispatch);
9099    }
9100 }
9101
9102
9103 /**
9104  * Set the offset added to list numbers in glCallLists.
9105  */
9106 static void GLAPIENTRY
9107 _mesa_ListBase(GLuint base)
9108 {
9109    GET_CURRENT_CONTEXT(ctx);
9110    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
9111    ASSERT_OUTSIDE_BEGIN_END(ctx);
9112    ctx->List.ListBase = base;
9113 }
9114
9115
9116 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
9117  */
9118 static void GLAPIENTRY
9119 exec_Finish(void)
9120 {
9121    GET_CURRENT_CONTEXT(ctx);
9122    FLUSH_VERTICES(ctx, 0);
9123    CALL_Finish(ctx->Exec, ());
9124 }
9125
9126 static void GLAPIENTRY
9127 exec_Flush(void)
9128 {
9129    GET_CURRENT_CONTEXT(ctx);
9130    FLUSH_VERTICES(ctx, 0);
9131    CALL_Flush(ctx->Exec, ());
9132 }
9133
9134 static void GLAPIENTRY
9135 exec_GetBooleanv(GLenum pname, GLboolean *params)
9136 {
9137    GET_CURRENT_CONTEXT(ctx);
9138    FLUSH_VERTICES(ctx, 0);
9139    CALL_GetBooleanv(ctx->Exec, (pname, params));
9140 }
9141
9142 static void GLAPIENTRY
9143 exec_GetClipPlane(GLenum plane, GLdouble * equation)
9144 {
9145    GET_CURRENT_CONTEXT(ctx);
9146    FLUSH_VERTICES(ctx, 0);
9147    CALL_GetClipPlane(ctx->Exec, (plane, equation));
9148 }
9149
9150 static void GLAPIENTRY
9151 exec_GetDoublev(GLenum pname, GLdouble *params)
9152 {
9153    GET_CURRENT_CONTEXT(ctx);
9154    FLUSH_VERTICES(ctx, 0);
9155    CALL_GetDoublev(ctx->Exec, (pname, params));
9156 }
9157
9158 static GLenum GLAPIENTRY
9159 exec_GetError(void)
9160 {
9161    GET_CURRENT_CONTEXT(ctx);
9162    FLUSH_VERTICES(ctx, 0);
9163    return CALL_GetError(ctx->Exec, ());
9164 }
9165
9166 static void GLAPIENTRY
9167 exec_GetFloatv(GLenum pname, GLfloat *params)
9168 {
9169    GET_CURRENT_CONTEXT(ctx);
9170    FLUSH_VERTICES(ctx, 0);
9171    CALL_GetFloatv(ctx->Exec, (pname, params));
9172 }
9173
9174 static void GLAPIENTRY
9175 exec_GetIntegerv(GLenum pname, GLint *params)
9176 {
9177    GET_CURRENT_CONTEXT(ctx);
9178    FLUSH_VERTICES(ctx, 0);
9179    CALL_GetIntegerv(ctx->Exec, (pname, params));
9180 }
9181
9182 static void GLAPIENTRY
9183 exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params)
9184 {
9185    GET_CURRENT_CONTEXT(ctx);
9186    FLUSH_VERTICES(ctx, 0);
9187    CALL_GetLightfv(ctx->Exec, (light, pname, params));
9188 }
9189
9190 static void GLAPIENTRY
9191 exec_GetLightiv(GLenum light, GLenum pname, GLint *params)
9192 {
9193    GET_CURRENT_CONTEXT(ctx);
9194    FLUSH_VERTICES(ctx, 0);
9195    CALL_GetLightiv(ctx->Exec, (light, pname, params));
9196 }
9197
9198 static void GLAPIENTRY
9199 exec_GetMapdv(GLenum target, GLenum query, GLdouble * v)
9200 {
9201    GET_CURRENT_CONTEXT(ctx);
9202    FLUSH_VERTICES(ctx, 0);
9203    CALL_GetMapdv(ctx->Exec, (target, query, v));
9204 }
9205
9206 static void GLAPIENTRY
9207 exec_GetMapfv(GLenum target, GLenum query, GLfloat * v)
9208 {
9209    GET_CURRENT_CONTEXT(ctx);
9210    FLUSH_VERTICES(ctx, 0);
9211    CALL_GetMapfv(ctx->Exec, (target, query, v));
9212 }
9213
9214 static void GLAPIENTRY
9215 exec_GetMapiv(GLenum target, GLenum query, GLint * v)
9216 {
9217    GET_CURRENT_CONTEXT(ctx);
9218    FLUSH_VERTICES(ctx, 0);
9219    CALL_GetMapiv(ctx->Exec, (target, query, v));
9220 }
9221
9222 static void GLAPIENTRY
9223 exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
9224 {
9225    GET_CURRENT_CONTEXT(ctx);
9226    FLUSH_VERTICES(ctx, 0);
9227    CALL_GetMaterialfv(ctx->Exec, (face, pname, params));
9228 }
9229
9230 static void GLAPIENTRY
9231 exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params)
9232 {
9233    GET_CURRENT_CONTEXT(ctx);
9234    FLUSH_VERTICES(ctx, 0);
9235    CALL_GetMaterialiv(ctx->Exec, (face, pname, params));
9236 }
9237
9238 static void GLAPIENTRY
9239 exec_GetPixelMapfv(GLenum map, GLfloat *values)
9240 {
9241    GET_CURRENT_CONTEXT(ctx);
9242    FLUSH_VERTICES(ctx, 0);
9243    CALL_GetPixelMapfv(ctx->Exec, (map, values));
9244 }
9245
9246 static void GLAPIENTRY
9247 exec_GetPixelMapuiv(GLenum map, GLuint *values)
9248 {
9249    GET_CURRENT_CONTEXT(ctx);
9250    FLUSH_VERTICES(ctx, 0);
9251    CALL_GetPixelMapuiv(ctx->Exec, (map, values));
9252 }
9253
9254 static void GLAPIENTRY
9255 exec_GetPixelMapusv(GLenum map, GLushort *values)
9256 {
9257    GET_CURRENT_CONTEXT(ctx);
9258    FLUSH_VERTICES(ctx, 0);
9259    CALL_GetPixelMapusv(ctx->Exec, (map, values));
9260 }
9261
9262 static void GLAPIENTRY
9263 exec_GetPolygonStipple(GLubyte * dest)
9264 {
9265    GET_CURRENT_CONTEXT(ctx);
9266    FLUSH_VERTICES(ctx, 0);
9267    CALL_GetPolygonStipple(ctx->Exec, (dest));
9268 }
9269
9270 static const GLubyte *GLAPIENTRY
9271 exec_GetString(GLenum name)
9272 {
9273    GET_CURRENT_CONTEXT(ctx);
9274    FLUSH_VERTICES(ctx, 0);
9275    return CALL_GetString(ctx->Exec, (name));
9276 }
9277
9278 static void GLAPIENTRY
9279 exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
9280 {
9281    GET_CURRENT_CONTEXT(ctx);
9282    FLUSH_VERTICES(ctx, 0);
9283    CALL_GetTexEnvfv(ctx->Exec, (target, pname, params));
9284 }
9285
9286 static void GLAPIENTRY
9287 exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params)
9288 {
9289    GET_CURRENT_CONTEXT(ctx);
9290    FLUSH_VERTICES(ctx, 0);
9291    CALL_GetTexEnviv(ctx->Exec, (target, pname, params));
9292 }
9293
9294 static void GLAPIENTRY
9295 exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
9296 {
9297    GET_CURRENT_CONTEXT(ctx);
9298    FLUSH_VERTICES(ctx, 0);
9299    CALL_GetTexGendv(ctx->Exec, (coord, pname, params));
9300 }
9301
9302 static void GLAPIENTRY
9303 exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
9304 {
9305    GET_CURRENT_CONTEXT(ctx);
9306    FLUSH_VERTICES(ctx, 0);
9307    CALL_GetTexGenfv(ctx->Exec, (coord, pname, params));
9308 }
9309
9310 static void GLAPIENTRY
9311 exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params)
9312 {
9313    GET_CURRENT_CONTEXT(ctx);
9314    FLUSH_VERTICES(ctx, 0);
9315    CALL_GetTexGeniv(ctx->Exec, (coord, pname, params));
9316 }
9317
9318 static void GLAPIENTRY
9319 exec_GetTexImage(GLenum target, GLint level, GLenum format,
9320                  GLenum type, GLvoid * pixels)
9321 {
9322    GET_CURRENT_CONTEXT(ctx);
9323    FLUSH_VERTICES(ctx, 0);
9324    CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels));
9325 }
9326
9327 static void GLAPIENTRY
9328 exec_GetTexLevelParameterfv(GLenum target, GLint level,
9329                             GLenum pname, GLfloat *params)
9330 {
9331    GET_CURRENT_CONTEXT(ctx);
9332    FLUSH_VERTICES(ctx, 0);
9333    CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params));
9334 }
9335
9336 static void GLAPIENTRY
9337 exec_GetTexLevelParameteriv(GLenum target, GLint level,
9338                             GLenum pname, GLint *params)
9339 {
9340    GET_CURRENT_CONTEXT(ctx);
9341    FLUSH_VERTICES(ctx, 0);
9342    CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params));
9343 }
9344
9345 static void GLAPIENTRY
9346 exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
9347 {
9348    GET_CURRENT_CONTEXT(ctx);
9349    FLUSH_VERTICES(ctx, 0);
9350    CALL_GetTexParameterfv(ctx->Exec, (target, pname, params));
9351 }
9352
9353 static void GLAPIENTRY
9354 exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
9355 {
9356    GET_CURRENT_CONTEXT(ctx);
9357    FLUSH_VERTICES(ctx, 0);
9358    CALL_GetTexParameteriv(ctx->Exec, (target, pname, params));
9359 }
9360
9361 static GLboolean GLAPIENTRY
9362 exec_IsEnabled(GLenum cap)
9363 {
9364    GET_CURRENT_CONTEXT(ctx);
9365    FLUSH_VERTICES(ctx, 0);
9366    return CALL_IsEnabled(ctx->Exec, (cap));
9367 }
9368
9369 static void GLAPIENTRY
9370 exec_PixelStoref(GLenum pname, GLfloat param)
9371 {
9372    GET_CURRENT_CONTEXT(ctx);
9373    FLUSH_VERTICES(ctx, 0);
9374    CALL_PixelStoref(ctx->Exec, (pname, param));
9375 }
9376
9377 static void GLAPIENTRY
9378 exec_PixelStorei(GLenum pname, GLint param)
9379 {
9380    GET_CURRENT_CONTEXT(ctx);
9381    FLUSH_VERTICES(ctx, 0);
9382    CALL_PixelStorei(ctx->Exec, (pname, param));
9383 }
9384
9385 static void GLAPIENTRY
9386 exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
9387                 GLenum format, GLenum type, GLvoid * pixels)
9388 {
9389    GET_CURRENT_CONTEXT(ctx);
9390    FLUSH_VERTICES(ctx, 0);
9391    CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels));
9392 }
9393
9394 static GLint GLAPIENTRY
9395 exec_RenderMode(GLenum mode)
9396 {
9397    GET_CURRENT_CONTEXT(ctx);
9398    FLUSH_VERTICES(ctx, 0);
9399    return CALL_RenderMode(ctx->Exec, (mode));
9400 }
9401
9402 static void GLAPIENTRY
9403 exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
9404 {
9405    GET_CURRENT_CONTEXT(ctx);
9406    FLUSH_VERTICES(ctx, 0);
9407    CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer));
9408 }
9409
9410 static void GLAPIENTRY
9411 exec_SelectBuffer(GLsizei size, GLuint * buffer)
9412 {
9413    GET_CURRENT_CONTEXT(ctx);
9414    FLUSH_VERTICES(ctx, 0);
9415    CALL_SelectBuffer(ctx->Exec, (size, buffer));
9416 }
9417
9418 static GLboolean GLAPIENTRY
9419 exec_AreTexturesResident(GLsizei n, const GLuint * texName,
9420                          GLboolean * residences)
9421 {
9422    GET_CURRENT_CONTEXT(ctx);
9423    FLUSH_VERTICES(ctx, 0);
9424    return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences));
9425 }
9426
9427 static void GLAPIENTRY
9428 exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
9429 {
9430    GET_CURRENT_CONTEXT(ctx);
9431    FLUSH_VERTICES(ctx, 0);
9432    CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr));
9433 }
9434
9435 static void GLAPIENTRY
9436 exec_DeleteTextures(GLsizei n, const GLuint * texName)
9437 {
9438    GET_CURRENT_CONTEXT(ctx);
9439    FLUSH_VERTICES(ctx, 0);
9440    CALL_DeleteTextures(ctx->Exec, (n, texName));
9441 }
9442
9443 static void GLAPIENTRY
9444 exec_DisableClientState(GLenum cap)
9445 {
9446    GET_CURRENT_CONTEXT(ctx);
9447    FLUSH_VERTICES(ctx, 0);
9448    CALL_DisableClientState(ctx->Exec, (cap));
9449 }
9450
9451 static void GLAPIENTRY
9452 exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr)
9453 {
9454    GET_CURRENT_CONTEXT(ctx);
9455    FLUSH_VERTICES(ctx, 0);
9456    CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr));
9457 }
9458
9459 static void GLAPIENTRY
9460 exec_EnableClientState(GLenum cap)
9461 {
9462    GET_CURRENT_CONTEXT(ctx);
9463    FLUSH_VERTICES(ctx, 0);
9464    CALL_EnableClientState(ctx->Exec, (cap));
9465 }
9466
9467 static void GLAPIENTRY
9468 exec_GenTextures(GLsizei n, GLuint * texName)
9469 {
9470    GET_CURRENT_CONTEXT(ctx);
9471    FLUSH_VERTICES(ctx, 0);
9472    CALL_GenTextures(ctx->Exec, (n, texName));
9473 }
9474
9475 static void GLAPIENTRY
9476 exec_GetPointerv(GLenum pname, GLvoid **params)
9477 {
9478    GET_CURRENT_CONTEXT(ctx);
9479    FLUSH_VERTICES(ctx, 0);
9480    CALL_GetPointerv(ctx->Exec, (pname, params));
9481 }
9482
9483 static void GLAPIENTRY
9484 exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
9485 {
9486    GET_CURRENT_CONTEXT(ctx);
9487    FLUSH_VERTICES(ctx, 0);
9488    CALL_IndexPointer(ctx->Exec, (type, stride, ptr));
9489 }
9490
9491 static void GLAPIENTRY
9492 exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer)
9493 {
9494    GET_CURRENT_CONTEXT(ctx);
9495    FLUSH_VERTICES(ctx, 0);
9496    CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer));
9497 }
9498
9499 static GLboolean GLAPIENTRY
9500 exec_IsTexture(GLuint texture)
9501 {
9502    GET_CURRENT_CONTEXT(ctx);
9503    FLUSH_VERTICES(ctx, 0);
9504    return CALL_IsTexture(ctx->Exec, (texture));
9505 }
9506
9507 static void GLAPIENTRY
9508 exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
9509 {
9510    GET_CURRENT_CONTEXT(ctx);
9511    FLUSH_VERTICES(ctx, 0);
9512    CALL_NormalPointer(ctx->Exec, (type, stride, ptr));
9513 }
9514
9515 static void GLAPIENTRY
9516 exec_PopClientAttrib(void)
9517 {
9518    GET_CURRENT_CONTEXT(ctx);
9519    FLUSH_VERTICES(ctx, 0);
9520    CALL_PopClientAttrib(ctx->Exec, ());
9521 }
9522
9523 static void GLAPIENTRY
9524 exec_PushClientAttrib(GLbitfield mask)
9525 {
9526    GET_CURRENT_CONTEXT(ctx);
9527    FLUSH_VERTICES(ctx, 0);
9528    CALL_PushClientAttrib(ctx->Exec, (mask));
9529 }
9530
9531 static void GLAPIENTRY
9532 exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
9533                      const GLvoid *ptr)
9534 {
9535    GET_CURRENT_CONTEXT(ctx);
9536    FLUSH_VERTICES(ctx, 0);
9537    CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr));
9538 }
9539
9540 static void GLAPIENTRY
9541 exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img)
9542 {
9543    GET_CURRENT_CONTEXT(ctx);
9544    FLUSH_VERTICES(ctx, 0);
9545    CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img));
9546 }
9547
9548 static void GLAPIENTRY
9549 exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
9550                    const GLvoid *ptr)
9551 {
9552    GET_CURRENT_CONTEXT(ctx);
9553    FLUSH_VERTICES(ctx, 0);
9554    CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr));
9555 }
9556
9557 static void GLAPIENTRY
9558 exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
9559                              GLint x, GLint y, GLsizei width)
9560 {
9561    GET_CURRENT_CONTEXT(ctx);
9562    FLUSH_VERTICES(ctx, 0);
9563    CALL_CopyConvolutionFilter1D(ctx->Exec,
9564                                 (target, internalFormat, x, y, width));
9565 }
9566
9567 static void GLAPIENTRY
9568 exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
9569                              GLint x, GLint y, GLsizei width, GLsizei height)
9570 {
9571    GET_CURRENT_CONTEXT(ctx);
9572    FLUSH_VERTICES(ctx, 0);
9573    CALL_CopyConvolutionFilter2D(ctx->Exec,
9574                                 (target, internalFormat, x, y, width,
9575                                  height));
9576 }
9577
9578 static void GLAPIENTRY
9579 exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data)
9580 {
9581    GET_CURRENT_CONTEXT(ctx);
9582    FLUSH_VERTICES(ctx, 0);
9583    CALL_GetColorTable(ctx->Exec, (target, format, type, data));
9584 }
9585
9586 static void GLAPIENTRY
9587 exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params)
9588 {
9589    GET_CURRENT_CONTEXT(ctx);
9590    FLUSH_VERTICES(ctx, 0);
9591    CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params));
9592 }
9593
9594 static void GLAPIENTRY
9595 exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params)
9596 {
9597    GET_CURRENT_CONTEXT(ctx);
9598    FLUSH_VERTICES(ctx, 0);
9599    CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params));
9600 }
9601
9602 static void GLAPIENTRY
9603 exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
9604                           GLvoid * image)
9605 {
9606    GET_CURRENT_CONTEXT(ctx);
9607    FLUSH_VERTICES(ctx, 0);
9608    CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image));
9609 }
9610
9611 static void GLAPIENTRY
9612 exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
9613 {
9614    GET_CURRENT_CONTEXT(ctx);
9615    FLUSH_VERTICES(ctx, 0);
9616    CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params));
9617 }
9618
9619 static void GLAPIENTRY
9620 exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
9621 {
9622    GET_CURRENT_CONTEXT(ctx);
9623    FLUSH_VERTICES(ctx, 0);
9624    CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params));
9625 }
9626
9627 static void GLAPIENTRY
9628 exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
9629                   GLenum type, GLvoid *values)
9630 {
9631    GET_CURRENT_CONTEXT(ctx);
9632    FLUSH_VERTICES(ctx, 0);
9633    CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values));
9634 }
9635
9636 static void GLAPIENTRY
9637 exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params)
9638 {
9639    GET_CURRENT_CONTEXT(ctx);
9640    FLUSH_VERTICES(ctx, 0);
9641    CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params));
9642 }
9643
9644 static void GLAPIENTRY
9645 exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params)
9646 {
9647    GET_CURRENT_CONTEXT(ctx);
9648    FLUSH_VERTICES(ctx, 0);
9649    CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params));
9650 }
9651
9652 static void GLAPIENTRY
9653 exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
9654                GLenum type, GLvoid *values)
9655 {
9656    GET_CURRENT_CONTEXT(ctx);
9657    FLUSH_VERTICES(ctx, 0);
9658    CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values));
9659 }
9660
9661 static void GLAPIENTRY
9662 exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params)
9663 {
9664    GET_CURRENT_CONTEXT(ctx);
9665    FLUSH_VERTICES(ctx, 0);
9666    CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params));
9667 }
9668
9669 static void GLAPIENTRY
9670 exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params)
9671 {
9672    GET_CURRENT_CONTEXT(ctx);
9673    FLUSH_VERTICES(ctx, 0);
9674    CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params));
9675 }
9676
9677 static void GLAPIENTRY
9678 exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
9679                         GLvoid *row, GLvoid *column, GLvoid *span)
9680 {
9681    GET_CURRENT_CONTEXT(ctx);
9682    FLUSH_VERTICES(ctx, 0);
9683    CALL_GetSeparableFilter(ctx->Exec,
9684                            (target, format, type, row, column, span));
9685 }
9686
9687 static void GLAPIENTRY
9688 exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
9689                        GLsizei width, GLsizei height, GLenum format,
9690                        GLenum type, const GLvoid *row, const GLvoid *column)
9691 {
9692    GET_CURRENT_CONTEXT(ctx);
9693    FLUSH_VERTICES(ctx, 0);
9694    CALL_SeparableFilter2D(ctx->Exec,
9695                           (target, internalFormat, width, height, format,
9696                            type, row, column));
9697 }
9698
9699 static void GLAPIENTRY
9700 exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
9701                      GLsizei count, const GLvoid *ptr)
9702 {
9703    GET_CURRENT_CONTEXT(ctx);
9704    FLUSH_VERTICES(ctx, 0);
9705    CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
9706 }
9707
9708 static void GLAPIENTRY
9709 exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
9710 {
9711    GET_CURRENT_CONTEXT(ctx);
9712    FLUSH_VERTICES(ctx, 0);
9713    CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr));
9714 }
9715
9716 static void GLAPIENTRY
9717 exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
9718                      const GLvoid *ptr)
9719 {
9720    GET_CURRENT_CONTEXT(ctx);
9721    FLUSH_VERTICES(ctx, 0);
9722    CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr));
9723 }
9724
9725 static void GLAPIENTRY
9726 exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
9727                       const GLvoid *ptr)
9728 {
9729    GET_CURRENT_CONTEXT(ctx);
9730    FLUSH_VERTICES(ctx, 0);
9731    CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr));
9732 }
9733
9734 static void GLAPIENTRY
9735 exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
9736                         GLsizei count, const GLvoid *ptr)
9737 {
9738    GET_CURRENT_CONTEXT(ctx);
9739    FLUSH_VERTICES(ctx, 0);
9740    CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
9741 }
9742
9743 static void GLAPIENTRY
9744 exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
9745                       GLsizei count, const GLvoid *ptr)
9746 {
9747    GET_CURRENT_CONTEXT(ctx);
9748    FLUSH_VERTICES(ctx, 0);
9749    CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr));
9750 }
9751
9752 static void GLAPIENTRY
9753 exec_LockArraysEXT(GLint first, GLsizei count)
9754 {
9755    GET_CURRENT_CONTEXT(ctx);
9756    FLUSH_VERTICES(ctx, 0);
9757    CALL_LockArraysEXT(ctx->Exec, (first, count));
9758 }
9759
9760 static void GLAPIENTRY
9761 exec_UnlockArraysEXT(void)
9762 {
9763    GET_CURRENT_CONTEXT(ctx);
9764    FLUSH_VERTICES(ctx, 0);
9765    CALL_UnlockArraysEXT(ctx->Exec, ());
9766 }
9767
9768 static void GLAPIENTRY
9769 exec_ClientActiveTextureARB(GLenum target)
9770 {
9771    GET_CURRENT_CONTEXT(ctx);
9772    FLUSH_VERTICES(ctx, 0);
9773    CALL_ClientActiveTextureARB(ctx->Exec, (target));
9774 }
9775
9776 static void GLAPIENTRY
9777 exec_SecondaryColorPointerEXT(GLint size, GLenum type,
9778                               GLsizei stride, const GLvoid *ptr)
9779 {
9780    GET_CURRENT_CONTEXT(ctx);
9781    FLUSH_VERTICES(ctx, 0);
9782    CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr));
9783 }
9784
9785 static void GLAPIENTRY
9786 exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
9787 {
9788    GET_CURRENT_CONTEXT(ctx);
9789    FLUSH_VERTICES(ctx, 0);
9790    CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr));
9791 }
9792
9793 /* GL_EXT_multi_draw_arrays */
9794 static void GLAPIENTRY
9795 exec_MultiDrawArraysEXT(GLenum mode, const GLint *first,
9796                         const GLsizei *count, GLsizei primcount)
9797 {
9798    GET_CURRENT_CONTEXT(ctx);
9799    FLUSH_VERTICES(ctx, 0);
9800    CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount));
9801 }
9802
9803 /* GL_IBM_multimode_draw_arrays */
9804 static void GLAPIENTRY
9805 exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first,
9806                             const GLsizei * count, GLsizei primcount,
9807                             GLint modestride)
9808 {
9809    GET_CURRENT_CONTEXT(ctx);
9810    FLUSH_VERTICES(ctx, 0);
9811    CALL_MultiModeDrawArraysIBM(ctx->Exec,
9812                                (mode, first, count, primcount, modestride));
9813 }
9814
9815 /* GL_IBM_multimode_draw_arrays */
9816 static void GLAPIENTRY
9817 exec_MultiModeDrawElementsIBM(const GLenum * mode,
9818                               const GLsizei * count,
9819                               GLenum type,
9820                               const GLvoid * const *indices,
9821                               GLsizei primcount, GLint modestride)
9822 {
9823    GET_CURRENT_CONTEXT(ctx);
9824    FLUSH_VERTICES(ctx, 0);
9825    CALL_MultiModeDrawElementsIBM(ctx->Exec,
9826                                  (mode, count, type, indices, primcount,
9827                                   modestride));
9828 }
9829
9830 /**
9831  * Setup the given dispatch table to point to Mesa's display list
9832  * building functions.
9833  *
9834  * This does not include any of the tnl functions - they are
9835  * initialized from _mesa_init_api_defaults and from the active vtxfmt
9836  * struct.
9837  */
9838 struct _glapi_table *
9839 _mesa_create_save_table(void)
9840 {
9841    struct _glapi_table *table;
9842
9843    table = _mesa_alloc_dispatch_table(_gloffset_COUNT);
9844    if (table == NULL)
9845       return NULL;
9846
9847    _mesa_loopback_init_api_table(table);
9848
9849    /* GL 1.0 */
9850    SET_Accum(table, save_Accum);
9851    SET_AlphaFunc(table, save_AlphaFunc);
9852    SET_Bitmap(table, save_Bitmap);
9853    SET_BlendFunc(table, save_BlendFunc);
9854    SET_CallList(table, save_CallList);
9855    SET_CallLists(table, save_CallLists);
9856    SET_Clear(table, save_Clear);
9857    SET_ClearAccum(table, save_ClearAccum);
9858    SET_ClearColor(table, save_ClearColor);
9859    SET_ClearDepth(table, save_ClearDepth);
9860    SET_ClearIndex(table, save_ClearIndex);
9861    SET_ClearStencil(table, save_ClearStencil);
9862    SET_ClipPlane(table, save_ClipPlane);
9863    SET_ColorMask(table, save_ColorMask);
9864    SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed);
9865    SET_ColorMaterial(table, save_ColorMaterial);
9866    SET_CopyPixels(table, save_CopyPixels);
9867    SET_CullFace(table, save_CullFace);
9868    SET_DeleteLists(table, _mesa_DeleteLists);
9869    SET_DepthFunc(table, save_DepthFunc);
9870    SET_DepthMask(table, save_DepthMask);
9871    SET_DepthRange(table, save_DepthRange);
9872    SET_Disable(table, save_Disable);
9873    SET_DisableIndexedEXT(table, save_DisableIndexed);
9874    SET_DrawBuffer(table, save_DrawBuffer);
9875    SET_DrawPixels(table, save_DrawPixels);
9876    SET_Enable(table, save_Enable);
9877    SET_EnableIndexedEXT(table, save_EnableIndexed);
9878    SET_EndList(table, _mesa_EndList);
9879    SET_EvalMesh1(table, save_EvalMesh1);
9880    SET_EvalMesh2(table, save_EvalMesh2);
9881    SET_Finish(table, exec_Finish);
9882    SET_Flush(table, exec_Flush);
9883    SET_Fogf(table, save_Fogf);
9884    SET_Fogfv(table, save_Fogfv);
9885    SET_Fogi(table, save_Fogi);
9886    SET_Fogiv(table, save_Fogiv);
9887    SET_FrontFace(table, save_FrontFace);
9888    SET_Frustum(table, save_Frustum);
9889    SET_GenLists(table, _mesa_GenLists);
9890    SET_GetBooleanv(table, exec_GetBooleanv);
9891    SET_GetClipPlane(table, exec_GetClipPlane);
9892    SET_GetDoublev(table, exec_GetDoublev);
9893    SET_GetError(table, exec_GetError);
9894    SET_GetFloatv(table, exec_GetFloatv);
9895    SET_GetIntegerv(table, exec_GetIntegerv);
9896    SET_GetLightfv(table, exec_GetLightfv);
9897    SET_GetLightiv(table, exec_GetLightiv);
9898    SET_GetMapdv(table, exec_GetMapdv);
9899    SET_GetMapfv(table, exec_GetMapfv);
9900    SET_GetMapiv(table, exec_GetMapiv);
9901    SET_GetMaterialfv(table, exec_GetMaterialfv);
9902    SET_GetMaterialiv(table, exec_GetMaterialiv);
9903    SET_GetPixelMapfv(table, exec_GetPixelMapfv);
9904    SET_GetPixelMapuiv(table, exec_GetPixelMapuiv);
9905    SET_GetPixelMapusv(table, exec_GetPixelMapusv);
9906    SET_GetPolygonStipple(table, exec_GetPolygonStipple);
9907    SET_GetString(table, exec_GetString);
9908    SET_GetTexEnvfv(table, exec_GetTexEnvfv);
9909    SET_GetTexEnviv(table, exec_GetTexEnviv);
9910    SET_GetTexGendv(table, exec_GetTexGendv);
9911    SET_GetTexGenfv(table, exec_GetTexGenfv);
9912    SET_GetTexGeniv(table, exec_GetTexGeniv);
9913    SET_GetTexImage(table, exec_GetTexImage);
9914    SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv);
9915    SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv);
9916    SET_GetTexParameterfv(table, exec_GetTexParameterfv);
9917    SET_GetTexParameteriv(table, exec_GetTexParameteriv);
9918    SET_Hint(table, save_Hint);
9919    SET_IndexMask(table, save_IndexMask);
9920    SET_InitNames(table, save_InitNames);
9921    SET_IsEnabled(table, exec_IsEnabled);
9922    SET_IsList(table, _mesa_IsList);
9923    SET_LightModelf(table, save_LightModelf);
9924    SET_LightModelfv(table, save_LightModelfv);
9925    SET_LightModeli(table, save_LightModeli);
9926    SET_LightModeliv(table, save_LightModeliv);
9927    SET_Lightf(table, save_Lightf);
9928    SET_Lightfv(table, save_Lightfv);
9929    SET_Lighti(table, save_Lighti);
9930    SET_Lightiv(table, save_Lightiv);
9931    SET_LineStipple(table, save_LineStipple);
9932    SET_LineWidth(table, save_LineWidth);
9933    SET_ListBase(table, save_ListBase);
9934    SET_LoadIdentity(table, save_LoadIdentity);
9935    SET_LoadMatrixd(table, save_LoadMatrixd);
9936    SET_LoadMatrixf(table, save_LoadMatrixf);
9937    SET_LoadName(table, save_LoadName);
9938    SET_LogicOp(table, save_LogicOp);
9939    SET_Map1d(table, save_Map1d);
9940    SET_Map1f(table, save_Map1f);
9941    SET_Map2d(table, save_Map2d);
9942    SET_Map2f(table, save_Map2f);
9943    SET_MapGrid1d(table, save_MapGrid1d);
9944    SET_MapGrid1f(table, save_MapGrid1f);
9945    SET_MapGrid2d(table, save_MapGrid2d);
9946    SET_MapGrid2f(table, save_MapGrid2f);
9947    SET_MatrixMode(table, save_MatrixMode);
9948    SET_MultMatrixd(table, save_MultMatrixd);
9949    SET_MultMatrixf(table, save_MultMatrixf);
9950    SET_NewList(table, save_NewList);
9951    SET_Ortho(table, save_Ortho);
9952    SET_PassThrough(table, save_PassThrough);
9953    SET_PixelMapfv(table, save_PixelMapfv);
9954    SET_PixelMapuiv(table, save_PixelMapuiv);
9955    SET_PixelMapusv(table, save_PixelMapusv);
9956    SET_PixelStoref(table, exec_PixelStoref);
9957    SET_PixelStorei(table, exec_PixelStorei);
9958    SET_PixelTransferf(table, save_PixelTransferf);
9959    SET_PixelTransferi(table, save_PixelTransferi);
9960    SET_PixelZoom(table, save_PixelZoom);
9961    SET_PointSize(table, save_PointSize);
9962    SET_PolygonMode(table, save_PolygonMode);
9963    SET_PolygonOffset(table, save_PolygonOffset);
9964    SET_PolygonStipple(table, save_PolygonStipple);
9965    SET_PopAttrib(table, save_PopAttrib);
9966    SET_PopMatrix(table, save_PopMatrix);
9967    SET_PopName(table, save_PopName);
9968    SET_PushAttrib(table, save_PushAttrib);
9969    SET_PushMatrix(table, save_PushMatrix);
9970    SET_PushName(table, save_PushName);
9971    SET_RasterPos2d(table, save_RasterPos2d);
9972    SET_RasterPos2dv(table, save_RasterPos2dv);
9973    SET_RasterPos2f(table, save_RasterPos2f);
9974    SET_RasterPos2fv(table, save_RasterPos2fv);
9975    SET_RasterPos2i(table, save_RasterPos2i);
9976    SET_RasterPos2iv(table, save_RasterPos2iv);
9977    SET_RasterPos2s(table, save_RasterPos2s);
9978    SET_RasterPos2sv(table, save_RasterPos2sv);
9979    SET_RasterPos3d(table, save_RasterPos3d);
9980    SET_RasterPos3dv(table, save_RasterPos3dv);
9981    SET_RasterPos3f(table, save_RasterPos3f);
9982    SET_RasterPos3fv(table, save_RasterPos3fv);
9983    SET_RasterPos3i(table, save_RasterPos3i);
9984    SET_RasterPos3iv(table, save_RasterPos3iv);
9985    SET_RasterPos3s(table, save_RasterPos3s);
9986    SET_RasterPos3sv(table, save_RasterPos3sv);
9987    SET_RasterPos4d(table, save_RasterPos4d);
9988    SET_RasterPos4dv(table, save_RasterPos4dv);
9989    SET_RasterPos4f(table, save_RasterPos4f);
9990    SET_RasterPos4fv(table, save_RasterPos4fv);
9991    SET_RasterPos4i(table, save_RasterPos4i);
9992    SET_RasterPos4iv(table, save_RasterPos4iv);
9993    SET_RasterPos4s(table, save_RasterPos4s);
9994    SET_RasterPos4sv(table, save_RasterPos4sv);
9995    SET_ReadBuffer(table, save_ReadBuffer);
9996    SET_ReadPixels(table, exec_ReadPixels);
9997    SET_RenderMode(table, exec_RenderMode);
9998    SET_Rotated(table, save_Rotated);
9999    SET_Rotatef(table, save_Rotatef);
10000    SET_Scaled(table, save_Scaled);
10001    SET_Scalef(table, save_Scalef);
10002    SET_Scissor(table, save_Scissor);
10003    SET_FeedbackBuffer(table, exec_FeedbackBuffer);
10004    SET_SelectBuffer(table, exec_SelectBuffer);
10005    SET_ShadeModel(table, save_ShadeModel);
10006    SET_StencilFunc(table, save_StencilFunc);
10007    SET_StencilMask(table, save_StencilMask);
10008    SET_StencilOp(table, save_StencilOp);
10009    SET_TexEnvf(table, save_TexEnvf);
10010    SET_TexEnvfv(table, save_TexEnvfv);
10011    SET_TexEnvi(table, save_TexEnvi);
10012    SET_TexEnviv(table, save_TexEnviv);
10013    SET_TexGend(table, save_TexGend);
10014    SET_TexGendv(table, save_TexGendv);
10015    SET_TexGenf(table, save_TexGenf);
10016    SET_TexGenfv(table, save_TexGenfv);
10017    SET_TexGeni(table, save_TexGeni);
10018    SET_TexGeniv(table, save_TexGeniv);
10019    SET_TexImage1D(table, save_TexImage1D);
10020    SET_TexImage2D(table, save_TexImage2D);
10021    SET_TexParameterf(table, save_TexParameterf);
10022    SET_TexParameterfv(table, save_TexParameterfv);
10023    SET_TexParameteri(table, save_TexParameteri);
10024    SET_TexParameteriv(table, save_TexParameteriv);
10025    SET_Translated(table, save_Translated);
10026    SET_Translatef(table, save_Translatef);
10027    SET_Viewport(table, save_Viewport);
10028
10029    /* GL 1.1 */
10030    SET_AreTexturesResident(table, exec_AreTexturesResident);
10031    SET_BindTexture(table, save_BindTexture);
10032    SET_ColorPointer(table, exec_ColorPointer);
10033    SET_CopyTexImage1D(table, save_CopyTexImage1D);
10034    SET_CopyTexImage2D(table, save_CopyTexImage2D);
10035    SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
10036    SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
10037    SET_DeleteTextures(table, exec_DeleteTextures);
10038    SET_DisableClientState(table, exec_DisableClientState);
10039    SET_EdgeFlagPointer(table, exec_EdgeFlagPointer);
10040    SET_EnableClientState(table, exec_EnableClientState);
10041    SET_GenTextures(table, exec_GenTextures);
10042    SET_GetPointerv(table, exec_GetPointerv);
10043    SET_IndexPointer(table, exec_IndexPointer);
10044    SET_InterleavedArrays(table, exec_InterleavedArrays);
10045    SET_IsTexture(table, exec_IsTexture);
10046    SET_NormalPointer(table, exec_NormalPointer);
10047    SET_PopClientAttrib(table, exec_PopClientAttrib);
10048    SET_PrioritizeTextures(table, save_PrioritizeTextures);
10049    SET_PushClientAttrib(table, exec_PushClientAttrib);
10050    SET_TexCoordPointer(table, exec_TexCoordPointer);
10051    SET_TexSubImage1D(table, save_TexSubImage1D);
10052    SET_TexSubImage2D(table, save_TexSubImage2D);
10053    SET_VertexPointer(table, exec_VertexPointer);
10054
10055    /* GL 1.2 */
10056    SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
10057    SET_TexImage3D(table, save_TexImage3D);
10058    SET_TexSubImage3D(table, save_TexSubImage3D);
10059
10060    /* GL 2.0 */
10061    SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
10062    SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
10063    SET_StencilOpSeparate(table, save_StencilOpSeparate);
10064
10065    /* ATI_separate_stencil */ 
10066    SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
10067
10068    /* GL_ARB_imaging */
10069    /* Not all are supported */
10070    SET_BlendColor(table, save_BlendColor);
10071    SET_BlendEquation(table, save_BlendEquation);
10072    SET_ColorSubTable(table, save_ColorSubTable);
10073    SET_ColorTable(table, save_ColorTable);
10074    SET_ColorTableParameterfv(table, save_ColorTableParameterfv);
10075    SET_ColorTableParameteriv(table, save_ColorTableParameteriv);
10076    SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D);
10077    SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D);
10078    SET_ConvolutionParameterf(table, save_ConvolutionParameterf);
10079    SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv);
10080    SET_ConvolutionParameteri(table, save_ConvolutionParameteri);
10081    SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv);
10082    SET_CopyColorSubTable(table, save_CopyColorSubTable);
10083    SET_CopyColorTable(table, save_CopyColorTable);
10084    SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D);
10085    SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D);
10086    SET_GetColorTable(table, exec_GetColorTable);
10087    SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv);
10088    SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv);
10089    SET_GetConvolutionFilter(table, exec_GetConvolutionFilter);
10090    SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv);
10091    SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv);
10092    SET_GetHistogram(table, exec_GetHistogram);
10093    SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv);
10094    SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv);
10095    SET_GetMinmax(table, exec_GetMinmax);
10096    SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv);
10097    SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv);
10098    SET_GetSeparableFilter(table, exec_GetSeparableFilter);
10099    SET_Histogram(table, save_Histogram);
10100    SET_Minmax(table, save_Minmax);
10101    SET_ResetHistogram(table, save_ResetHistogram);
10102    SET_ResetMinmax(table, save_ResetMinmax);
10103    SET_SeparableFilter2D(table, exec_SeparableFilter2D);
10104
10105    /* 2. GL_EXT_blend_color */
10106 #if 0
10107    SET_BlendColorEXT(table, save_BlendColorEXT);
10108 #endif
10109
10110    /* 3. GL_EXT_polygon_offset */
10111    SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT);
10112
10113    /* 6. GL_EXT_texture3d */
10114 #if 0
10115    SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
10116    SET_TexImage3DEXT(table, save_TexImage3DEXT);
10117    SET_TexSubImage3DEXT(table, save_TexSubImage3D);
10118 #endif
10119
10120    /* 14. GL_SGI_color_table */
10121 #if 0
10122    SET_ColorTableSGI(table, save_ColorTable);
10123    SET_ColorSubTableSGI(table, save_ColorSubTable);
10124    SET_GetColorTableSGI(table, exec_GetColorTable);
10125    SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv);
10126    SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv);
10127 #endif
10128
10129    /* 30. GL_EXT_vertex_array */
10130    SET_ColorPointerEXT(table, exec_ColorPointerEXT);
10131    SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT);
10132    SET_IndexPointerEXT(table, exec_IndexPointerEXT);
10133    SET_NormalPointerEXT(table, exec_NormalPointerEXT);
10134    SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT);
10135    SET_VertexPointerEXT(table, exec_VertexPointerEXT);
10136
10137    /* 37. GL_EXT_blend_minmax */
10138 #if 0
10139    SET_BlendEquationEXT(table, save_BlendEquationEXT);
10140 #endif
10141
10142    /* 54. GL_EXT_point_parameters */
10143    SET_PointParameterfEXT(table, save_PointParameterfEXT);
10144    SET_PointParameterfvEXT(table, save_PointParameterfvEXT);
10145
10146    /* 97. GL_EXT_compiled_vertex_array */
10147    SET_LockArraysEXT(table, exec_LockArraysEXT);
10148    SET_UnlockArraysEXT(table, exec_UnlockArraysEXT);
10149
10150    /* 145. GL_EXT_secondary_color */
10151    SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT);
10152
10153    /* 148. GL_EXT_multi_draw_arrays */
10154    SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT);
10155
10156    /* 149. GL_EXT_fog_coord */
10157    SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT);
10158
10159    /* 173. GL_EXT_blend_func_separate */
10160    SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT);
10161
10162    /* 196. GL_MESA_resize_buffers */
10163    SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA);
10164
10165    /* 197. GL_MESA_window_pos */
10166    SET_WindowPos2dMESA(table, save_WindowPos2dMESA);
10167    SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA);
10168    SET_WindowPos2fMESA(table, save_WindowPos2fMESA);
10169    SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA);
10170    SET_WindowPos2iMESA(table, save_WindowPos2iMESA);
10171    SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA);
10172    SET_WindowPos2sMESA(table, save_WindowPos2sMESA);
10173    SET_WindowPos2svMESA(table, save_WindowPos2svMESA);
10174    SET_WindowPos3dMESA(table, save_WindowPos3dMESA);
10175    SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA);
10176    SET_WindowPos3fMESA(table, save_WindowPos3fMESA);
10177    SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA);
10178    SET_WindowPos3iMESA(table, save_WindowPos3iMESA);
10179    SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA);
10180    SET_WindowPos3sMESA(table, save_WindowPos3sMESA);
10181    SET_WindowPos3svMESA(table, save_WindowPos3svMESA);
10182    SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
10183    SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
10184    SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
10185    SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
10186    SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
10187    SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
10188    SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
10189    SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
10190
10191    /* 200. GL_IBM_multimode_draw_arrays */
10192    SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM);
10193    SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM);
10194
10195 #if FEATURE_NV_vertex_program
10196    /* 233. GL_NV_vertex_program */
10197    /* The following commands DO NOT go into display lists:
10198     * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
10199     * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
10200     */
10201    SET_BindProgramNV(table, save_BindProgramNV);
10202    SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
10203    SET_ExecuteProgramNV(table, save_ExecuteProgramNV);
10204    SET_GenProgramsNV(table, _mesa_GenPrograms);
10205    SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV);
10206    SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV);
10207    SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV);
10208    SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV);
10209    SET_GetProgramivNV(table, _mesa_GetProgramivNV);
10210    SET_GetProgramStringNV(table, _mesa_GetProgramStringNV);
10211    SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV);
10212    SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
10213    SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
10214    SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
10215    SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
10216    SET_IsProgramNV(table, _mesa_IsProgramARB);
10217    SET_LoadProgramNV(table, save_LoadProgramNV);
10218    SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
10219    SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
10220    SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
10221    SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
10222    SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
10223    SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
10224    SET_TrackMatrixNV(table, save_TrackMatrixNV);
10225    SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV);
10226 #endif
10227
10228    /* 244. GL_ATI_envmap_bumpmap */
10229    SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI);
10230    SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI);
10231
10232    /* 245. GL_ATI_fragment_shader */
10233 #if FEATURE_ATI_fragment_shader
10234    SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
10235    SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
10236 #endif
10237
10238    /* 282. GL_NV_fragment_program */
10239 #if FEATURE_NV_fragment_program
10240    SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV);
10241    SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV);
10242    SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV);
10243    SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV);
10244    SET_GetProgramNamedParameterfvNV(table,
10245                                     _mesa_GetProgramNamedParameterfvNV);
10246    SET_GetProgramNamedParameterdvNV(table,
10247                                     _mesa_GetProgramNamedParameterdvNV);
10248    SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
10249    SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
10250    SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
10251    SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
10252    SET_GetProgramLocalParameterdvARB(table,
10253                                      _mesa_GetProgramLocalParameterdvARB);
10254    SET_GetProgramLocalParameterfvARB(table,
10255                                      _mesa_GetProgramLocalParameterfvARB);
10256 #endif
10257
10258    /* 262. GL_NV_point_sprite */
10259    SET_PointParameteriNV(table, save_PointParameteriNV);
10260    SET_PointParameterivNV(table, save_PointParameterivNV);
10261
10262    /* 268. GL_EXT_stencil_two_side */
10263    SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
10264
10265    /* 273. GL_APPLE_vertex_array_object */
10266    SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE);
10267    SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE);
10268    SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE);
10269    SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE);
10270
10271    /* 310. GL_EXT_framebuffer_object */
10272    SET_GenFramebuffersEXT(table, _mesa_GenFramebuffersEXT);
10273    SET_BindFramebufferEXT(table, _mesa_BindFramebufferEXT);
10274    SET_DeleteFramebuffersEXT(table, _mesa_DeleteFramebuffersEXT);
10275    SET_CheckFramebufferStatusEXT(table, _mesa_CheckFramebufferStatusEXT);
10276    SET_GenRenderbuffersEXT(table, _mesa_GenRenderbuffersEXT);
10277    SET_BindRenderbufferEXT(table, _mesa_BindRenderbufferEXT);
10278    SET_DeleteRenderbuffersEXT(table, _mesa_DeleteRenderbuffersEXT);
10279    SET_RenderbufferStorageEXT(table, _mesa_RenderbufferStorageEXT);
10280    SET_FramebufferTexture1DEXT(table, _mesa_FramebufferTexture1DEXT);
10281    SET_FramebufferTexture2DEXT(table, _mesa_FramebufferTexture2DEXT);
10282    SET_FramebufferTexture3DEXT(table, _mesa_FramebufferTexture3DEXT);
10283    SET_FramebufferRenderbufferEXT(table, _mesa_FramebufferRenderbufferEXT);
10284    SET_GenerateMipmapEXT(table, _mesa_GenerateMipmapEXT);
10285
10286    /* 317. GL_EXT_framebuffer_multisample */
10287    SET_RenderbufferStorageMultisample(table, _mesa_RenderbufferStorageMultisample);
10288
10289    /* GL_ARB_vertex_array_object */
10290    SET_BindVertexArray(table, _mesa_BindVertexArray);
10291    SET_GenVertexArrays(table, _mesa_GenVertexArrays);
10292
10293    /* ???. GL_EXT_depth_bounds_test */
10294    SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
10295
10296    /* ARB 1. GL_ARB_multitexture */
10297    SET_ActiveTextureARB(table, save_ActiveTextureARB);
10298    SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB);
10299
10300    /* ARB 3. GL_ARB_transpose_matrix */
10301    SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB);
10302    SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB);
10303    SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB);
10304    SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB);
10305
10306    /* ARB 5. GL_ARB_multisample */
10307    SET_SampleCoverageARB(table, save_SampleCoverageARB);
10308
10309    /* ARB 12. GL_ARB_texture_compression */
10310    SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB);
10311    SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB);
10312    SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB);
10313    SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB);
10314    SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB);
10315    SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB);
10316    SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB);
10317
10318    /* ARB 14. GL_ARB_point_parameters */
10319    /* aliased with EXT_point_parameters functions */
10320
10321    /* ARB 25. GL_ARB_window_pos */
10322    /* aliased with MESA_window_pos functions */
10323
10324    /* ARB 26. GL_ARB_vertex_program */
10325    /* ARB 27. GL_ARB_fragment_program */
10326 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
10327    /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
10328    SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB);
10329    SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB);
10330    SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB);
10331    SET_ProgramStringARB(table, save_ProgramStringARB);
10332    SET_BindProgramNV(table, save_BindProgramNV);
10333    SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
10334    SET_GenProgramsNV(table, _mesa_GenPrograms);
10335    SET_IsProgramNV(table, _mesa_IsProgramARB);
10336    SET_GetVertexAttribdvARB(table, _mesa_GetVertexAttribdvARB);
10337    SET_GetVertexAttribfvARB(table, _mesa_GetVertexAttribfvARB);
10338    SET_GetVertexAttribivARB(table, _mesa_GetVertexAttribivARB);
10339    SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
10340    SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
10341    SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
10342    SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
10343    SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
10344    SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
10345    SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
10346    SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
10347    SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
10348    SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB);
10349    SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB);
10350    SET_GetProgramLocalParameterdvARB(table,
10351                                      _mesa_GetProgramLocalParameterdvARB);
10352    SET_GetProgramLocalParameterfvARB(table,
10353                                      _mesa_GetProgramLocalParameterfvARB);
10354    SET_GetProgramivARB(table, _mesa_GetProgramivARB);
10355    SET_GetProgramStringARB(table, _mesa_GetProgramStringARB);
10356 #endif
10357
10358    /* ARB 28. GL_ARB_vertex_buffer_object */
10359    /* None of the extension's functions get compiled */
10360    SET_BindBufferARB(table, _mesa_BindBufferARB);
10361    SET_BufferDataARB(table, _mesa_BufferDataARB);
10362    SET_BufferSubDataARB(table, _mesa_BufferSubDataARB);
10363    SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB);
10364    SET_GenBuffersARB(table, _mesa_GenBuffersARB);
10365    SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB);
10366    SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB);
10367    SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB);
10368    SET_IsBufferARB(table, _mesa_IsBufferARB);
10369    SET_MapBufferARB(table, _mesa_MapBufferARB);
10370    SET_UnmapBufferARB(table, _mesa_UnmapBufferARB);
10371
10372 #if FEATURE_queryobj
10373    _mesa_init_queryobj_dispatch(table); /* glGetQuery, etc */
10374    SET_BeginQueryARB(table, save_BeginQueryARB);
10375    SET_EndQueryARB(table, save_EndQueryARB);
10376    SET_QueryCounter(table, save_QueryCounter);
10377 #endif
10378
10379    SET_DrawBuffersARB(table, save_DrawBuffersARB);
10380
10381 #if FEATURE_EXT_framebuffer_blit
10382    SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
10383 #endif
10384
10385    /* GL_ARB_shader_objects */
10386    _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */
10387    SET_UseProgramObjectARB(table, save_UseProgramObjectARB);
10388    SET_Uniform1fARB(table, save_Uniform1fARB);
10389    SET_Uniform2fARB(table, save_Uniform2fARB);
10390    SET_Uniform3fARB(table, save_Uniform3fARB);
10391    SET_Uniform4fARB(table, save_Uniform4fARB);
10392    SET_Uniform1fvARB(table, save_Uniform1fvARB);
10393    SET_Uniform2fvARB(table, save_Uniform2fvARB);
10394    SET_Uniform3fvARB(table, save_Uniform3fvARB);
10395    SET_Uniform4fvARB(table, save_Uniform4fvARB);
10396    SET_Uniform1iARB(table, save_Uniform1iARB);
10397    SET_Uniform2iARB(table, save_Uniform2iARB);
10398    SET_Uniform3iARB(table, save_Uniform3iARB);
10399    SET_Uniform4iARB(table, save_Uniform4iARB);
10400    SET_Uniform1ivARB(table, save_Uniform1ivARB);
10401    SET_Uniform2ivARB(table, save_Uniform2ivARB);
10402    SET_Uniform3ivARB(table, save_Uniform3ivARB);
10403    SET_Uniform4ivARB(table, save_Uniform4ivARB);
10404    SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB);
10405    SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB);
10406    SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB);
10407    SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv);
10408    SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv);
10409    SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv);
10410    SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv);
10411    SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv);
10412    SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv);
10413
10414    /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
10415    SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
10416    SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
10417    SET_GetUniformLocationARB(table, exec_GetUniformLocationARB);
10418    /* XXX additional functions need to be implemented here! */
10419
10420    /* 299. GL_EXT_blend_equation_separate */
10421    SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
10422
10423    /* GL_EXT_gpu_program_parameters */
10424 #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
10425    SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
10426    SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
10427 #endif
10428
10429    /* ARB 50. GL_ARB_map_buffer_range */
10430 #if FEATURE_ARB_map_buffer_range
10431    SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */
10432    SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */
10433 #endif
10434
10435    /* ARB 51. GL_ARB_texture_buffer_object */
10436    SET_TexBufferARB(table, _mesa_TexBuffer); /* no dlist save */
10437
10438    /* ARB 59. GL_ARB_copy_buffer */
10439    SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */
10440
10441    /* 364. GL_EXT_provoking_vertex */
10442    SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT);
10443
10444    /* 371. GL_APPLE_object_purgeable */
10445 #if FEATURE_APPLE_object_purgeable
10446    SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE);
10447    SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE);
10448    SET_GetObjectParameterivAPPLE(table, _mesa_GetObjectParameterivAPPLE);
10449 #endif
10450
10451    /* GL_EXT_texture_integer */
10452    SET_ClearColorIiEXT(table, save_ClearColorIi);
10453    SET_ClearColorIuiEXT(table, save_ClearColorIui);
10454    SET_TexParameterIivEXT(table, save_TexParameterIiv);
10455    SET_TexParameterIuivEXT(table, save_TexParameterIuiv);
10456    SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv);
10457    SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv);
10458
10459    /* 377. GL_EXT_separate_shader_objects */
10460    SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT);
10461    SET_ActiveProgramEXT(table, save_ActiveProgramEXT);
10462
10463    /* GL_ARB_color_buffer_float */
10464    SET_ClampColorARB(table, save_ClampColorARB);
10465    SET_ClampColor(table, save_ClampColorARB);
10466
10467    /* GL 3.0 */
10468    SET_ClearBufferiv(table, save_ClearBufferiv);
10469    SET_ClearBufferuiv(table, save_ClearBufferuiv);
10470    SET_ClearBufferfv(table, save_ClearBufferfv);
10471    SET_ClearBufferfi(table, save_ClearBufferfi);
10472 #if 0
10473    SET_Uniform1ui(table, save_Uniform1ui);
10474    SET_Uniform2ui(table, save_Uniform2ui);
10475    SET_Uniform3ui(table, save_Uniform3ui);
10476    SET_Uniform4ui(table, save_Uniform4ui);
10477    SET_Uniform1uiv(table, save_Uniform1uiv);
10478    SET_Uniform2uiv(table, save_Uniform2uiv);
10479    SET_Uniform3uiv(table, save_Uniform3uiv);
10480    SET_Uniform4uiv(table, save_Uniform4uiv);
10481 #else
10482    (void) save_Uniform1ui;
10483    (void) save_Uniform2ui;
10484    (void) save_Uniform3ui;
10485    (void) save_Uniform4ui;
10486    (void) save_Uniform1uiv;
10487    (void) save_Uniform2uiv;
10488    (void) save_Uniform3uiv;
10489    (void) save_Uniform4uiv;
10490 #endif
10491
10492 #if FEATURE_EXT_transform_feedback
10493    /* These are not compiled into display lists: */
10494    SET_BindBufferBaseEXT(table, _mesa_BindBufferBase);
10495    SET_BindBufferOffsetEXT(table, _mesa_BindBufferOffsetEXT);
10496    SET_BindBufferRangeEXT(table, _mesa_BindBufferRange);
10497    SET_TransformFeedbackVaryingsEXT(table, _mesa_TransformFeedbackVaryings);
10498    /* These are: */
10499    SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback);
10500    SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback);
10501    SET_BindTransformFeedback(table, save_BindTransformFeedback);
10502    SET_PauseTransformFeedback(table, save_PauseTransformFeedback);
10503    SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback);
10504    SET_DrawTransformFeedback(table, save_DrawTransformFeedback);
10505 #if FEATURE_queryobj
10506    SET_BeginQueryIndexed(table, save_BeginQueryIndexed);
10507    SET_EndQueryIndexed(table, save_EndQueryIndexed);
10508 #endif
10509 #endif
10510
10511    /* GL_ARB_instanced_arrays */
10512    SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor);
10513
10514    /* GL_NV_texture_barrier */
10515    SET_TextureBarrierNV(table, save_TextureBarrierNV);
10516
10517    /* GL_ARB_sampler_objects */
10518    _mesa_init_sampler_object_dispatch(table); /* plug in Gen/Get/etc functions */
10519    SET_BindSampler(table, save_BindSampler);
10520    SET_SamplerParameteri(table, save_SamplerParameteri);
10521    SET_SamplerParameterf(table, save_SamplerParameterf);
10522    SET_SamplerParameteriv(table, save_SamplerParameteriv);
10523    SET_SamplerParameterfv(table, save_SamplerParameterfv);
10524    SET_SamplerParameterIiv(table, save_SamplerParameterIiv);
10525    SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv);
10526
10527    /* GL_ARB_draw_buffer_blend */
10528    SET_BlendFunciARB(table, save_BlendFunci);
10529    SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei);
10530    SET_BlendEquationiARB(table, save_BlendEquationi);
10531    SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
10532
10533    /* GL_ARB_geometry_shader4 */
10534    SET_ProgramParameteriARB(table, save_ProgramParameteri);
10535    SET_FramebufferTextureARB(table, save_FramebufferTexture);
10536    SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace);
10537
10538    /* GL_NV_conditional_render */
10539    SET_BeginConditionalRenderNV(table, save_BeginConditionalRender);
10540    SET_EndConditionalRenderNV(table, save_EndConditionalRender);
10541
10542    /* GL_ARB_sync */
10543    _mesa_init_sync_dispatch(table);
10544    SET_WaitSync(table, save_WaitSync);
10545
10546    /* GL_ARB_texture_storage (no dlist support) */
10547    SET_TexStorage1D(table, _mesa_TexStorage1D);
10548    SET_TexStorage2D(table, _mesa_TexStorage2D);
10549    SET_TexStorage3D(table, _mesa_TexStorage3D);
10550    SET_TextureStorage1DEXT(table, _mesa_TextureStorage1DEXT);
10551    SET_TextureStorage2DEXT(table, _mesa_TextureStorage2DEXT);
10552    SET_TextureStorage3DEXT(table, _mesa_TextureStorage3DEXT);
10553
10554    /* GL_ARB_debug_output (no dlist support) */
10555    _mesa_init_errors_dispatch(table);
10556
10557    /* GL_NV_primitive_restart */
10558    SET_PrimitiveRestartIndexNV(table, _mesa_PrimitiveRestartIndex);
10559
10560    return table;
10561 }
10562
10563
10564
10565 static const char *
10566 enum_string(GLenum k)
10567 {
10568    return _mesa_lookup_enum_by_nr(k);
10569 }
10570
10571
10572 /**
10573  * Print the commands in a display list.  For debugging only.
10574  * TODO: many commands aren't handled yet.
10575  */
10576 static void GLAPIENTRY
10577 print_list(struct gl_context *ctx, GLuint list)
10578 {
10579    struct gl_display_list *dlist;
10580    Node *n;
10581    GLboolean done;
10582
10583    if (!islist(ctx, list)) {
10584       printf("%u is not a display list ID\n", list);
10585       return;
10586    }
10587
10588    dlist = lookup_list(ctx, list);
10589    if (!dlist)
10590       return;
10591
10592    n = dlist->Head;
10593
10594    printf("START-LIST %u, address %p\n", list, (void *) n);
10595
10596    done = n ? GL_FALSE : GL_TRUE;
10597    while (!done) {
10598       const OpCode opcode = n[0].opcode;
10599
10600       if (is_ext_opcode(opcode)) {
10601          n += ext_opcode_print(ctx, n);
10602       }
10603       else {
10604          switch (opcode) {
10605          case OPCODE_ACCUM:
10606             printf("Accum %s %g\n", enum_string(n[1].e), n[2].f);
10607             break;
10608          case OPCODE_BITMAP:
10609             printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
10610                          n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data);
10611             break;
10612          case OPCODE_CALL_LIST:
10613             printf("CallList %d\n", (int) n[1].ui);
10614             break;
10615          case OPCODE_CALL_LIST_OFFSET:
10616             printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
10617                          ctx->List.ListBase, ctx->List.ListBase + n[1].ui);
10618             break;
10619          case OPCODE_COLOR_TABLE_PARAMETER_FV:
10620             printf("ColorTableParameterfv %s %s %f %f %f %f\n",
10621                          enum_string(n[1].e), enum_string(n[2].e),
10622                          n[3].f, n[4].f, n[5].f, n[6].f);
10623             break;
10624          case OPCODE_COLOR_TABLE_PARAMETER_IV:
10625             printf("ColorTableParameteriv %s %s %d %d %d %d\n",
10626                          enum_string(n[1].e), enum_string(n[2].e),
10627                          n[3].i, n[4].i, n[5].i, n[6].i);
10628             break;
10629          case OPCODE_DISABLE:
10630             printf("Disable %s\n", enum_string(n[1].e));
10631             break;
10632          case OPCODE_ENABLE:
10633             printf("Enable %s\n", enum_string(n[1].e));
10634             break;
10635          case OPCODE_FRUSTUM:
10636             printf("Frustum %g %g %g %g %g %g\n",
10637                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
10638             break;
10639          case OPCODE_LINE_STIPPLE:
10640             printf("LineStipple %d %x\n", n[1].i, (int) n[2].us);
10641             break;
10642          case OPCODE_LOAD_IDENTITY:
10643             printf("LoadIdentity\n");
10644             break;
10645          case OPCODE_LOAD_MATRIX:
10646             printf("LoadMatrix\n");
10647             printf("  %8f %8f %8f %8f\n",
10648                          n[1].f, n[5].f, n[9].f, n[13].f);
10649             printf("  %8f %8f %8f %8f\n",
10650                          n[2].f, n[6].f, n[10].f, n[14].f);
10651             printf("  %8f %8f %8f %8f\n",
10652                          n[3].f, n[7].f, n[11].f, n[15].f);
10653             printf("  %8f %8f %8f %8f\n",
10654                          n[4].f, n[8].f, n[12].f, n[16].f);
10655             break;
10656          case OPCODE_MULT_MATRIX:
10657             printf("MultMatrix (or Rotate)\n");
10658             printf("  %8f %8f %8f %8f\n",
10659                          n[1].f, n[5].f, n[9].f, n[13].f);
10660             printf("  %8f %8f %8f %8f\n",
10661                          n[2].f, n[6].f, n[10].f, n[14].f);
10662             printf("  %8f %8f %8f %8f\n",
10663                          n[3].f, n[7].f, n[11].f, n[15].f);
10664             printf("  %8f %8f %8f %8f\n",
10665                          n[4].f, n[8].f, n[12].f, n[16].f);
10666             break;
10667          case OPCODE_ORTHO:
10668             printf("Ortho %g %g %g %g %g %g\n",
10669                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
10670             break;
10671          case OPCODE_POP_ATTRIB:
10672             printf("PopAttrib\n");
10673             break;
10674          case OPCODE_POP_MATRIX:
10675             printf("PopMatrix\n");
10676             break;
10677          case OPCODE_POP_NAME:
10678             printf("PopName\n");
10679             break;
10680          case OPCODE_PUSH_ATTRIB:
10681             printf("PushAttrib %x\n", n[1].bf);
10682             break;
10683          case OPCODE_PUSH_MATRIX:
10684             printf("PushMatrix\n");
10685             break;
10686          case OPCODE_PUSH_NAME:
10687             printf("PushName %d\n", (int) n[1].ui);
10688             break;
10689          case OPCODE_RASTER_POS:
10690             printf("RasterPos %g %g %g %g\n",
10691                          n[1].f, n[2].f, n[3].f, n[4].f);
10692             break;
10693          case OPCODE_ROTATE:
10694             printf("Rotate %g %g %g %g\n",
10695                          n[1].f, n[2].f, n[3].f, n[4].f);
10696             break;
10697          case OPCODE_SCALE:
10698             printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
10699             break;
10700          case OPCODE_TRANSLATE:
10701             printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
10702             break;
10703          case OPCODE_BIND_TEXTURE:
10704             printf("BindTexture %s %d\n",
10705                          _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
10706             break;
10707          case OPCODE_SHADE_MODEL:
10708             printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
10709             break;
10710          case OPCODE_MAP1:
10711             printf("Map1 %s %.3f %.3f %d %d\n",
10712                          _mesa_lookup_enum_by_nr(n[1].ui),
10713                          n[2].f, n[3].f, n[4].i, n[5].i);
10714             break;
10715          case OPCODE_MAP2:
10716             printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
10717                          _mesa_lookup_enum_by_nr(n[1].ui),
10718                          n[2].f, n[3].f, n[4].f, n[5].f,
10719                          n[6].i, n[7].i, n[8].i, n[9].i);
10720             break;
10721          case OPCODE_MAPGRID1:
10722             printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
10723             break;
10724          case OPCODE_MAPGRID2:
10725             printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
10726                          n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
10727             break;
10728          case OPCODE_EVALMESH1:
10729             printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
10730             break;
10731          case OPCODE_EVALMESH2:
10732             printf("EvalMesh2 %d %d %d %d\n",
10733                          n[1].i, n[2].i, n[3].i, n[4].i);
10734             break;
10735
10736          case OPCODE_ATTR_1F_NV:
10737             printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
10738             break;
10739          case OPCODE_ATTR_2F_NV:
10740             printf("ATTR_2F_NV attr %d: %f %f\n",
10741                          n[1].i, n[2].f, n[3].f);
10742             break;
10743          case OPCODE_ATTR_3F_NV:
10744             printf("ATTR_3F_NV attr %d: %f %f %f\n",
10745                          n[1].i, n[2].f, n[3].f, n[4].f);
10746             break;
10747          case OPCODE_ATTR_4F_NV:
10748             printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
10749                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
10750             break;
10751          case OPCODE_ATTR_1F_ARB:
10752             printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
10753             break;
10754          case OPCODE_ATTR_2F_ARB:
10755             printf("ATTR_2F_ARB attr %d: %f %f\n",
10756                          n[1].i, n[2].f, n[3].f);
10757             break;
10758          case OPCODE_ATTR_3F_ARB:
10759             printf("ATTR_3F_ARB attr %d: %f %f %f\n",
10760                          n[1].i, n[2].f, n[3].f, n[4].f);
10761             break;
10762          case OPCODE_ATTR_4F_ARB:
10763             printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
10764                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
10765             break;
10766
10767          case OPCODE_MATERIAL:
10768             printf("MATERIAL %x %x: %f %f %f %f\n",
10769                          n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
10770             break;
10771          case OPCODE_BEGIN:
10772             printf("BEGIN %x\n", n[1].i);
10773             break;
10774          case OPCODE_END:
10775             printf("END\n");
10776             break;
10777          case OPCODE_RECTF:
10778             printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f,
10779                          n[4].f);
10780             break;
10781          case OPCODE_EVAL_C1:
10782             printf("EVAL_C1 %f\n", n[1].f);
10783             break;
10784          case OPCODE_EVAL_C2:
10785             printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
10786             break;
10787          case OPCODE_EVAL_P1:
10788             printf("EVAL_P1 %d\n", n[1].i);
10789             break;
10790          case OPCODE_EVAL_P2:
10791             printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
10792             break;
10793
10794          case OPCODE_PROVOKING_VERTEX:
10795             printf("ProvokingVertex %s\n",
10796                          _mesa_lookup_enum_by_nr(n[1].ui));
10797             break;
10798
10799             /*
10800              * meta opcodes/commands
10801              */
10802          case OPCODE_ERROR:
10803             printf("Error: %s %s\n",
10804                          enum_string(n[1].e), (const char *) n[2].data);
10805             break;
10806          case OPCODE_CONTINUE:
10807             printf("DISPLAY-LIST-CONTINUE\n");
10808             n = (Node *) n[1].next;
10809             break;
10810          case OPCODE_END_OF_LIST:
10811             printf("END-LIST %u\n", list);
10812             done = GL_TRUE;
10813             break;
10814          default:
10815             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
10816                printf
10817                   ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
10818                    opcode, (void *) n);
10819                return;
10820             }
10821             else {
10822                printf("command %d, %u operands\n", opcode,
10823                             InstSize[opcode]);
10824             }
10825          }
10826          /* increment n to point to next compiled command */
10827          if (opcode != OPCODE_CONTINUE) {
10828             n += InstSize[opcode];
10829          }
10830       }
10831    }
10832 }
10833
10834
10835
10836 /**
10837  * Clients may call this function to help debug display list problems.
10838  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
10839  * changed, or break in the future without notice.
10840  */
10841 void
10842 mesa_print_display_list(GLuint list)
10843 {
10844    GET_CURRENT_CONTEXT(ctx);
10845    print_list(ctx, list);
10846 }
10847
10848
10849 /**********************************************************************/
10850 /*****                      Initialization                        *****/
10851 /**********************************************************************/
10852
10853 void
10854 _mesa_save_vtxfmt_init(GLvertexformat * vfmt)
10855 {
10856    _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_);
10857
10858    vfmt->Begin = save_Begin;
10859
10860    _MESA_INIT_DLIST_VTXFMT(vfmt, save_);
10861
10862    vfmt->Color3f = save_Color3f;
10863    vfmt->Color3fv = save_Color3fv;
10864    vfmt->Color4f = save_Color4f;
10865    vfmt->Color4fv = save_Color4fv;
10866    vfmt->EdgeFlag = save_EdgeFlag;
10867    vfmt->End = save_End;
10868
10869    _MESA_INIT_EVAL_VTXFMT(vfmt, save_);
10870
10871    vfmt->FogCoordfEXT = save_FogCoordfEXT;
10872    vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
10873    vfmt->Indexf = save_Indexf;
10874    vfmt->Indexfv = save_Indexfv;
10875    vfmt->Materialfv = save_Materialfv;
10876    vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
10877    vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
10878    vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
10879    vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
10880    vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
10881    vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
10882    vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
10883    vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
10884    vfmt->Normal3f = save_Normal3f;
10885    vfmt->Normal3fv = save_Normal3fv;
10886    vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
10887    vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
10888    vfmt->TexCoord1f = save_TexCoord1f;
10889    vfmt->TexCoord1fv = save_TexCoord1fv;
10890    vfmt->TexCoord2f = save_TexCoord2f;
10891    vfmt->TexCoord2fv = save_TexCoord2fv;
10892    vfmt->TexCoord3f = save_TexCoord3f;
10893    vfmt->TexCoord3fv = save_TexCoord3fv;
10894    vfmt->TexCoord4f = save_TexCoord4f;
10895    vfmt->TexCoord4fv = save_TexCoord4fv;
10896    vfmt->Vertex2f = save_Vertex2f;
10897    vfmt->Vertex2fv = save_Vertex2fv;
10898    vfmt->Vertex3f = save_Vertex3f;
10899    vfmt->Vertex3fv = save_Vertex3fv;
10900    vfmt->Vertex4f = save_Vertex4f;
10901    vfmt->Vertex4fv = save_Vertex4fv;
10902    vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
10903    vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
10904    vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
10905    vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
10906    vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
10907    vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
10908    vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
10909    vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
10910    vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
10911    vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
10912    vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
10913    vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
10914    vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
10915    vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
10916    vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
10917    vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
10918
10919    vfmt->Rectf = save_Rectf;
10920
10921    /* GL_ARB_draw_instanced */
10922    vfmt->DrawArraysInstanced = save_DrawArraysInstancedARB;
10923    vfmt->DrawElementsInstanced = save_DrawElementsInstancedARB;
10924
10925    /* GL_ARB_draw_elements_base_vertex */
10926    vfmt->DrawElementsInstancedBaseVertex = save_DrawElementsInstancedBaseVertexARB;
10927
10928    /* GL_ARB_base_instance */
10929    vfmt->DrawArraysInstancedBaseInstance = save_DrawArraysInstancedBaseInstance;
10930    vfmt->DrawElementsInstancedBaseInstance = save_DrawElementsInstancedBaseInstance;
10931    vfmt->DrawElementsInstancedBaseVertexBaseInstance = save_DrawElementsInstancedBaseVertexBaseInstance;
10932
10933    /* The driver is required to implement these as
10934     * 1) They can probably do a better job.
10935     * 2) A lot of new mechanisms would have to be added to this module
10936     *     to support it.  That code would probably never get used,
10937     *     because of (1).
10938     */
10939 #if 0
10940    vfmt->DrawArrays = 0;
10941    vfmt->DrawElements = 0;
10942    vfmt->DrawRangeElements = 0;
10943    vfmt->MultiDrawElemementsEXT = 0;
10944    vfmt->DrawElementsBaseVertex = 0;
10945    vfmt->DrawRangeElementsBaseVertex = 0;
10946    vfmt->MultiDrawElemementsBaseVertex = 0;
10947 #endif
10948 }
10949
10950
10951 void
10952 _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
10953                            const GLvertexformat *vfmt)
10954 {
10955    SET_CallList(disp, vfmt->CallList);
10956    SET_CallLists(disp, vfmt->CallLists);
10957 }
10958
10959
10960 void _mesa_init_dlist_dispatch(struct _glapi_table *disp)
10961 {
10962    SET_CallList(disp, _mesa_CallList);
10963    SET_CallLists(disp, _mesa_CallLists);
10964
10965    SET_DeleteLists(disp, _mesa_DeleteLists);
10966    SET_EndList(disp, _mesa_EndList);
10967    SET_GenLists(disp, _mesa_GenLists);
10968    SET_IsList(disp, _mesa_IsList);
10969    SET_ListBase(disp, _mesa_ListBase);
10970    SET_NewList(disp, _mesa_NewList);
10971 }
10972
10973
10974 #endif /* FEATURE_dlist */
10975
10976
10977 /**
10978  * Initialize display list state for given context.
10979  */
10980 void
10981 _mesa_init_display_list(struct gl_context *ctx)
10982 {
10983    static GLboolean tableInitialized = GL_FALSE;
10984
10985    /* zero-out the instruction size table, just once */
10986    if (!tableInitialized) {
10987       memset(InstSize, 0, sizeof(InstSize));
10988       tableInitialized = GL_TRUE;
10989    }
10990
10991    /* extension info */
10992    ctx->ListExt = CALLOC_STRUCT(gl_list_extensions);
10993
10994    /* Display list */
10995    ctx->ListState.CallDepth = 0;
10996    ctx->ExecuteFlag = GL_TRUE;
10997    ctx->CompileFlag = GL_FALSE;
10998    ctx->ListState.CurrentBlock = NULL;
10999    ctx->ListState.CurrentPos = 0;
11000
11001    /* Display List group */
11002    ctx->List.ListBase = 0;
11003
11004 #if FEATURE_dlist
11005    _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt);
11006 #endif
11007 }
11008
11009
11010 void
11011 _mesa_free_display_list_data(struct gl_context *ctx)
11012 {
11013    free(ctx->ListExt);
11014    ctx->ListExt = NULL;
11015 }