OSDN Git Service

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