mesa: initialize OutsideBeginEnd directly instead of through Exec
[platform/upstream/mesa.git] / src / mesa / main / dlist.c
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26
27 /**
28  * \file dlist.c
29  * Display lists management functions.
30  */
31
32 #include "api_save.h"
33 #include "api_arrayelt.h"
34 #include "draw_validate.h"
35 #include "arrayobj.h"
36 #include "enums.h"
37 #include "eval.h"
38 #include "hash.h"
39 #include "image.h"
40 #include "light.h"
41 #include "pack.h"
42 #include "pbo.h"
43 #include "teximage.h"
44 #include "texobj.h"
45 #include "varray.h"
46 #include "glthread_marshal.h"
47
48 #include "main/dispatch.h"
49
50 #include "vbo/vbo_save.h"
51 #include "util/u_inlines.h"
52 #include "util/u_memory.h"
53 #include "api_exec_decl.h"
54
55 #include "state_tracker/st_context.h"
56 #include "state_tracker/st_cb_texture.h"
57 #include "state_tracker/st_cb_bitmap.h"
58 #include "state_tracker/st_sampler_view.h"
59
60 static bool
61 _mesa_glthread_should_execute_list(struct gl_context *ctx,
62                                    struct gl_display_list *dlist);
63
64 /**
65  * Flush vertices.
66  *
67  * \param ctx GL context.
68  *
69  * Checks if dd_function_table::SaveNeedFlush is marked to flush
70  * stored (save) vertices, and calls vbo_save_SaveFlushVertices if so.
71  */
72 #define SAVE_FLUSH_VERTICES(ctx)                     \
73    do {                                              \
74       if (ctx->Driver.SaveNeedFlush)                 \
75          vbo_save_SaveFlushVertices(ctx);            \
76    } while (0)
77
78
79 /**
80  * Macro to assert that the API call was made outside the
81  * glBegin()/glEnd() pair, with return value.
82  *
83  * \param ctx GL context.
84  * \param retval value to return value in case the assertion fails.
85  */
86 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)          \
87    do {                                                                 \
88       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
89          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
90          return retval;                                                 \
91       }                                                                 \
92    } while (0)
93
94 /**
95  * Macro to assert that the API call was made outside the
96  * glBegin()/glEnd() pair.
97  *
98  * \param ctx GL context.
99  */
100 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)                              \
101    do {                                                                 \
102       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
103          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
104          return;                                                        \
105       }                                                                 \
106    } while (0)
107
108 /**
109  * Macro to assert that the API call was made outside the
110  * glBegin()/glEnd() pair and flush the vertices.
111  *
112  * \param ctx GL context.
113  */
114 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                    \
115    do {                                                                 \
116       ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                               \
117       SAVE_FLUSH_VERTICES(ctx);                                         \
118    } while (0)
119
120 /**
121  * Macro to assert that the API call was made outside the
122  * glBegin()/glEnd() pair and flush the vertices, with return value.
123  *
124  * \param ctx GL context.
125  * \param retval value to return value in case the assertion fails.
126  */
127 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
128    do {                                                                 \
129       ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);           \
130       SAVE_FLUSH_VERTICES(ctx);                                         \
131    } while (0)
132
133
134 /**
135  * Display list opcodes.
136  */
137 typedef enum
138 {
139    OPCODE_INVALID = -1,         /* Force signed enum */
140    OPCODE_ACCUM,
141    OPCODE_ALPHA_FUNC,
142    OPCODE_BIND_TEXTURE,
143    OPCODE_BITMAP,
144    OPCODE_BLEND_COLOR,
145    OPCODE_BLEND_EQUATION,
146    OPCODE_BLEND_EQUATION_SEPARATE,
147    OPCODE_BLEND_FUNC_SEPARATE,
148
149    OPCODE_BLEND_EQUATION_I,
150    OPCODE_BLEND_EQUATION_SEPARATE_I,
151    OPCODE_BLEND_FUNC_I,
152    OPCODE_BLEND_FUNC_SEPARATE_I,
153
154    OPCODE_CALL_LIST,
155    OPCODE_CALL_LISTS,
156    OPCODE_CLEAR,
157    OPCODE_CLEAR_ACCUM,
158    OPCODE_CLEAR_COLOR,
159    OPCODE_CLEAR_DEPTH,
160    OPCODE_CLEAR_INDEX,
161    OPCODE_CLEAR_STENCIL,
162    OPCODE_CLEAR_BUFFER_IV,
163    OPCODE_CLEAR_BUFFER_UIV,
164    OPCODE_CLEAR_BUFFER_FV,
165    OPCODE_CLEAR_BUFFER_FI,
166    OPCODE_CLIP_PLANE,
167    OPCODE_COLOR_MASK,
168    OPCODE_COLOR_MASK_INDEXED,
169    OPCODE_COLOR_MATERIAL,
170    OPCODE_COPY_PIXELS,
171    OPCODE_COPY_TEX_IMAGE1D,
172    OPCODE_COPY_TEX_IMAGE2D,
173    OPCODE_COPY_TEX_SUB_IMAGE1D,
174    OPCODE_COPY_TEX_SUB_IMAGE2D,
175    OPCODE_COPY_TEX_SUB_IMAGE3D,
176    OPCODE_CULL_FACE,
177    OPCODE_DEPTH_FUNC,
178    OPCODE_DEPTH_MASK,
179    OPCODE_DEPTH_RANGE,
180    OPCODE_DISABLE,
181    OPCODE_DISABLE_INDEXED,
182    OPCODE_DRAW_BUFFER,
183    OPCODE_DRAW_PIXELS,
184    OPCODE_ENABLE,
185    OPCODE_ENABLE_INDEXED,
186    OPCODE_EVALMESH1,
187    OPCODE_EVALMESH2,
188    OPCODE_FOG,
189    OPCODE_FRONT_FACE,
190    OPCODE_FRUSTUM,
191    OPCODE_HINT,
192    OPCODE_INDEX_MASK,
193    OPCODE_INIT_NAMES,
194    OPCODE_LIGHT,
195    OPCODE_LIGHT_MODEL,
196    OPCODE_LINE_STIPPLE,
197    OPCODE_LINE_WIDTH,
198    OPCODE_LIST_BASE,
199    OPCODE_LOAD_IDENTITY,
200    OPCODE_LOAD_MATRIX,
201    OPCODE_LOAD_NAME,
202    OPCODE_LOGIC_OP,
203    OPCODE_MAP1,
204    OPCODE_MAP2,
205    OPCODE_MAPGRID1,
206    OPCODE_MAPGRID2,
207    OPCODE_MATRIX_MODE,
208    OPCODE_MULT_MATRIX,
209    OPCODE_ORTHO,
210    OPCODE_PASSTHROUGH,
211    OPCODE_PIXEL_MAP,
212    OPCODE_PIXEL_TRANSFER,
213    OPCODE_PIXEL_ZOOM,
214    OPCODE_POINT_SIZE,
215    OPCODE_POINT_PARAMETERS,
216    OPCODE_POLYGON_MODE,
217    OPCODE_POLYGON_STIPPLE,
218    OPCODE_POLYGON_OFFSET,
219    OPCODE_POP_ATTRIB,
220    OPCODE_POP_MATRIX,
221    OPCODE_POP_NAME,
222    OPCODE_PRIORITIZE_TEXTURE,
223    OPCODE_PUSH_ATTRIB,
224    OPCODE_PUSH_MATRIX,
225    OPCODE_PUSH_NAME,
226    OPCODE_RASTER_POS,
227    OPCODE_READ_BUFFER,
228    OPCODE_ROTATE,
229    OPCODE_SCALE,
230    OPCODE_SCISSOR,
231    OPCODE_SELECT_TEXTURE_SGIS,
232    OPCODE_SELECT_TEXTURE_COORD_SET,
233    OPCODE_SHADE_MODEL,
234    OPCODE_STENCIL_FUNC,
235    OPCODE_STENCIL_MASK,
236    OPCODE_STENCIL_OP,
237    OPCODE_TEXENV,
238    OPCODE_TEXGEN,
239    OPCODE_TEXPARAMETER,
240    OPCODE_TEX_IMAGE1D,
241    OPCODE_TEX_IMAGE2D,
242    OPCODE_TEX_IMAGE3D,
243    OPCODE_TEX_SUB_IMAGE1D,
244    OPCODE_TEX_SUB_IMAGE2D,
245    OPCODE_TEX_SUB_IMAGE3D,
246    OPCODE_TRANSLATE,
247    OPCODE_VIEWPORT,
248    OPCODE_WINDOW_POS,
249    /* ARB_viewport_array */
250    OPCODE_VIEWPORT_ARRAY_V,
251    OPCODE_VIEWPORT_INDEXED_F,
252    OPCODE_VIEWPORT_INDEXED_FV,
253    OPCODE_SCISSOR_ARRAY_V,
254    OPCODE_SCISSOR_INDEXED,
255    OPCODE_SCISSOR_INDEXED_V,
256    OPCODE_DEPTH_ARRAY_V,
257    OPCODE_DEPTH_INDEXED,
258    /* GL_ARB_multitexture */
259    OPCODE_ACTIVE_TEXTURE,
260    /* GL_ARB_texture_compression */
261    OPCODE_COMPRESSED_TEX_IMAGE_1D,
262    OPCODE_COMPRESSED_TEX_IMAGE_2D,
263    OPCODE_COMPRESSED_TEX_IMAGE_3D,
264    OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
265    OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
266    OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
267    /* GL_ARB_multisample */
268    OPCODE_SAMPLE_COVERAGE,
269    /* GL_ARB_window_pos */
270    OPCODE_WINDOW_POS_ARB,
271    /* GL_ARB_vertex_program */
272    OPCODE_BIND_PROGRAM_ARB,
273    OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
274    /* GL_EXT_stencil_two_side */
275    OPCODE_ACTIVE_STENCIL_FACE_EXT,
276    /* GL_EXT_depth_bounds_test */
277    OPCODE_DEPTH_BOUNDS_EXT,
278    /* GL_ARB_vertex/fragment_program */
279    OPCODE_PROGRAM_STRING_ARB,
280    OPCODE_PROGRAM_ENV_PARAMETER_ARB,
281    /* GL_ARB_occlusion_query */
282    OPCODE_BEGIN_QUERY_ARB,
283    OPCODE_END_QUERY_ARB,
284    /* GL_ARB_draw_buffers */
285    OPCODE_DRAW_BUFFERS_ARB,
286    /* GL_ATI_fragment_shader */
287    OPCODE_BIND_FRAGMENT_SHADER_ATI,
288    OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
289    /* OpenGL 2.0 */
290    OPCODE_STENCIL_FUNC_SEPARATE,
291    OPCODE_STENCIL_OP_SEPARATE,
292    OPCODE_STENCIL_MASK_SEPARATE,
293    /* GL_NV_primitive_restart */
294    OPCODE_PRIMITIVE_RESTART_NV,
295    /* GL_ARB_shader_objects */
296    OPCODE_USE_PROGRAM,
297    OPCODE_UNIFORM_1F,
298    OPCODE_UNIFORM_2F,
299    OPCODE_UNIFORM_3F,
300    OPCODE_UNIFORM_4F,
301    OPCODE_UNIFORM_1FV,
302    OPCODE_UNIFORM_2FV,
303    OPCODE_UNIFORM_3FV,
304    OPCODE_UNIFORM_4FV,
305    OPCODE_UNIFORM_1I,
306    OPCODE_UNIFORM_2I,
307    OPCODE_UNIFORM_3I,
308    OPCODE_UNIFORM_4I,
309    OPCODE_UNIFORM_1IV,
310    OPCODE_UNIFORM_2IV,
311    OPCODE_UNIFORM_3IV,
312    OPCODE_UNIFORM_4IV,
313    OPCODE_UNIFORM_MATRIX22,
314    OPCODE_UNIFORM_MATRIX33,
315    OPCODE_UNIFORM_MATRIX44,
316    OPCODE_UNIFORM_MATRIX23,
317    OPCODE_UNIFORM_MATRIX32,
318    OPCODE_UNIFORM_MATRIX24,
319    OPCODE_UNIFORM_MATRIX42,
320    OPCODE_UNIFORM_MATRIX34,
321    OPCODE_UNIFORM_MATRIX43,
322
323    /* OpenGL 3.0 */
324    OPCODE_UNIFORM_1UI,
325    OPCODE_UNIFORM_2UI,
326    OPCODE_UNIFORM_3UI,
327    OPCODE_UNIFORM_4UI,
328    OPCODE_UNIFORM_1UIV,
329    OPCODE_UNIFORM_2UIV,
330    OPCODE_UNIFORM_3UIV,
331    OPCODE_UNIFORM_4UIV,
332
333    /* GL_ARB_gpu_shader_fp64 */
334    OPCODE_UNIFORM_1D,
335    OPCODE_UNIFORM_2D,
336    OPCODE_UNIFORM_3D,
337    OPCODE_UNIFORM_4D,
338    OPCODE_UNIFORM_1DV,
339    OPCODE_UNIFORM_2DV,
340    OPCODE_UNIFORM_3DV,
341    OPCODE_UNIFORM_4DV,
342    OPCODE_UNIFORM_MATRIX22D,
343    OPCODE_UNIFORM_MATRIX33D,
344    OPCODE_UNIFORM_MATRIX44D,
345    OPCODE_UNIFORM_MATRIX23D,
346    OPCODE_UNIFORM_MATRIX32D,
347    OPCODE_UNIFORM_MATRIX24D,
348    OPCODE_UNIFORM_MATRIX42D,
349    OPCODE_UNIFORM_MATRIX34D,
350    OPCODE_UNIFORM_MATRIX43D,
351
352    /* GL_ARB_gpu_shader_int64 */
353    OPCODE_UNIFORM_1I64,
354    OPCODE_UNIFORM_2I64,
355    OPCODE_UNIFORM_3I64,
356    OPCODE_UNIFORM_4I64,
357    OPCODE_UNIFORM_1I64V,
358    OPCODE_UNIFORM_2I64V,
359    OPCODE_UNIFORM_3I64V,
360    OPCODE_UNIFORM_4I64V,
361    OPCODE_UNIFORM_1UI64,
362    OPCODE_UNIFORM_2UI64,
363    OPCODE_UNIFORM_3UI64,
364    OPCODE_UNIFORM_4UI64,
365    OPCODE_UNIFORM_1UI64V,
366    OPCODE_UNIFORM_2UI64V,
367    OPCODE_UNIFORM_3UI64V,
368    OPCODE_UNIFORM_4UI64V,
369    OPCODE_PROGRAM_UNIFORM_1I64,
370    OPCODE_PROGRAM_UNIFORM_2I64,
371    OPCODE_PROGRAM_UNIFORM_3I64,
372    OPCODE_PROGRAM_UNIFORM_4I64,
373    OPCODE_PROGRAM_UNIFORM_1I64V,
374    OPCODE_PROGRAM_UNIFORM_2I64V,
375    OPCODE_PROGRAM_UNIFORM_3I64V,
376    OPCODE_PROGRAM_UNIFORM_4I64V,
377    OPCODE_PROGRAM_UNIFORM_1UI64,
378    OPCODE_PROGRAM_UNIFORM_2UI64,
379    OPCODE_PROGRAM_UNIFORM_3UI64,
380    OPCODE_PROGRAM_UNIFORM_4UI64,
381    OPCODE_PROGRAM_UNIFORM_1UI64V,
382    OPCODE_PROGRAM_UNIFORM_2UI64V,
383    OPCODE_PROGRAM_UNIFORM_3UI64V,
384    OPCODE_PROGRAM_UNIFORM_4UI64V,
385
386    /* OpenGL 4.0 / GL_ARB_tessellation_shader */
387    OPCODE_PATCH_PARAMETER_I,
388    OPCODE_PATCH_PARAMETER_FV_INNER,
389    OPCODE_PATCH_PARAMETER_FV_OUTER,
390
391    /* OpenGL 4.2 / GL_ARB_separate_shader_objects */
392    OPCODE_USE_PROGRAM_STAGES,
393    OPCODE_PROGRAM_UNIFORM_1F,
394    OPCODE_PROGRAM_UNIFORM_2F,
395    OPCODE_PROGRAM_UNIFORM_3F,
396    OPCODE_PROGRAM_UNIFORM_4F,
397    OPCODE_PROGRAM_UNIFORM_1FV,
398    OPCODE_PROGRAM_UNIFORM_2FV,
399    OPCODE_PROGRAM_UNIFORM_3FV,
400    OPCODE_PROGRAM_UNIFORM_4FV,
401    OPCODE_PROGRAM_UNIFORM_1D,
402    OPCODE_PROGRAM_UNIFORM_2D,
403    OPCODE_PROGRAM_UNIFORM_3D,
404    OPCODE_PROGRAM_UNIFORM_4D,
405    OPCODE_PROGRAM_UNIFORM_1DV,
406    OPCODE_PROGRAM_UNIFORM_2DV,
407    OPCODE_PROGRAM_UNIFORM_3DV,
408    OPCODE_PROGRAM_UNIFORM_4DV,
409    OPCODE_PROGRAM_UNIFORM_1I,
410    OPCODE_PROGRAM_UNIFORM_2I,
411    OPCODE_PROGRAM_UNIFORM_3I,
412    OPCODE_PROGRAM_UNIFORM_4I,
413    OPCODE_PROGRAM_UNIFORM_1IV,
414    OPCODE_PROGRAM_UNIFORM_2IV,
415    OPCODE_PROGRAM_UNIFORM_3IV,
416    OPCODE_PROGRAM_UNIFORM_4IV,
417    OPCODE_PROGRAM_UNIFORM_1UI,
418    OPCODE_PROGRAM_UNIFORM_2UI,
419    OPCODE_PROGRAM_UNIFORM_3UI,
420    OPCODE_PROGRAM_UNIFORM_4UI,
421    OPCODE_PROGRAM_UNIFORM_1UIV,
422    OPCODE_PROGRAM_UNIFORM_2UIV,
423    OPCODE_PROGRAM_UNIFORM_3UIV,
424    OPCODE_PROGRAM_UNIFORM_4UIV,
425    OPCODE_PROGRAM_UNIFORM_MATRIX22F,
426    OPCODE_PROGRAM_UNIFORM_MATRIX33F,
427    OPCODE_PROGRAM_UNIFORM_MATRIX44F,
428    OPCODE_PROGRAM_UNIFORM_MATRIX23F,
429    OPCODE_PROGRAM_UNIFORM_MATRIX32F,
430    OPCODE_PROGRAM_UNIFORM_MATRIX24F,
431    OPCODE_PROGRAM_UNIFORM_MATRIX42F,
432    OPCODE_PROGRAM_UNIFORM_MATRIX34F,
433    OPCODE_PROGRAM_UNIFORM_MATRIX43F,
434    OPCODE_PROGRAM_UNIFORM_MATRIX22D,
435    OPCODE_PROGRAM_UNIFORM_MATRIX33D,
436    OPCODE_PROGRAM_UNIFORM_MATRIX44D,
437    OPCODE_PROGRAM_UNIFORM_MATRIX23D,
438    OPCODE_PROGRAM_UNIFORM_MATRIX32D,
439    OPCODE_PROGRAM_UNIFORM_MATRIX24D,
440    OPCODE_PROGRAM_UNIFORM_MATRIX42D,
441    OPCODE_PROGRAM_UNIFORM_MATRIX34D,
442    OPCODE_PROGRAM_UNIFORM_MATRIX43D,
443
444    /* GL_ARB_clip_control */
445    OPCODE_CLIP_CONTROL,
446
447    /* GL_ARB_color_buffer_float */
448    OPCODE_CLAMP_COLOR,
449
450    /* GL_EXT_framebuffer_blit */
451    OPCODE_BLIT_FRAMEBUFFER,
452
453    /* Vertex attributes -- fallback for when optimized display
454     * list build isn't active.
455     */
456    OPCODE_ATTR_1F_NV,
457    OPCODE_ATTR_2F_NV,
458    OPCODE_ATTR_3F_NV,
459    OPCODE_ATTR_4F_NV,
460    OPCODE_ATTR_1F_ARB,
461    OPCODE_ATTR_2F_ARB,
462    OPCODE_ATTR_3F_ARB,
463    OPCODE_ATTR_4F_ARB,
464    OPCODE_ATTR_1I,
465    OPCODE_ATTR_2I,
466    OPCODE_ATTR_3I,
467    OPCODE_ATTR_4I,
468    OPCODE_ATTR_1D,
469    OPCODE_ATTR_2D,
470    OPCODE_ATTR_3D,
471    OPCODE_ATTR_4D,
472    OPCODE_ATTR_1UI64,
473    OPCODE_MATERIAL,
474    OPCODE_BEGIN,
475    OPCODE_END,
476    OPCODE_EVAL_C1,
477    OPCODE_EVAL_C2,
478    OPCODE_EVAL_P1,
479    OPCODE_EVAL_P2,
480
481    /* GL_EXT_provoking_vertex */
482    OPCODE_PROVOKING_VERTEX,
483
484    /* GL_EXT_transform_feedback */
485    OPCODE_BEGIN_TRANSFORM_FEEDBACK,
486    OPCODE_END_TRANSFORM_FEEDBACK,
487    OPCODE_BIND_TRANSFORM_FEEDBACK,
488    OPCODE_PAUSE_TRANSFORM_FEEDBACK,
489    OPCODE_RESUME_TRANSFORM_FEEDBACK,
490    OPCODE_DRAW_TRANSFORM_FEEDBACK,
491
492    /* GL_EXT_texture_integer */
493    OPCODE_CLEARCOLOR_I,
494    OPCODE_CLEARCOLOR_UI,
495    OPCODE_TEXPARAMETER_I,
496    OPCODE_TEXPARAMETER_UI,
497
498    /* GL_ARB_instanced_arrays */
499    OPCODE_VERTEX_ATTRIB_DIVISOR,
500
501    /* GL_NV_texture_barrier */
502    OPCODE_TEXTURE_BARRIER_NV,
503
504    /* GL_ARB_sampler_object */
505    OPCODE_BIND_SAMPLER,
506    OPCODE_SAMPLER_PARAMETERIV,
507    OPCODE_SAMPLER_PARAMETERFV,
508    OPCODE_SAMPLER_PARAMETERIIV,
509    OPCODE_SAMPLER_PARAMETERUIV,
510
511    /* ARB_compute_shader */
512    OPCODE_DISPATCH_COMPUTE,
513
514    /* GL_ARB_sync */
515    OPCODE_WAIT_SYNC,
516
517    /* GL_NV_conditional_render */
518    OPCODE_BEGIN_CONDITIONAL_RENDER,
519    OPCODE_END_CONDITIONAL_RENDER,
520
521    /* ARB_timer_query */
522    OPCODE_QUERY_COUNTER,
523
524    /* ARB_transform_feedback3 */
525    OPCODE_BEGIN_QUERY_INDEXED,
526    OPCODE_END_QUERY_INDEXED,
527    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM,
528
529    /* ARB_transform_feedback_instanced */
530    OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED,
531    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED,
532
533    /* ARB_uniform_buffer_object */
534    OPCODE_UNIFORM_BLOCK_BINDING,
535
536    /* ARB_shader_subroutines */
537    OPCODE_UNIFORM_SUBROUTINES,
538
539    /* EXT_polygon_offset_clamp */
540    OPCODE_POLYGON_OFFSET_CLAMP,
541
542    /* EXT_window_rectangles */
543    OPCODE_WINDOW_RECTANGLES,
544
545    /* NV_conservative_raster */
546    OPCODE_SUBPIXEL_PRECISION_BIAS,
547
548    /* NV_conservative_raster_dilate */
549    OPCODE_CONSERVATIVE_RASTER_PARAMETER_F,
550
551    /* NV_conservative_raster_pre_snap_triangles */
552    OPCODE_CONSERVATIVE_RASTER_PARAMETER_I,
553
554    /* EXT_direct_state_access */
555    OPCODE_MATRIX_LOAD,
556    OPCODE_MATRIX_MULT,
557    OPCODE_MATRIX_ROTATE,
558    OPCODE_MATRIX_SCALE,
559    OPCODE_MATRIX_TRANSLATE,
560    OPCODE_MATRIX_LOAD_IDENTITY,
561    OPCODE_MATRIX_ORTHO,
562    OPCODE_MATRIX_FRUSTUM,
563    OPCODE_MATRIX_PUSH,
564    OPCODE_MATRIX_POP,
565    OPCODE_TEXTUREPARAMETER_F,
566    OPCODE_TEXTUREPARAMETER_I,
567    OPCODE_TEXTUREPARAMETER_II,
568    OPCODE_TEXTUREPARAMETER_IUI,
569    OPCODE_TEXTURE_IMAGE1D,
570    OPCODE_TEXTURE_IMAGE2D,
571    OPCODE_TEXTURE_IMAGE3D,
572    OPCODE_TEXTURE_SUB_IMAGE1D,
573    OPCODE_TEXTURE_SUB_IMAGE2D,
574    OPCODE_TEXTURE_SUB_IMAGE3D,
575    OPCODE_COPY_TEXTURE_IMAGE1D,
576    OPCODE_COPY_TEXTURE_IMAGE2D,
577    OPCODE_COPY_TEXTURE_SUB_IMAGE1D,
578    OPCODE_COPY_TEXTURE_SUB_IMAGE2D,
579    OPCODE_COPY_TEXTURE_SUB_IMAGE3D,
580    OPCODE_BIND_MULTITEXTURE,
581    OPCODE_MULTITEXPARAMETER_F,
582    OPCODE_MULTITEXPARAMETER_I,
583    OPCODE_MULTITEXPARAMETER_II,
584    OPCODE_MULTITEXPARAMETER_IUI,
585    OPCODE_MULTITEX_IMAGE1D,
586    OPCODE_MULTITEX_IMAGE2D,
587    OPCODE_MULTITEX_IMAGE3D,
588    OPCODE_MULTITEX_SUB_IMAGE1D,
589    OPCODE_MULTITEX_SUB_IMAGE2D,
590    OPCODE_MULTITEX_SUB_IMAGE3D,
591    OPCODE_COPY_MULTITEX_IMAGE1D,
592    OPCODE_COPY_MULTITEX_IMAGE2D,
593    OPCODE_COPY_MULTITEX_SUB_IMAGE1D,
594    OPCODE_COPY_MULTITEX_SUB_IMAGE2D,
595    OPCODE_COPY_MULTITEX_SUB_IMAGE3D,
596    OPCODE_MULTITEXENV,
597    OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
598    OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
599    OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
600    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
601    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
602    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
603    OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
604    OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
605    OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
606    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
607    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
608    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
609    OPCODE_NAMED_PROGRAM_STRING,
610    OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER,
611
612    /* GL_ARB_ES3_2_compatibility */
613    OPCODE_PRIMITIVE_BOUNDING_BOX,
614
615    OPCODE_VERTEX_LIST,
616    OPCODE_VERTEX_LIST_LOOPBACK,
617    OPCODE_VERTEX_LIST_COPY_CURRENT,
618
619    /* The following three are meta instructions */
620    OPCODE_ERROR,                /* raise compiled-in error */
621    OPCODE_CONTINUE,
622    OPCODE_END_OF_LIST
623 } OpCode;
624
625
626 typedef union gl_dlist_node Node;
627
628
629 /** How many 4-byte dwords to store a pointer */
630 #define POINTER_DWORDS (sizeof(void *) / 4)
631
632 /* We want to keep sizeof(union gl_dlist_node) == 4 to minimize
633  * space for display lists.  The following types and functions are
634  * used to help store 4- and 8-byte pointers in 1 or 2 dlist_nodes.
635  */
636 union pointer
637 {
638    void *ptr;
639    GLuint dwords[POINTER_DWORDS];
640 };
641
642
643 /**
644  * Save a 4 or 8-byte pointer at dest (and dest+1).
645  */
646 static inline void
647 save_pointer(Node *dest, void *src)
648 {
649    union pointer p;
650    unsigned i;
651
652    STATIC_ASSERT(POINTER_DWORDS == 1 || POINTER_DWORDS == 2);
653    STATIC_ASSERT(sizeof(Node) == 4);
654
655    p.ptr = src;
656
657    for (i = 0; i < POINTER_DWORDS; i++)
658       dest[i].ui = p.dwords[i];
659 }
660
661
662 /**
663  * Retrieve a 4 or 8-byte pointer from node (node+1).
664  */
665 static inline void *
666 get_pointer(const Node *node)
667 {
668    union pointer p;
669    unsigned i;
670
671    for (i = 0; i < POINTER_DWORDS; i++)
672       p.dwords[i] = node[i].ui;
673
674    return p.ptr;
675 }
676
677
678 /**
679  * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit
680  * environment.
681  */
682 union uint64_pair
683 {
684    GLuint64 uint64;
685    GLuint uint32[2];
686 };
687
688
689 union float64_pair
690 {
691    GLdouble d;
692    GLuint uint32[2];
693 };
694
695 union int64_pair
696 {
697    GLint64 int64;
698    GLint int32[2];
699 };
700
701 #define ASSIGN_DOUBLE_TO_NODES(n, idx, value)                              \
702    do {                                                                    \
703       union float64_pair tmp;                                              \
704       tmp.d = value;                                                       \
705       n[idx].ui = tmp.uint32[0];                                           \
706       n[idx+1].ui = tmp.uint32[1];                                         \
707    } while (0)
708
709 #define ASSIGN_UINT64_TO_NODES(n, idx, value)                              \
710    do {                                                                    \
711       union uint64_pair tmp;                                               \
712       tmp.uint64 = value;                                                  \
713       n[idx].ui = tmp.uint32[0];                                           \
714       n[idx+1].ui = tmp.uint32[1];                                         \
715    } while (0)
716
717 #define ASSIGN_INT64_TO_NODES(n, idx, value)                               \
718    do {                                                                    \
719       union int64_pair tmp;                                                \
720       tmp.int64 = value;                                                   \
721       n[idx].i = tmp.int32[0];                                             \
722       n[idx+1].i = tmp.int32[1];                                           \
723    } while (0)
724
725 /**
726  * How many nodes to allocate at a time.  Note that bulk vertex data
727  * from glBegin/glVertex/glEnd primitives will typically wind up in
728  * a VBO, and not directly in the display list itself.
729  */
730 #define BLOCK_SIZE 256
731
732
733 void mesa_print_display_list(GLuint list);
734
735
736 /**
737  * Called by display list code when a display list is being deleted.
738  */
739 static void
740 vbo_destroy_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node)
741 {
742    struct gl_buffer_object *bo = node->cold->VAO[0]->BufferBinding[0].BufferObj;
743
744    if (_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
745       _mesa_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
746
747    for (gl_vertex_processing_mode mode = VP_MODE_FF; mode < VP_MODE_MAX; ++mode) {
748       _mesa_reference_vao(ctx, &node->cold->VAO[mode], NULL);
749       if (node->private_refcount[mode]) {
750          assert(node->private_refcount[mode] > 0);
751          p_atomic_add(&node->state[mode]->reference.count,
752                       -node->private_refcount[mode]);
753       }
754       pipe_vertex_state_reference(&node->state[mode], NULL);
755    }
756
757    if (node->modes) {
758       free(node->modes);
759       free(node->start_counts);
760    }
761
762    _mesa_reference_buffer_object(ctx, &node->cold->ib.obj, NULL);
763    free(node->cold->current_data);
764    node->cold->current_data = NULL;
765
766    free(node->cold->prims);
767    free(node->cold);
768 }
769
770 static void
771 vbo_print_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node, OpCode op, FILE *f)
772 {
773    GLuint i;
774    struct gl_buffer_object *buffer = node->cold->VAO[0]->BufferBinding[0].BufferObj;
775    const GLuint vertex_size = _vbo_save_get_stride(node)/sizeof(GLfloat);
776    (void) ctx;
777
778    const char *label[] = {
779       "VBO-VERTEX-LIST", "VBO-VERTEX-LIST-LOOPBACK", "VBO-VERTEX-LIST-COPY-CURRENT"
780    };
781
782    fprintf(f, "%s, %u vertices, %d primitives, %d vertsize, "
783            "buffer %p\n",
784            label[op - OPCODE_VERTEX_LIST],
785            node->cold->vertex_count, node->cold->prim_count, vertex_size,
786            buffer);
787
788    for (i = 0; i < node->cold->prim_count; i++) {
789       struct _mesa_prim *prim = &node->cold->prims[i];
790       fprintf(f, "   prim %d: %s %d..%d %s %s\n",
791              i,
792              _mesa_lookup_prim_by_nr(prim->mode),
793              prim->start,
794              prim->start + prim->count,
795              (prim->begin) ? "BEGIN" : "(wrap)",
796              (prim->end) ? "END" : "(wrap)");
797    }
798 }
799
800
801 static inline
802 Node *get_list_head(struct gl_context *ctx, struct gl_display_list *dlist)
803 {
804    return dlist->small_list ?
805       &ctx->Shared->small_dlist_store.ptr[dlist->start] :
806       dlist->Head;
807 }
808
809
810 /**
811  * Allocate a gl_display_list object with an initial block of storage.
812  * \param count  how many display list nodes/tokens to allocate
813  */
814 static struct gl_display_list *
815 make_list(GLuint name, GLuint count)
816 {
817    struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
818    dlist->Name = name;
819    dlist->Head = malloc(sizeof(Node) * count);
820    dlist->Head[0].opcode = OPCODE_END_OF_LIST;
821    return dlist;
822 }
823
824
825 /**
826  * Lookup function to just encapsulate casting.
827  */
828 struct gl_display_list *
829 _mesa_lookup_list(struct gl_context *ctx, GLuint list, bool locked)
830 {
831    return (struct gl_display_list *)
832       _mesa_HashLookupMaybeLocked(ctx->Shared->DisplayList, list, locked);
833 }
834
835
836 /**
837  * Delete the named display list, but don't remove from hash table.
838  * \param dlist - display list pointer
839  */
840 void
841 _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
842 {
843    Node *n, *block;
844
845    n = block = get_list_head(ctx, dlist);
846
847    if (!n) {
848       free(dlist->Label);
849       FREE(dlist);
850       return;
851    }
852
853    while (1) {
854       const OpCode opcode = n[0].opcode;
855
856       switch (opcode) {
857             /* for some commands, we need to free malloc'd memory */
858          case OPCODE_MAP1:
859             free(get_pointer(&n[6]));
860             break;
861          case OPCODE_MAP2:
862             free(get_pointer(&n[10]));
863             break;
864          case OPCODE_CALL_LISTS:
865             free(get_pointer(&n[3]));
866             break;
867          case OPCODE_DRAW_PIXELS:
868             free(get_pointer(&n[5]));
869             break;
870          case OPCODE_BITMAP: {
871             struct pipe_resource *tex = get_pointer(&n[7]);
872             pipe_resource_reference(&tex, NULL);
873             break;
874          }
875          case OPCODE_POLYGON_STIPPLE:
876             free(get_pointer(&n[1]));
877             break;
878          case OPCODE_TEX_IMAGE1D:
879             free(get_pointer(&n[8]));
880             break;
881          case OPCODE_TEX_IMAGE2D:
882             free(get_pointer(&n[9]));
883             break;
884          case OPCODE_TEX_IMAGE3D:
885             free(get_pointer(&n[10]));
886             break;
887          case OPCODE_TEX_SUB_IMAGE1D:
888             free(get_pointer(&n[7]));
889             break;
890          case OPCODE_TEX_SUB_IMAGE2D:
891             free(get_pointer(&n[9]));
892             break;
893          case OPCODE_TEX_SUB_IMAGE3D:
894             free(get_pointer(&n[11]));
895             break;
896          case OPCODE_COMPRESSED_TEX_IMAGE_1D:
897             free(get_pointer(&n[7]));
898             break;
899          case OPCODE_COMPRESSED_TEX_IMAGE_2D:
900             free(get_pointer(&n[8]));
901             break;
902          case OPCODE_COMPRESSED_TEX_IMAGE_3D:
903             free(get_pointer(&n[9]));
904             break;
905          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
906             free(get_pointer(&n[7]));
907             break;
908          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
909             free(get_pointer(&n[9]));
910             break;
911          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
912             free(get_pointer(&n[11]));
913             break;
914          case OPCODE_PROGRAM_STRING_ARB:
915             free(get_pointer(&n[4]));      /* program string */
916             break;
917          case OPCODE_UNIFORM_1FV:
918          case OPCODE_UNIFORM_2FV:
919          case OPCODE_UNIFORM_3FV:
920          case OPCODE_UNIFORM_4FV:
921          case OPCODE_UNIFORM_1DV:
922          case OPCODE_UNIFORM_2DV:
923          case OPCODE_UNIFORM_3DV:
924          case OPCODE_UNIFORM_4DV:
925          case OPCODE_UNIFORM_1IV:
926          case OPCODE_UNIFORM_2IV:
927          case OPCODE_UNIFORM_3IV:
928          case OPCODE_UNIFORM_4IV:
929          case OPCODE_UNIFORM_1UIV:
930          case OPCODE_UNIFORM_2UIV:
931          case OPCODE_UNIFORM_3UIV:
932          case OPCODE_UNIFORM_4UIV:
933          case OPCODE_UNIFORM_1I64V:
934          case OPCODE_UNIFORM_2I64V:
935          case OPCODE_UNIFORM_3I64V:
936          case OPCODE_UNIFORM_4I64V:
937          case OPCODE_UNIFORM_1UI64V:
938          case OPCODE_UNIFORM_2UI64V:
939          case OPCODE_UNIFORM_3UI64V:
940          case OPCODE_UNIFORM_4UI64V:
941             free(get_pointer(&n[3]));
942             break;
943          case OPCODE_UNIFORM_MATRIX22:
944          case OPCODE_UNIFORM_MATRIX33:
945          case OPCODE_UNIFORM_MATRIX44:
946          case OPCODE_UNIFORM_MATRIX24:
947          case OPCODE_UNIFORM_MATRIX42:
948          case OPCODE_UNIFORM_MATRIX23:
949          case OPCODE_UNIFORM_MATRIX32:
950          case OPCODE_UNIFORM_MATRIX34:
951          case OPCODE_UNIFORM_MATRIX43:
952          case OPCODE_UNIFORM_MATRIX22D:
953          case OPCODE_UNIFORM_MATRIX33D:
954          case OPCODE_UNIFORM_MATRIX44D:
955          case OPCODE_UNIFORM_MATRIX24D:
956          case OPCODE_UNIFORM_MATRIX42D:
957          case OPCODE_UNIFORM_MATRIX23D:
958          case OPCODE_UNIFORM_MATRIX32D:
959          case OPCODE_UNIFORM_MATRIX34D:
960          case OPCODE_UNIFORM_MATRIX43D:
961             free(get_pointer(&n[4]));
962             break;
963          case OPCODE_PROGRAM_UNIFORM_1FV:
964          case OPCODE_PROGRAM_UNIFORM_2FV:
965          case OPCODE_PROGRAM_UNIFORM_3FV:
966          case OPCODE_PROGRAM_UNIFORM_4FV:
967          case OPCODE_PROGRAM_UNIFORM_1DV:
968          case OPCODE_PROGRAM_UNIFORM_2DV:
969          case OPCODE_PROGRAM_UNIFORM_3DV:
970          case OPCODE_PROGRAM_UNIFORM_4DV:
971          case OPCODE_PROGRAM_UNIFORM_1IV:
972          case OPCODE_PROGRAM_UNIFORM_2IV:
973          case OPCODE_PROGRAM_UNIFORM_3IV:
974          case OPCODE_PROGRAM_UNIFORM_4IV:
975          case OPCODE_PROGRAM_UNIFORM_1UIV:
976          case OPCODE_PROGRAM_UNIFORM_2UIV:
977          case OPCODE_PROGRAM_UNIFORM_3UIV:
978          case OPCODE_PROGRAM_UNIFORM_4UIV:
979          case OPCODE_PROGRAM_UNIFORM_1I64V:
980          case OPCODE_PROGRAM_UNIFORM_2I64V:
981          case OPCODE_PROGRAM_UNIFORM_3I64V:
982          case OPCODE_PROGRAM_UNIFORM_4I64V:
983          case OPCODE_PROGRAM_UNIFORM_1UI64V:
984          case OPCODE_PROGRAM_UNIFORM_2UI64V:
985          case OPCODE_PROGRAM_UNIFORM_3UI64V:
986          case OPCODE_PROGRAM_UNIFORM_4UI64V:
987             free(get_pointer(&n[4]));
988             break;
989          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
990          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
991          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
992          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
993          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
994          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
995          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
996          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
997          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
998          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
999          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
1000          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
1001          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
1002          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
1003          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
1004          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
1005          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
1006          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
1007             free(get_pointer(&n[5]));
1008             break;
1009          case OPCODE_PIXEL_MAP:
1010             free(get_pointer(&n[3]));
1011             break;
1012          case OPCODE_VIEWPORT_ARRAY_V:
1013          case OPCODE_SCISSOR_ARRAY_V:
1014          case OPCODE_DEPTH_ARRAY_V:
1015          case OPCODE_UNIFORM_SUBROUTINES:
1016          case OPCODE_WINDOW_RECTANGLES:
1017             free(get_pointer(&n[3]));
1018             break;
1019          case OPCODE_TEXTURE_IMAGE1D:
1020          case OPCODE_MULTITEX_IMAGE1D:
1021             free(get_pointer(&n[9]));
1022             break;
1023          case OPCODE_TEXTURE_IMAGE2D:
1024          case OPCODE_MULTITEX_IMAGE2D:
1025             free(get_pointer(&n[10]));
1026             break;
1027          case OPCODE_TEXTURE_IMAGE3D:
1028          case OPCODE_MULTITEX_IMAGE3D:
1029             free(get_pointer(&n[11]));
1030             break;
1031          case OPCODE_TEXTURE_SUB_IMAGE1D:
1032          case OPCODE_MULTITEX_SUB_IMAGE1D:
1033          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
1034          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
1035             free(get_pointer(&n[8]));
1036             break;
1037          case OPCODE_TEXTURE_SUB_IMAGE2D:
1038          case OPCODE_MULTITEX_SUB_IMAGE2D:
1039          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
1040          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
1041             free(get_pointer(&n[10]));
1042             break;
1043          case OPCODE_TEXTURE_SUB_IMAGE3D:
1044          case OPCODE_MULTITEX_SUB_IMAGE3D:
1045          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
1046          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
1047             free(get_pointer(&n[12]));
1048             break;
1049          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
1050          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
1051             free(get_pointer(&n[8]));
1052             break;
1053          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
1054          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
1055             free(get_pointer(&n[9]));
1056             break;
1057          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
1058          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
1059             free(get_pointer(&n[10]));
1060             break;
1061          case OPCODE_NAMED_PROGRAM_STRING:
1062             free(get_pointer(&n[5]));
1063             break;
1064          case OPCODE_VERTEX_LIST:
1065          case OPCODE_VERTEX_LIST_LOOPBACK:
1066          case OPCODE_VERTEX_LIST_COPY_CURRENT:
1067             vbo_destroy_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[0]);
1068             break;
1069          case OPCODE_CONTINUE:
1070             n = (Node *) get_pointer(&n[1]);
1071             assert (!dlist->small_list);
1072             free(block);
1073             block = n;
1074             continue;
1075          case OPCODE_END_OF_LIST:
1076             if (dlist->small_list) {
1077                unsigned start = dlist->start;
1078                for (int i = 0; i < dlist->count; i++) {
1079                   util_idalloc_free(&ctx->Shared->small_dlist_store.free_idx,
1080                                     start + i);
1081                }
1082             } else {
1083                free(block);
1084             }
1085             free(dlist->Label);
1086             free(dlist);
1087             return;
1088          default:
1089             /* just increment 'n' pointer, below */
1090             ;
1091       }
1092
1093       assert(n[0].InstSize > 0);
1094       n += n[0].InstSize;
1095    }
1096 }
1097
1098
1099 /**
1100  * Destroy a display list and remove from hash table.
1101  * \param list - display list number
1102  */
1103 static void
1104 destroy_list(struct gl_context *ctx, GLuint list)
1105 {
1106    struct gl_display_list *dlist;
1107
1108    if (list == 0)
1109       return;
1110
1111    dlist = _mesa_lookup_list(ctx, list, true);
1112    if (!dlist)
1113       return;
1114
1115    _mesa_delete_list(ctx, dlist);
1116    _mesa_HashRemoveLocked(ctx->Shared->DisplayList, list);
1117 }
1118
1119
1120 /**
1121  * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects.
1122  * If width < 0 or height < 0 or format or type are invalid we'll just
1123  * return NULL.  We will not generate an error since OpenGL command
1124  * arguments aren't error-checked until the command is actually executed
1125  * (not when they're compiled).
1126  * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded.
1127  */
1128 static GLvoid *
1129 unpack_image(struct gl_context *ctx, GLuint dimensions,
1130              GLsizei width, GLsizei height, GLsizei depth,
1131              GLenum format, GLenum type, const GLvoid * pixels,
1132              const struct gl_pixelstore_attrib *unpack)
1133 {
1134    if (width <= 0 || height <= 0) {
1135       return NULL;
1136    }
1137
1138    if (_mesa_bytes_per_pixel(format, type) < 0) {
1139       /* bad format and/or type */
1140       return NULL;
1141    }
1142
1143    if (!unpack->BufferObj) {
1144       /* no PBO */
1145       GLvoid *image;
1146
1147       image = _mesa_unpack_image(dimensions, width, height, depth,
1148                                  format, type, pixels, unpack);
1149       if (pixels && !image) {
1150          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1151       }
1152       return image;
1153    }
1154    else if (_mesa_validate_pbo_access(dimensions, unpack, width, height,
1155                                       depth, format, type, INT_MAX, pixels)) {
1156       const GLubyte *map, *src;
1157       GLvoid *image;
1158
1159       map = (GLubyte *)
1160          _mesa_bufferobj_map_range(ctx, 0, unpack->BufferObj->Size,
1161                                    GL_MAP_READ_BIT, unpack->BufferObj,
1162                                    MAP_INTERNAL);
1163       if (!map) {
1164          /* unable to map src buffer! */
1165          _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
1166          return NULL;
1167       }
1168
1169       src = ADD_POINTERS(map, pixels);
1170       image = _mesa_unpack_image(dimensions, width, height, depth,
1171                                  format, type, src, unpack);
1172
1173       _mesa_bufferobj_unmap(ctx, unpack->BufferObj, MAP_INTERNAL);
1174
1175       if (!image) {
1176          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1177       }
1178       return image;
1179    }
1180
1181    /* bad access! */
1182    _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access");
1183    return NULL;
1184 }
1185
1186
1187 /** Return copy of memory */
1188 static void *
1189 memdup(const void *src, GLsizei bytes)
1190 {
1191    void *b = bytes >= 0 ? malloc(bytes) : NULL;
1192    if (b)
1193       memcpy(b, src, bytes);
1194    return b;
1195 }
1196
1197
1198 /**
1199  * Allocate space for a display list instruction (opcode + payload space).
1200  * \param opcode  the instruction opcode (OPCODE_* value)
1201  * \param bytes   instruction payload size (not counting opcode)
1202  * \param align8  does the payload need to be 8-byte aligned?
1203  *                This is only relevant in 64-bit environments.
1204  * \return pointer to allocated memory (the payload will be at pointer+1)
1205  */
1206 static Node *
1207 dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8)
1208 {
1209    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
1210    const GLuint contNodes = 1 + POINTER_DWORDS;  /* size of continue info */
1211
1212    assert(bytes <= BLOCK_SIZE * sizeof(Node));
1213
1214    /* If this node needs to start on an 8-byte boundary, pad the last node. */
1215    if (sizeof(void *) == 8 && align8 &&
1216        ctx->ListState.CurrentPos % 2 == 1) {
1217       Node *last = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos -
1218                    ctx->ListState.LastInstSize;
1219       last->InstSize++;
1220       ctx->ListState.CurrentPos++;
1221    }
1222
1223    if (ctx->ListState.CurrentPos + numNodes + contNodes > BLOCK_SIZE) {
1224       /* This block is full.  Allocate a new block and chain to it */
1225       Node *newblock;
1226       Node *n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1227       n[0].opcode = OPCODE_CONTINUE;
1228       newblock = malloc(sizeof(Node) * BLOCK_SIZE);
1229       if (!newblock) {
1230          _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
1231          return NULL;
1232       }
1233
1234       /* a fresh block should be 8-byte aligned on 64-bit systems */
1235       assert(((GLintptr) newblock) % sizeof(void *) == 0);
1236
1237       save_pointer(&n[1], newblock);
1238       ctx->ListState.CurrentBlock = newblock;
1239       ctx->ListState.CurrentPos = 0;
1240    }
1241
1242    Node *n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1243    ctx->ListState.CurrentPos += numNodes;
1244
1245    n[0].opcode = opcode;
1246    n[0].InstSize = numNodes;
1247    ctx->ListState.LastInstSize = numNodes;
1248
1249    return n;
1250 }
1251
1252
1253 void *
1254 _mesa_dlist_alloc_vertex_list(struct gl_context *ctx, bool copy_to_current)
1255 {
1256    Node *n =  dlist_alloc(ctx,
1257                           copy_to_current ? OPCODE_VERTEX_LIST_COPY_CURRENT :
1258                                             OPCODE_VERTEX_LIST,
1259                           sizeof(struct vbo_save_vertex_list) - sizeof(Node),
1260                           true);
1261    if (!n)
1262       return NULL;
1263
1264    /* Clear all nodes except the header */
1265    memset(n + 1, 0, sizeof(struct vbo_save_vertex_list) - sizeof(Node));
1266    return n;
1267 }
1268
1269
1270 /**
1271  * Allocate space for a display list instruction.  The space is basically
1272  * an array of Nodes where node[0] holds the opcode, node[1] is the first
1273  * function parameter, node[2] is the second parameter, etc.
1274  *
1275  * \param opcode  one of OPCODE_x
1276  * \param nparams  number of function parameters
1277  * \return  pointer to start of instruction space
1278  */
1279 static inline Node *
1280 alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams)
1281 {
1282    return dlist_alloc(ctx, opcode, nparams * sizeof(Node), false);
1283 }
1284
1285
1286 /*
1287  * Display List compilation functions
1288  */
1289 void GLAPIENTRY
1290 save_Accum(GLenum op, GLfloat value)
1291 {
1292    GET_CURRENT_CONTEXT(ctx);
1293    Node *n;
1294    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1295    n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
1296    if (n) {
1297       n[1].e = op;
1298       n[2].f = value;
1299    }
1300    if (ctx->ExecuteFlag) {
1301       CALL_Accum(ctx->Exec, (op, value));
1302    }
1303 }
1304
1305
1306 void GLAPIENTRY
1307 save_AlphaFunc(GLenum func, GLclampf ref)
1308 {
1309    GET_CURRENT_CONTEXT(ctx);
1310    Node *n;
1311    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1312    n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
1313    if (n) {
1314       n[1].e = func;
1315       n[2].f = (GLfloat) ref;
1316    }
1317    if (ctx->ExecuteFlag) {
1318       CALL_AlphaFunc(ctx->Exec, (func, ref));
1319    }
1320 }
1321
1322
1323 void GLAPIENTRY
1324 save_BindTexture(GLenum target, GLuint texture)
1325 {
1326    GET_CURRENT_CONTEXT(ctx);
1327    Node *n;
1328    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1329    n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
1330    if (n) {
1331       n[1].e = target;
1332       n[2].ui = texture;
1333    }
1334    if (ctx->ExecuteFlag) {
1335       CALL_BindTexture(ctx->Exec, (target, texture));
1336    }
1337 }
1338
1339
1340 void GLAPIENTRY
1341 save_Bitmap(GLsizei width, GLsizei height,
1342             GLfloat xorig, GLfloat yorig,
1343             GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
1344 {
1345    GET_CURRENT_CONTEXT(ctx);
1346    Node *n;
1347    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1348    struct pipe_resource *tex =
1349       st_make_bitmap_texture(ctx, width, height, &ctx->Unpack, pixels);
1350
1351    if (!tex) {
1352       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNewList -> glBitmap");
1353       return;
1354    }
1355
1356    n = alloc_instruction(ctx, OPCODE_BITMAP, 6 + POINTER_DWORDS);
1357    if (!n) {
1358       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNewList -> glBitmap (3)");
1359       pipe_resource_reference(&tex, NULL);
1360       return;
1361    }
1362
1363    n[1].i = (GLint) width;
1364    n[2].i = (GLint) height;
1365    n[3].f = xorig;
1366    n[4].f = yorig;
1367    n[5].f = xmove;
1368    n[6].f = ymove;
1369    save_pointer(&n[7], tex);
1370
1371    if (ctx->ExecuteFlag) {
1372       ASSERT_OUTSIDE_BEGIN_END(ctx);
1373       _mesa_bitmap(ctx, width, height, xorig, yorig, xmove, ymove, NULL, tex);
1374    }
1375 }
1376
1377
1378 void GLAPIENTRY
1379 save_BlendEquation(GLenum mode)
1380 {
1381    GET_CURRENT_CONTEXT(ctx);
1382    Node *n;
1383    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1384    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
1385    if (n) {
1386       n[1].e = mode;
1387    }
1388    if (ctx->ExecuteFlag) {
1389       CALL_BlendEquation(ctx->Exec, (mode));
1390    }
1391 }
1392
1393
1394 void GLAPIENTRY
1395 save_BlendEquationSeparate(GLenum modeRGB, GLenum modeA)
1396 {
1397    GET_CURRENT_CONTEXT(ctx);
1398    Node *n;
1399    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1400    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
1401    if (n) {
1402       n[1].e = modeRGB;
1403       n[2].e = modeA;
1404    }
1405    if (ctx->ExecuteFlag) {
1406       CALL_BlendEquationSeparate(ctx->Exec, (modeRGB, modeA));
1407    }
1408 }
1409
1410
1411 void GLAPIENTRY
1412 save_BlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB,
1413                           GLenum sfactorA, GLenum dfactorA)
1414 {
1415    GET_CURRENT_CONTEXT(ctx);
1416    Node *n;
1417    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1418    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
1419    if (n) {
1420       n[1].e = sfactorRGB;
1421       n[2].e = dfactorRGB;
1422       n[3].e = sfactorA;
1423       n[4].e = dfactorA;
1424    }
1425    if (ctx->ExecuteFlag) {
1426       CALL_BlendFuncSeparate(ctx->Exec,
1427                                 (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
1428    }
1429 }
1430
1431
1432 void GLAPIENTRY
1433 save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
1434 {
1435    save_BlendFuncSeparate(srcfactor, dstfactor, srcfactor, dstfactor);
1436 }
1437
1438
1439 void GLAPIENTRY
1440 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1441 {
1442    GET_CURRENT_CONTEXT(ctx);
1443    Node *n;
1444    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1445    n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
1446    if (n) {
1447       n[1].f = red;
1448       n[2].f = green;
1449       n[3].f = blue;
1450       n[4].f = alpha;
1451    }
1452    if (ctx->ExecuteFlag) {
1453       CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
1454    }
1455 }
1456
1457 /* GL_ARB_draw_buffers_blend */
1458 void GLAPIENTRY
1459 save_BlendFuncSeparateiARB(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
1460                         GLenum sfactorA, GLenum dfactorA)
1461 {
1462    GET_CURRENT_CONTEXT(ctx);
1463    Node *n;
1464    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1465    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
1466    if (n) {
1467       n[1].ui = buf;
1468       n[2].e = sfactorRGB;
1469       n[3].e = dfactorRGB;
1470       n[4].e = sfactorA;
1471       n[5].e = dfactorA;
1472    }
1473    if (ctx->ExecuteFlag) {
1474       CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
1475                                              sfactorA, dfactorA));
1476    }
1477 }
1478
1479 /* GL_ARB_draw_buffers_blend */
1480 void GLAPIENTRY
1481 save_BlendFunciARB(GLuint buf, GLenum sfactor, GLenum dfactor)
1482 {
1483    GET_CURRENT_CONTEXT(ctx);
1484    Node *n;
1485    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1486    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_I, 3);
1487    if (n) {
1488       n[1].ui = buf;
1489       n[2].e = sfactor;
1490       n[3].e = dfactor;
1491    }
1492    if (ctx->ExecuteFlag) {
1493       CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
1494    }
1495 }
1496
1497 /* GL_ARB_draw_buffers_blend */
1498 void GLAPIENTRY
1499 save_BlendEquationiARB(GLuint buf, GLenum mode)
1500 {
1501    GET_CURRENT_CONTEXT(ctx);
1502    Node *n;
1503    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1504    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
1505    if (n) {
1506       n[1].ui = buf;
1507       n[2].e = mode;
1508    }
1509    if (ctx->ExecuteFlag) {
1510       CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
1511    }
1512 }
1513
1514 /* GL_ARB_draw_buffers_blend */
1515 void GLAPIENTRY
1516 save_BlendEquationSeparateiARB(GLuint buf, GLenum modeRGB, GLenum modeA)
1517 {
1518    GET_CURRENT_CONTEXT(ctx);
1519    Node *n;
1520    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1521    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
1522    if (n) {
1523       n[1].ui = buf;
1524       n[2].e = modeRGB;
1525       n[3].e = modeA;
1526    }
1527    if (ctx->ExecuteFlag) {
1528       CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
1529    }
1530 }
1531
1532
1533 /* GL_ARB_draw_instanced. */
1534 void GLAPIENTRY
1535 save_DrawArraysInstancedARB(UNUSED GLenum mode,
1536                             UNUSED GLint first,
1537                             UNUSED GLsizei count,
1538                             UNUSED GLsizei primcount)
1539 {
1540    GET_CURRENT_CONTEXT(ctx);
1541    _mesa_error(ctx, GL_INVALID_OPERATION,
1542                "glDrawArraysInstanced() during display list compile");
1543 }
1544
1545 void GLAPIENTRY
1546 save_DrawElementsInstancedARB(UNUSED GLenum mode,
1547                               UNUSED GLsizei count,
1548                               UNUSED GLenum type,
1549                               UNUSED const GLvoid *indices,
1550                               UNUSED GLsizei primcount)
1551 {
1552    GET_CURRENT_CONTEXT(ctx);
1553    _mesa_error(ctx, GL_INVALID_OPERATION,
1554                "glDrawElementsInstanced() during display list compile");
1555 }
1556
1557 void GLAPIENTRY
1558 save_DrawElementsInstancedBaseVertex(UNUSED GLenum mode,
1559                                         UNUSED GLsizei count,
1560                                         UNUSED GLenum type,
1561                                         UNUSED const GLvoid *indices,
1562                                         UNUSED GLsizei primcount,
1563                                         UNUSED GLint basevertex)
1564 {
1565    GET_CURRENT_CONTEXT(ctx);
1566    _mesa_error(ctx, GL_INVALID_OPERATION,
1567                "glDrawElementsInstancedBaseVertex() during display list compile");
1568 }
1569
1570 /* GL_ARB_base_instance. */
1571 void GLAPIENTRY
1572 save_DrawArraysInstancedBaseInstance(UNUSED GLenum mode,
1573                                      UNUSED GLint first,
1574                                      UNUSED GLsizei count,
1575                                      UNUSED GLsizei primcount,
1576                                      UNUSED GLuint baseinstance)
1577 {
1578    GET_CURRENT_CONTEXT(ctx);
1579    _mesa_error(ctx, GL_INVALID_OPERATION,
1580                "glDrawArraysInstancedBaseInstance() during display list compile");
1581 }
1582
1583 void GLAPIENTRY
1584 save_DrawElementsInstancedBaseInstance(UNUSED GLenum mode,
1585                                        UNUSED GLsizei count,
1586                                        UNUSED GLenum type,
1587                                        UNUSED const void *indices,
1588                                        UNUSED GLsizei primcount,
1589                                        UNUSED GLuint baseinstance)
1590 {
1591    GET_CURRENT_CONTEXT(ctx);
1592    _mesa_error(ctx, GL_INVALID_OPERATION,
1593                "glDrawElementsInstancedBaseInstance() during display list compile");
1594 }
1595
1596 void GLAPIENTRY
1597 save_DrawElementsInstancedBaseVertexBaseInstance(UNUSED GLenum mode,
1598                                                  UNUSED GLsizei count,
1599                                                  UNUSED GLenum type,
1600                                                  UNUSED const void *indices,
1601                                                  UNUSED GLsizei primcount,
1602                                                  UNUSED GLint basevertex,
1603                                                  UNUSED GLuint baseinstance)
1604 {
1605    GET_CURRENT_CONTEXT(ctx);
1606    _mesa_error(ctx, GL_INVALID_OPERATION,
1607                "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile");
1608 }
1609
1610 void GLAPIENTRY
1611 save_DrawArraysIndirect(UNUSED GLenum mode,
1612                         UNUSED const void *indirect)
1613 {
1614    GET_CURRENT_CONTEXT(ctx);
1615    _mesa_error(ctx, GL_INVALID_OPERATION,
1616                "glDrawArraysIndirect() during display list compile");
1617 }
1618
1619 void GLAPIENTRY
1620 save_DrawElementsIndirect(UNUSED GLenum mode,
1621                           UNUSED GLenum type,
1622                           UNUSED const void *indirect)
1623 {
1624    GET_CURRENT_CONTEXT(ctx);
1625    _mesa_error(ctx, GL_INVALID_OPERATION,
1626                "glDrawElementsIndirect() during display list compile");
1627 }
1628
1629 void GLAPIENTRY
1630 save_MultiDrawArraysIndirect(UNUSED GLenum mode,
1631                              UNUSED const void *indirect,
1632                              UNUSED GLsizei primcount,
1633                              UNUSED GLsizei stride)
1634 {
1635    GET_CURRENT_CONTEXT(ctx);
1636    _mesa_error(ctx, GL_INVALID_OPERATION,
1637                "glMultiDrawArraysIndirect() during display list compile");
1638 }
1639
1640 void GLAPIENTRY
1641 save_MultiDrawElementsIndirect(UNUSED GLenum mode,
1642                                UNUSED GLenum type,
1643                                UNUSED const void *indirect,
1644                                UNUSED GLsizei primcount,
1645                                UNUSED GLsizei stride)
1646 {
1647    GET_CURRENT_CONTEXT(ctx);
1648    _mesa_error(ctx, GL_INVALID_OPERATION,
1649                "glMultiDrawElementsIndirect() during display list compile");
1650 }
1651
1652 /**
1653  * While building a display list we cache some OpenGL state.
1654  * Under some circumstances we need to invalidate that state (immediately
1655  * when we start compiling a list, or after glCallList(s)).
1656  */
1657 static void
1658 invalidate_saved_current_state(struct gl_context *ctx)
1659 {
1660    GLint i;
1661
1662    for (i = 0; i < VERT_ATTRIB_MAX; i++)
1663       ctx->ListState.ActiveAttribSize[i] = 0;
1664
1665    for (i = 0; i < MAT_ATTRIB_MAX; i++)
1666       ctx->ListState.ActiveMaterialSize[i] = 0;
1667
1668    /* Loopback usage applies recursively, so remember this state */
1669    bool use_loopback = ctx->ListState.Current.UseLoopback;
1670    memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
1671    ctx->ListState.Current.UseLoopback = use_loopback;
1672
1673    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
1674 }
1675
1676
1677 static void GLAPIENTRY
1678 save_CallList(GLuint list)
1679 {
1680    GET_CURRENT_CONTEXT(ctx);
1681    Node *n;
1682    SAVE_FLUSH_VERTICES(ctx);
1683
1684    n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
1685    if (n) {
1686       n[1].ui = list;
1687    }
1688
1689    /* After this, we don't know what state we're in.  Invalidate all
1690     * cached information previously gathered:
1691     */
1692    invalidate_saved_current_state( ctx );
1693
1694    if (ctx->ExecuteFlag) {
1695       _mesa_CallList(list);
1696    }
1697 }
1698
1699
1700 static void GLAPIENTRY
1701 save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
1702 {
1703    GET_CURRENT_CONTEXT(ctx);
1704    unsigned type_size;
1705    Node *n;
1706    void *lists_copy;
1707
1708    SAVE_FLUSH_VERTICES(ctx);
1709
1710    switch (type) {
1711    case GL_BYTE:
1712    case GL_UNSIGNED_BYTE:
1713       type_size = 1;
1714       break;
1715    case GL_SHORT:
1716    case GL_UNSIGNED_SHORT:
1717    case GL_2_BYTES:
1718       type_size = 2;
1719       break;
1720    case GL_3_BYTES:
1721       type_size = 3;
1722       break;
1723    case GL_INT:
1724    case GL_UNSIGNED_INT:
1725    case GL_FLOAT:
1726    case GL_4_BYTES:
1727       type_size = 4;
1728       break;
1729    default:
1730       type_size = 0;
1731    }
1732
1733    if (num > 0 && type_size > 0) {
1734       /* create a copy of the array of list IDs to save in the display list */
1735       lists_copy = memdup(lists, num * type_size);
1736    } else {
1737       lists_copy = NULL;
1738    }
1739
1740    n = alloc_instruction(ctx, OPCODE_CALL_LISTS, 2 + POINTER_DWORDS);
1741    if (n) {
1742       n[1].i = num;
1743       n[2].e = type;
1744       save_pointer(&n[3], lists_copy);
1745    }
1746
1747    /* After this, we don't know what state we're in.  Invalidate all
1748     * cached information previously gathered:
1749     */
1750    invalidate_saved_current_state( ctx );
1751
1752    if (ctx->ExecuteFlag) {
1753       CALL_CallLists(ctx->Exec, (num, type, lists));
1754    }
1755 }
1756
1757
1758 void GLAPIENTRY
1759 save_Clear(GLbitfield mask)
1760 {
1761    GET_CURRENT_CONTEXT(ctx);
1762    Node *n;
1763    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1764    n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
1765    if (n) {
1766       n[1].bf = mask;
1767    }
1768    if (ctx->ExecuteFlag) {
1769       CALL_Clear(ctx->Exec, (mask));
1770    }
1771 }
1772
1773
1774 void GLAPIENTRY
1775 save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
1776 {
1777    GET_CURRENT_CONTEXT(ctx);
1778    Node *n;
1779    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1780    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
1781    if (n) {
1782       n[1].e = buffer;
1783       n[2].i = drawbuffer;
1784       n[3].i = value[0];
1785       if (buffer == GL_COLOR) {
1786          n[4].i = value[1];
1787          n[5].i = value[2];
1788          n[6].i = value[3];
1789       }
1790       else {
1791          n[4].i = 0;
1792          n[5].i = 0;
1793          n[6].i = 0;
1794       }
1795    }
1796    if (ctx->ExecuteFlag) {
1797       CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));
1798    }
1799 }
1800
1801
1802 void GLAPIENTRY
1803 save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
1804 {
1805    GET_CURRENT_CONTEXT(ctx);
1806    Node *n;
1807    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1808    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
1809    if (n) {
1810       n[1].e = buffer;
1811       n[2].i = drawbuffer;
1812       n[3].ui = value[0];
1813       if (buffer == GL_COLOR) {
1814          n[4].ui = value[1];
1815          n[5].ui = value[2];
1816          n[6].ui = value[3];
1817       }
1818       else {
1819          n[4].ui = 0;
1820          n[5].ui = 0;
1821          n[6].ui = 0;
1822       }
1823    }
1824    if (ctx->ExecuteFlag) {
1825       CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));
1826    }
1827 }
1828
1829
1830 void GLAPIENTRY
1831 save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
1832 {
1833    GET_CURRENT_CONTEXT(ctx);
1834    Node *n;
1835    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1836    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
1837    if (n) {
1838       n[1].e = buffer;
1839       n[2].i = drawbuffer;
1840       n[3].f = value[0];
1841       if (buffer == GL_COLOR) {
1842          n[4].f = value[1];
1843          n[5].f = value[2];
1844          n[6].f = value[3];
1845       }
1846       else {
1847          n[4].f = 0.0F;
1848          n[5].f = 0.0F;
1849          n[6].f = 0.0F;
1850       }
1851    }
1852    if (ctx->ExecuteFlag) {
1853       CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value));
1854    }
1855 }
1856
1857
1858 void GLAPIENTRY
1859 save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
1860                    GLfloat depth, GLint stencil)
1861 {
1862    GET_CURRENT_CONTEXT(ctx);
1863    Node *n;
1864    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1865    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
1866    if (n) {
1867       n[1].e = buffer;
1868       n[2].i = drawbuffer;
1869       n[3].f = depth;
1870       n[4].i = stencil;
1871    }
1872    if (ctx->ExecuteFlag) {
1873       CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));
1874    }
1875 }
1876
1877
1878 void GLAPIENTRY
1879 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1880 {
1881    GET_CURRENT_CONTEXT(ctx);
1882    Node *n;
1883    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1884    n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
1885    if (n) {
1886       n[1].f = red;
1887       n[2].f = green;
1888       n[3].f = blue;
1889       n[4].f = alpha;
1890    }
1891    if (ctx->ExecuteFlag) {
1892       CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
1893    }
1894 }
1895
1896
1897 void GLAPIENTRY
1898 save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1899 {
1900    GET_CURRENT_CONTEXT(ctx);
1901    Node *n;
1902    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1903    n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
1904    if (n) {
1905       n[1].f = red;
1906       n[2].f = green;
1907       n[3].f = blue;
1908       n[4].f = alpha;
1909    }
1910    if (ctx->ExecuteFlag) {
1911       CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
1912    }
1913 }
1914
1915
1916 void GLAPIENTRY
1917 save_ClearDepth(GLclampd depth)
1918 {
1919    GET_CURRENT_CONTEXT(ctx);
1920    Node *n;
1921    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1922    n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
1923    if (n) {
1924       n[1].f = (GLfloat) depth;
1925    }
1926    if (ctx->ExecuteFlag) {
1927       CALL_ClearDepth(ctx->Exec, (depth));
1928    }
1929 }
1930
1931
1932 void GLAPIENTRY
1933 save_ClearIndex(GLfloat c)
1934 {
1935    GET_CURRENT_CONTEXT(ctx);
1936    Node *n;
1937    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1938    n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
1939    if (n) {
1940       n[1].f = c;
1941    }
1942    if (ctx->ExecuteFlag) {
1943       CALL_ClearIndex(ctx->Exec, (c));
1944    }
1945 }
1946
1947
1948 void GLAPIENTRY
1949 save_ClearStencil(GLint s)
1950 {
1951    GET_CURRENT_CONTEXT(ctx);
1952    Node *n;
1953    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1954    n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
1955    if (n) {
1956       n[1].i = s;
1957    }
1958    if (ctx->ExecuteFlag) {
1959       CALL_ClearStencil(ctx->Exec, (s));
1960    }
1961 }
1962
1963
1964 void GLAPIENTRY
1965 save_ClipPlane(GLenum plane, const GLdouble * equ)
1966 {
1967    GET_CURRENT_CONTEXT(ctx);
1968    Node *n;
1969    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1970    n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
1971    if (n) {
1972       n[1].e = plane;
1973       n[2].f = (GLfloat) equ[0];
1974       n[3].f = (GLfloat) equ[1];
1975       n[4].f = (GLfloat) equ[2];
1976       n[5].f = (GLfloat) equ[3];
1977    }
1978    if (ctx->ExecuteFlag) {
1979       CALL_ClipPlane(ctx->Exec, (plane, equ));
1980    }
1981 }
1982
1983
1984
1985 void GLAPIENTRY
1986 save_ColorMask(GLboolean red, GLboolean green,
1987                GLboolean blue, GLboolean alpha)
1988 {
1989    GET_CURRENT_CONTEXT(ctx);
1990    Node *n;
1991    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1992    n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
1993    if (n) {
1994       n[1].b = red;
1995       n[2].b = green;
1996       n[3].b = blue;
1997       n[4].b = alpha;
1998    }
1999    if (ctx->ExecuteFlag) {
2000       CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
2001    }
2002 }
2003
2004
2005 void GLAPIENTRY
2006 save_ColorMaski(GLuint buf, GLboolean red, GLboolean green,
2007                       GLboolean blue, GLboolean alpha)
2008 {
2009    GET_CURRENT_CONTEXT(ctx);
2010    Node *n;
2011    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2012    n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
2013    if (n) {
2014       n[1].ui = buf;
2015       n[2].b = red;
2016       n[3].b = green;
2017       n[4].b = blue;
2018       n[5].b = alpha;
2019    }
2020    if (ctx->ExecuteFlag) {
2021       /*CALL_ColorMaski(ctx->Exec, (buf, red, green, blue, alpha));*/
2022    }
2023 }
2024
2025
2026 void GLAPIENTRY
2027 save_ColorMaterial(GLenum face, GLenum mode)
2028 {
2029    GET_CURRENT_CONTEXT(ctx);
2030    Node *n;
2031    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2032
2033    n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
2034    if (n) {
2035       n[1].e = face;
2036       n[2].e = mode;
2037    }
2038    if (ctx->ExecuteFlag) {
2039       CALL_ColorMaterial(ctx->Exec, (face, mode));
2040    }
2041 }
2042
2043
2044 void GLAPIENTRY
2045 save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
2046 {
2047    GET_CURRENT_CONTEXT(ctx);
2048    Node *n;
2049    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2050    n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
2051    if (n) {
2052       n[1].i = x;
2053       n[2].i = y;
2054       n[3].i = (GLint) width;
2055       n[4].i = (GLint) height;
2056       n[5].e = type;
2057    }
2058    if (ctx->ExecuteFlag) {
2059       CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
2060    }
2061 }
2062
2063
2064
2065 void GLAPIENTRY
2066 save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
2067                     GLint x, GLint y, GLsizei width, GLint border)
2068 {
2069    GET_CURRENT_CONTEXT(ctx);
2070    Node *n;
2071    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2072    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
2073    if (n) {
2074       n[1].e = target;
2075       n[2].i = level;
2076       n[3].e = internalformat;
2077       n[4].i = x;
2078       n[5].i = y;
2079       n[6].i = width;
2080       n[7].i = border;
2081    }
2082    if (ctx->ExecuteFlag) {
2083       CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
2084                                       x, y, width, border));
2085    }
2086 }
2087
2088
2089 void GLAPIENTRY
2090 save_CopyTexImage2D(GLenum target, GLint level,
2091                     GLenum internalformat,
2092                     GLint x, GLint y, GLsizei width,
2093                     GLsizei height, GLint border)
2094 {
2095    GET_CURRENT_CONTEXT(ctx);
2096    Node *n;
2097    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2098    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
2099    if (n) {
2100       n[1].e = target;
2101       n[2].i = level;
2102       n[3].e = internalformat;
2103       n[4].i = x;
2104       n[5].i = y;
2105       n[6].i = width;
2106       n[7].i = height;
2107       n[8].i = border;
2108    }
2109    if (ctx->ExecuteFlag) {
2110       CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
2111                                       x, y, width, height, border));
2112    }
2113 }
2114
2115
2116
2117 void GLAPIENTRY
2118 save_CopyTexSubImage1D(GLenum target, GLint level,
2119                        GLint xoffset, GLint x, GLint y, GLsizei width)
2120 {
2121    GET_CURRENT_CONTEXT(ctx);
2122    Node *n;
2123    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2124    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
2125    if (n) {
2126       n[1].e = target;
2127       n[2].i = level;
2128       n[3].i = xoffset;
2129       n[4].i = x;
2130       n[5].i = y;
2131       n[6].i = width;
2132    }
2133    if (ctx->ExecuteFlag) {
2134       CALL_CopyTexSubImage1D(ctx->Exec,
2135                              (target, level, xoffset, x, y, width));
2136    }
2137 }
2138
2139
2140 void GLAPIENTRY
2141 save_CopyTexSubImage2D(GLenum target, GLint level,
2142                        GLint xoffset, GLint yoffset,
2143                        GLint x, GLint y, GLsizei width, GLint height)
2144 {
2145    GET_CURRENT_CONTEXT(ctx);
2146    Node *n;
2147    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2148    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
2149    if (n) {
2150       n[1].e = target;
2151       n[2].i = level;
2152       n[3].i = xoffset;
2153       n[4].i = yoffset;
2154       n[5].i = x;
2155       n[6].i = y;
2156       n[7].i = width;
2157       n[8].i = height;
2158    }
2159    if (ctx->ExecuteFlag) {
2160       CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
2161                                          x, y, width, height));
2162    }
2163 }
2164
2165
2166 void GLAPIENTRY
2167 save_CopyTexSubImage3D(GLenum target, GLint level,
2168                        GLint xoffset, GLint yoffset, GLint zoffset,
2169                        GLint x, GLint y, GLsizei width, GLint height)
2170 {
2171    GET_CURRENT_CONTEXT(ctx);
2172    Node *n;
2173    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2174    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
2175    if (n) {
2176       n[1].e = target;
2177       n[2].i = level;
2178       n[3].i = xoffset;
2179       n[4].i = yoffset;
2180       n[5].i = zoffset;
2181       n[6].i = x;
2182       n[7].i = y;
2183       n[8].i = width;
2184       n[9].i = height;
2185    }
2186    if (ctx->ExecuteFlag) {
2187       CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
2188                                          xoffset, yoffset, zoffset,
2189                                          x, y, width, height));
2190    }
2191 }
2192
2193
2194 void GLAPIENTRY
2195 save_CullFace(GLenum mode)
2196 {
2197    GET_CURRENT_CONTEXT(ctx);
2198    Node *n;
2199    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2200    n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
2201    if (n) {
2202       n[1].e = mode;
2203    }
2204    if (ctx->ExecuteFlag) {
2205       CALL_CullFace(ctx->Exec, (mode));
2206    }
2207 }
2208
2209
2210 void GLAPIENTRY
2211 save_DepthFunc(GLenum func)
2212 {
2213    GET_CURRENT_CONTEXT(ctx);
2214    Node *n;
2215    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2216    n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
2217    if (n) {
2218       n[1].e = func;
2219    }
2220    if (ctx->ExecuteFlag) {
2221       CALL_DepthFunc(ctx->Exec, (func));
2222    }
2223 }
2224
2225
2226 void GLAPIENTRY
2227 save_DepthMask(GLboolean mask)
2228 {
2229    GET_CURRENT_CONTEXT(ctx);
2230    Node *n;
2231    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2232    n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
2233    if (n) {
2234       n[1].b = mask;
2235    }
2236    if (ctx->ExecuteFlag) {
2237       CALL_DepthMask(ctx->Exec, (mask));
2238    }
2239 }
2240
2241
2242 void GLAPIENTRY
2243 save_DepthRange(GLclampd nearval, GLclampd farval)
2244 {
2245    GET_CURRENT_CONTEXT(ctx);
2246    Node *n;
2247    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2248    n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
2249    if (n) {
2250       n[1].f = (GLfloat) nearval;
2251       n[2].f = (GLfloat) farval;
2252    }
2253    if (ctx->ExecuteFlag) {
2254       CALL_DepthRange(ctx->Exec, (nearval, farval));
2255    }
2256 }
2257
2258
2259 void GLAPIENTRY
2260 save_Disable(GLenum cap)
2261 {
2262    GET_CURRENT_CONTEXT(ctx);
2263    Node *n;
2264    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2265    n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
2266    if (n) {
2267       n[1].e = cap;
2268    }
2269    if (ctx->ExecuteFlag) {
2270       CALL_Disable(ctx->Exec, (cap));
2271    }
2272 }
2273
2274
2275 void GLAPIENTRY
2276 save_Disablei(GLuint index, GLenum cap)
2277 {
2278    GET_CURRENT_CONTEXT(ctx);
2279    Node *n;
2280    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2281    n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
2282    if (n) {
2283       n[1].ui = index;
2284       n[2].e = cap;
2285    }
2286    if (ctx->ExecuteFlag) {
2287       CALL_Disablei(ctx->Exec, (index, cap));
2288    }
2289 }
2290
2291
2292 void GLAPIENTRY
2293 save_DrawBuffer(GLenum mode)
2294 {
2295    GET_CURRENT_CONTEXT(ctx);
2296    Node *n;
2297    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2298    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
2299    if (n) {
2300       n[1].e = mode;
2301    }
2302    if (ctx->ExecuteFlag) {
2303       CALL_DrawBuffer(ctx->Exec, (mode));
2304    }
2305 }
2306
2307
2308 void GLAPIENTRY
2309 save_DrawPixels(GLsizei width, GLsizei height,
2310                 GLenum format, GLenum type, const GLvoid * pixels)
2311 {
2312    GET_CURRENT_CONTEXT(ctx);
2313    Node *n;
2314
2315    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2316
2317    n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 4 + POINTER_DWORDS);
2318    if (n) {
2319       n[1].i = width;
2320       n[2].i = height;
2321       n[3].e = format;
2322       n[4].e = type;
2323       save_pointer(&n[5],
2324                    unpack_image(ctx, 2, width, height, 1, format, type,
2325                                 pixels, &ctx->Unpack));
2326    }
2327    if (ctx->ExecuteFlag) {
2328       CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
2329    }
2330 }
2331
2332
2333
2334 void GLAPIENTRY
2335 save_Enable(GLenum cap)
2336 {
2337    GET_CURRENT_CONTEXT(ctx);
2338    Node *n;
2339    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2340    n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
2341    if (n) {
2342       n[1].e = cap;
2343    }
2344    if (ctx->ExecuteFlag) {
2345       CALL_Enable(ctx->Exec, (cap));
2346    }
2347 }
2348
2349
2350
2351 void GLAPIENTRY
2352 save_Enablei(GLuint index, GLenum cap)
2353 {
2354    GET_CURRENT_CONTEXT(ctx);
2355    Node *n;
2356    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2357    n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
2358    if (n) {
2359       n[1].ui = index;
2360       n[2].e = cap;
2361    }
2362    if (ctx->ExecuteFlag) {
2363       CALL_Enablei(ctx->Exec, (index, cap));
2364    }
2365 }
2366
2367
2368
2369 void GLAPIENTRY
2370 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
2371 {
2372    GET_CURRENT_CONTEXT(ctx);
2373    Node *n;
2374    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2375    n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
2376    if (n) {
2377       n[1].e = mode;
2378       n[2].i = i1;
2379       n[3].i = i2;
2380    }
2381    if (ctx->ExecuteFlag) {
2382       CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
2383    }
2384 }
2385
2386
2387 void GLAPIENTRY
2388 save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
2389 {
2390    GET_CURRENT_CONTEXT(ctx);
2391    Node *n;
2392    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2393    n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
2394    if (n) {
2395       n[1].e = mode;
2396       n[2].i = i1;
2397       n[3].i = i2;
2398       n[4].i = j1;
2399       n[5].i = j2;
2400    }
2401    if (ctx->ExecuteFlag) {
2402       CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
2403    }
2404 }
2405
2406
2407
2408
2409 void GLAPIENTRY
2410 save_Fogfv(GLenum pname, const GLfloat *params)
2411 {
2412    GET_CURRENT_CONTEXT(ctx);
2413    Node *n;
2414    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2415    n = alloc_instruction(ctx, OPCODE_FOG, 5);
2416    if (n) {
2417       n[1].e = pname;
2418       n[2].f = params[0];
2419       n[3].f = params[1];
2420       n[4].f = params[2];
2421       n[5].f = params[3];
2422    }
2423    if (ctx->ExecuteFlag) {
2424       CALL_Fogfv(ctx->Exec, (pname, params));
2425    }
2426 }
2427
2428
2429 void GLAPIENTRY
2430 save_Fogf(GLenum pname, GLfloat param)
2431 {
2432    GLfloat parray[4];
2433    parray[0] = param;
2434    parray[1] = parray[2] = parray[3] = 0.0F;
2435    save_Fogfv(pname, parray);
2436 }
2437
2438
2439 void GLAPIENTRY
2440 save_Fogiv(GLenum pname, const GLint *params)
2441 {
2442    GLfloat p[4];
2443    switch (pname) {
2444    case GL_FOG_MODE:
2445    case GL_FOG_DENSITY:
2446    case GL_FOG_START:
2447    case GL_FOG_END:
2448    case GL_FOG_INDEX:
2449    case GL_FOG_COORDINATE_SOURCE:
2450       p[0] = (GLfloat) *params;
2451       p[1] = 0.0f;
2452       p[2] = 0.0f;
2453       p[3] = 0.0f;
2454       break;
2455    case GL_FOG_COLOR:
2456       p[0] = INT_TO_FLOAT(params[0]);
2457       p[1] = INT_TO_FLOAT(params[1]);
2458       p[2] = INT_TO_FLOAT(params[2]);
2459       p[3] = INT_TO_FLOAT(params[3]);
2460       break;
2461    default:
2462       /* Error will be caught later in gl_Fogfv */
2463       ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
2464    }
2465    save_Fogfv(pname, p);
2466 }
2467
2468
2469 void GLAPIENTRY
2470 save_Fogi(GLenum pname, GLint param)
2471 {
2472    GLint parray[4];
2473    parray[0] = param;
2474    parray[1] = parray[2] = parray[3] = 0;
2475    save_Fogiv(pname, parray);
2476 }
2477
2478
2479 void GLAPIENTRY
2480 save_FrontFace(GLenum mode)
2481 {
2482    GET_CURRENT_CONTEXT(ctx);
2483    Node *n;
2484    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2485    n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
2486    if (n) {
2487       n[1].e = mode;
2488    }
2489    if (ctx->ExecuteFlag) {
2490       CALL_FrontFace(ctx->Exec, (mode));
2491    }
2492 }
2493
2494
2495 void GLAPIENTRY
2496 save_Frustum(GLdouble left, GLdouble right,
2497              GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2498 {
2499    GET_CURRENT_CONTEXT(ctx);
2500    Node *n;
2501    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2502    n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
2503    if (n) {
2504       n[1].f = (GLfloat) left;
2505       n[2].f = (GLfloat) right;
2506       n[3].f = (GLfloat) bottom;
2507       n[4].f = (GLfloat) top;
2508       n[5].f = (GLfloat) nearval;
2509       n[6].f = (GLfloat) farval;
2510    }
2511    if (ctx->ExecuteFlag) {
2512       CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
2513    }
2514 }
2515
2516
2517 void GLAPIENTRY
2518 save_Hint(GLenum target, GLenum mode)
2519 {
2520    GET_CURRENT_CONTEXT(ctx);
2521    Node *n;
2522    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2523    n = alloc_instruction(ctx, OPCODE_HINT, 2);
2524    if (n) {
2525       n[1].e = target;
2526       n[2].e = mode;
2527    }
2528    if (ctx->ExecuteFlag) {
2529       CALL_Hint(ctx->Exec, (target, mode));
2530    }
2531 }
2532
2533
2534 void GLAPIENTRY
2535 save_IndexMask(GLuint mask)
2536 {
2537    GET_CURRENT_CONTEXT(ctx);
2538    Node *n;
2539    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2540    n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
2541    if (n) {
2542       n[1].ui = mask;
2543    }
2544    if (ctx->ExecuteFlag) {
2545       CALL_IndexMask(ctx->Exec, (mask));
2546    }
2547 }
2548
2549
2550 void GLAPIENTRY
2551 save_InitNames(void)
2552 {
2553    GET_CURRENT_CONTEXT(ctx);
2554    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2555    (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
2556    if (ctx->ExecuteFlag) {
2557       CALL_InitNames(ctx->Exec, ());
2558    }
2559 }
2560
2561
2562 void GLAPIENTRY
2563 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2564 {
2565    GET_CURRENT_CONTEXT(ctx);
2566    Node *n;
2567    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2568    n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
2569    if (n) {
2570       GLint i, nParams;
2571       n[1].e = light;
2572       n[2].e = pname;
2573       switch (pname) {
2574       case GL_AMBIENT:
2575          nParams = 4;
2576          break;
2577       case GL_DIFFUSE:
2578          nParams = 4;
2579          break;
2580       case GL_SPECULAR:
2581          nParams = 4;
2582          break;
2583       case GL_POSITION:
2584          nParams = 4;
2585          break;
2586       case GL_SPOT_DIRECTION:
2587          nParams = 3;
2588          break;
2589       case GL_SPOT_EXPONENT:
2590          nParams = 1;
2591          break;
2592       case GL_SPOT_CUTOFF:
2593          nParams = 1;
2594          break;
2595       case GL_CONSTANT_ATTENUATION:
2596          nParams = 1;
2597          break;
2598       case GL_LINEAR_ATTENUATION:
2599          nParams = 1;
2600          break;
2601       case GL_QUADRATIC_ATTENUATION:
2602          nParams = 1;
2603          break;
2604       default:
2605          nParams = 0;
2606       }
2607       for (i = 0; i < nParams; i++) {
2608          n[3 + i].f = params[i];
2609       }
2610    }
2611    if (ctx->ExecuteFlag) {
2612       CALL_Lightfv(ctx->Exec, (light, pname, params));
2613    }
2614 }
2615
2616
2617 void GLAPIENTRY
2618 save_Lightf(GLenum light, GLenum pname, GLfloat param)
2619 {
2620    GLfloat parray[4];
2621    parray[0] = param;
2622    parray[1] = parray[2] = parray[3] = 0.0F;
2623    save_Lightfv(light, pname, parray);
2624 }
2625
2626
2627 void GLAPIENTRY
2628 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2629 {
2630    GLfloat fparam[4];
2631    switch (pname) {
2632    case GL_AMBIENT:
2633    case GL_DIFFUSE:
2634    case GL_SPECULAR:
2635       fparam[0] = INT_TO_FLOAT(params[0]);
2636       fparam[1] = INT_TO_FLOAT(params[1]);
2637       fparam[2] = INT_TO_FLOAT(params[2]);
2638       fparam[3] = INT_TO_FLOAT(params[3]);
2639       break;
2640    case GL_POSITION:
2641       fparam[0] = (GLfloat) params[0];
2642       fparam[1] = (GLfloat) params[1];
2643       fparam[2] = (GLfloat) params[2];
2644       fparam[3] = (GLfloat) params[3];
2645       break;
2646    case GL_SPOT_DIRECTION:
2647       fparam[0] = (GLfloat) params[0];
2648       fparam[1] = (GLfloat) params[1];
2649       fparam[2] = (GLfloat) params[2];
2650       break;
2651    case GL_SPOT_EXPONENT:
2652    case GL_SPOT_CUTOFF:
2653    case GL_CONSTANT_ATTENUATION:
2654    case GL_LINEAR_ATTENUATION:
2655    case GL_QUADRATIC_ATTENUATION:
2656       fparam[0] = (GLfloat) params[0];
2657       break;
2658    default:
2659       /* error will be caught later in gl_Lightfv */
2660       ;
2661    }
2662    save_Lightfv(light, pname, fparam);
2663 }
2664
2665
2666 void GLAPIENTRY
2667 save_Lighti(GLenum light, GLenum pname, GLint param)
2668 {
2669    GLint parray[4];
2670    parray[0] = param;
2671    parray[1] = parray[2] = parray[3] = 0;
2672    save_Lightiv(light, pname, parray);
2673 }
2674
2675
2676 void GLAPIENTRY
2677 save_LightModelfv(GLenum pname, const GLfloat *params)
2678 {
2679    GET_CURRENT_CONTEXT(ctx);
2680    Node *n;
2681    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2682    n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
2683    if (n) {
2684       n[1].e = pname;
2685       n[2].f = params[0];
2686       n[3].f = params[1];
2687       n[4].f = params[2];
2688       n[5].f = params[3];
2689    }
2690    if (ctx->ExecuteFlag) {
2691       CALL_LightModelfv(ctx->Exec, (pname, params));
2692    }
2693 }
2694
2695
2696 void GLAPIENTRY
2697 save_LightModelf(GLenum pname, GLfloat param)
2698 {
2699    GLfloat parray[4];
2700    parray[0] = param;
2701    parray[1] = parray[2] = parray[3] = 0.0F;
2702    save_LightModelfv(pname, parray);
2703 }
2704
2705
2706 void GLAPIENTRY
2707 save_LightModeliv(GLenum pname, const GLint *params)
2708 {
2709    GLfloat fparam[4];
2710    switch (pname) {
2711    case GL_LIGHT_MODEL_AMBIENT:
2712       fparam[0] = INT_TO_FLOAT(params[0]);
2713       fparam[1] = INT_TO_FLOAT(params[1]);
2714       fparam[2] = INT_TO_FLOAT(params[2]);
2715       fparam[3] = INT_TO_FLOAT(params[3]);
2716       break;
2717    case GL_LIGHT_MODEL_LOCAL_VIEWER:
2718    case GL_LIGHT_MODEL_TWO_SIDE:
2719    case GL_LIGHT_MODEL_COLOR_CONTROL:
2720       fparam[0] = (GLfloat) params[0];
2721       fparam[1] = 0.0F;
2722       fparam[2] = 0.0F;
2723       fparam[3] = 0.0F;
2724       break;
2725    default:
2726       /* Error will be caught later in gl_LightModelfv */
2727       ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
2728    }
2729    save_LightModelfv(pname, fparam);
2730 }
2731
2732
2733 void GLAPIENTRY
2734 save_LightModeli(GLenum pname, GLint param)
2735 {
2736    GLint parray[4];
2737    parray[0] = param;
2738    parray[1] = parray[2] = parray[3] = 0;
2739    save_LightModeliv(pname, parray);
2740 }
2741
2742
2743 void GLAPIENTRY
2744 save_LineStipple(GLint factor, GLushort pattern)
2745 {
2746    GET_CURRENT_CONTEXT(ctx);
2747    Node *n;
2748    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2749    n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
2750    if (n) {
2751       n[1].i = factor;
2752       n[2].us = pattern;
2753    }
2754    if (ctx->ExecuteFlag) {
2755       CALL_LineStipple(ctx->Exec, (factor, pattern));
2756    }
2757 }
2758
2759
2760 void GLAPIENTRY
2761 save_LineWidth(GLfloat width)
2762 {
2763    GET_CURRENT_CONTEXT(ctx);
2764    Node *n;
2765    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2766    n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
2767    if (n) {
2768       n[1].f = width;
2769    }
2770    if (ctx->ExecuteFlag) {
2771       CALL_LineWidth(ctx->Exec, (width));
2772    }
2773 }
2774
2775
2776 void GLAPIENTRY
2777 save_ListBase(GLuint base)
2778 {
2779    GET_CURRENT_CONTEXT(ctx);
2780    Node *n;
2781    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2782    n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
2783    if (n) {
2784       n[1].ui = base;
2785    }
2786    if (ctx->ExecuteFlag) {
2787       CALL_ListBase(ctx->Exec, (base));
2788    }
2789 }
2790
2791
2792 void GLAPIENTRY
2793 save_LoadIdentity(void)
2794 {
2795    GET_CURRENT_CONTEXT(ctx);
2796    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2797    (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
2798    if (ctx->ExecuteFlag) {
2799       CALL_LoadIdentity(ctx->Exec, ());
2800    }
2801 }
2802
2803
2804 void GLAPIENTRY
2805 save_LoadMatrixf(const GLfloat * m)
2806 {
2807    GET_CURRENT_CONTEXT(ctx);
2808    Node *n;
2809    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2810    n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
2811    if (n) {
2812       GLuint i;
2813       for (i = 0; i < 16; i++) {
2814          n[1 + i].f = m[i];
2815       }
2816    }
2817    if (ctx->ExecuteFlag) {
2818       CALL_LoadMatrixf(ctx->Exec, (m));
2819    }
2820 }
2821
2822
2823 void GLAPIENTRY
2824 save_LoadMatrixd(const GLdouble * m)
2825 {
2826    GLfloat f[16];
2827    GLint i;
2828    for (i = 0; i < 16; i++) {
2829       f[i] = (GLfloat) m[i];
2830    }
2831    save_LoadMatrixf(f);
2832 }
2833
2834
2835 void GLAPIENTRY
2836 save_LoadName(GLuint name)
2837 {
2838    GET_CURRENT_CONTEXT(ctx);
2839    Node *n;
2840    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2841    n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
2842    if (n) {
2843       n[1].ui = name;
2844    }
2845    if (ctx->ExecuteFlag) {
2846       CALL_LoadName(ctx->Exec, (name));
2847    }
2848 }
2849
2850
2851 void GLAPIENTRY
2852 save_LogicOp(GLenum opcode)
2853 {
2854    GET_CURRENT_CONTEXT(ctx);
2855    Node *n;
2856    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2857    n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
2858    if (n) {
2859       n[1].e = opcode;
2860    }
2861    if (ctx->ExecuteFlag) {
2862       CALL_LogicOp(ctx->Exec, (opcode));
2863    }
2864 }
2865
2866
2867 void GLAPIENTRY
2868 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
2869            GLint order, const GLdouble * points)
2870 {
2871    GET_CURRENT_CONTEXT(ctx);
2872    Node *n;
2873    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2874    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
2875    if (n) {
2876       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
2877       n[1].e = target;
2878       n[2].f = (GLfloat) u1;
2879       n[3].f = (GLfloat) u2;
2880       n[4].i = _mesa_evaluator_components(target);      /* stride */
2881       n[5].i = order;
2882       save_pointer(&n[6], pnts);
2883    }
2884    if (ctx->ExecuteFlag) {
2885       CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
2886    }
2887 }
2888
2889 void GLAPIENTRY
2890 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
2891            GLint order, const GLfloat * points)
2892 {
2893    GET_CURRENT_CONTEXT(ctx);
2894    Node *n;
2895    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2896    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
2897    if (n) {
2898       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
2899       n[1].e = target;
2900       n[2].f = u1;
2901       n[3].f = u2;
2902       n[4].i = _mesa_evaluator_components(target);      /* stride */
2903       n[5].i = order;
2904       save_pointer(&n[6], pnts);
2905    }
2906    if (ctx->ExecuteFlag) {
2907       CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
2908    }
2909 }
2910
2911
2912 void GLAPIENTRY
2913 save_Map2d(GLenum target,
2914            GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
2915            GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
2916            const GLdouble * points)
2917 {
2918    GET_CURRENT_CONTEXT(ctx);
2919    Node *n;
2920    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2921    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
2922    if (n) {
2923       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
2924                                               vstride, vorder, points);
2925       n[1].e = target;
2926       n[2].f = (GLfloat) u1;
2927       n[3].f = (GLfloat) u2;
2928       n[4].f = (GLfloat) v1;
2929       n[5].f = (GLfloat) v2;
2930       /* XXX verify these strides are correct */
2931       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
2932       n[7].i = _mesa_evaluator_components(target);      /*vstride */
2933       n[8].i = uorder;
2934       n[9].i = vorder;
2935       save_pointer(&n[10], pnts);
2936    }
2937    if (ctx->ExecuteFlag) {
2938       CALL_Map2d(ctx->Exec, (target,
2939                              u1, u2, ustride, uorder,
2940                              v1, v2, vstride, vorder, points));
2941    }
2942 }
2943
2944
2945 void GLAPIENTRY
2946 save_Map2f(GLenum target,
2947            GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
2948            GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
2949            const GLfloat * points)
2950 {
2951    GET_CURRENT_CONTEXT(ctx);
2952    Node *n;
2953    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2954    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
2955    if (n) {
2956       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
2957                                               vstride, vorder, points);
2958       n[1].e = target;
2959       n[2].f = u1;
2960       n[3].f = u2;
2961       n[4].f = v1;
2962       n[5].f = v2;
2963       /* XXX verify these strides are correct */
2964       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
2965       n[7].i = _mesa_evaluator_components(target);      /*vstride */
2966       n[8].i = uorder;
2967       n[9].i = vorder;
2968       save_pointer(&n[10], pnts);
2969    }
2970    if (ctx->ExecuteFlag) {
2971       CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
2972                              v1, v2, vstride, vorder, points));
2973    }
2974 }
2975
2976
2977 void GLAPIENTRY
2978 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
2979 {
2980    GET_CURRENT_CONTEXT(ctx);
2981    Node *n;
2982    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2983    n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
2984    if (n) {
2985       n[1].i = un;
2986       n[2].f = u1;
2987       n[3].f = u2;
2988    }
2989    if (ctx->ExecuteFlag) {
2990       CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
2991    }
2992 }
2993
2994
2995 void GLAPIENTRY
2996 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
2997 {
2998    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
2999 }
3000
3001
3002 void GLAPIENTRY
3003 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
3004                GLint vn, GLfloat v1, GLfloat v2)
3005 {
3006    GET_CURRENT_CONTEXT(ctx);
3007    Node *n;
3008    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3009    n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
3010    if (n) {
3011       n[1].i = un;
3012       n[2].f = u1;
3013       n[3].f = u2;
3014       n[4].i = vn;
3015       n[5].f = v1;
3016       n[6].f = v2;
3017    }
3018    if (ctx->ExecuteFlag) {
3019       CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
3020    }
3021 }
3022
3023
3024
3025 void GLAPIENTRY
3026 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
3027                GLint vn, GLdouble v1, GLdouble v2)
3028 {
3029    save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
3030                   vn, (GLfloat) v1, (GLfloat) v2);
3031 }
3032
3033
3034 void GLAPIENTRY
3035 save_MatrixMode(GLenum mode)
3036 {
3037    GET_CURRENT_CONTEXT(ctx);
3038    Node *n;
3039    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3040    n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
3041    if (n) {
3042       n[1].e = mode;
3043    }
3044    if (ctx->ExecuteFlag) {
3045       CALL_MatrixMode(ctx->Exec, (mode));
3046    }
3047 }
3048
3049
3050 void GLAPIENTRY
3051 save_MultMatrixf(const GLfloat * m)
3052 {
3053    GET_CURRENT_CONTEXT(ctx);
3054    Node *n;
3055    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3056    n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
3057    if (n) {
3058       GLuint i;
3059       for (i = 0; i < 16; i++) {
3060          n[1 + i].f = m[i];
3061       }
3062    }
3063    if (ctx->ExecuteFlag) {
3064       CALL_MultMatrixf(ctx->Exec, (m));
3065    }
3066 }
3067
3068
3069 void GLAPIENTRY
3070 save_MultMatrixd(const GLdouble * m)
3071 {
3072    GLfloat f[16];
3073    GLint i;
3074    for (i = 0; i < 16; i++) {
3075       f[i] = (GLfloat) m[i];
3076    }
3077    save_MultMatrixf(f);
3078 }
3079
3080
3081 void GLAPIENTRY
3082 save_NewList(GLuint name, GLenum mode)
3083 {
3084    GET_CURRENT_CONTEXT(ctx);
3085    /* It's an error to call this function while building a display list */
3086    _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
3087    (void) name;
3088    (void) mode;
3089 }
3090
3091
3092
3093 void GLAPIENTRY
3094 save_Ortho(GLdouble left, GLdouble right,
3095            GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
3096 {
3097    GET_CURRENT_CONTEXT(ctx);
3098    Node *n;
3099    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3100    n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
3101    if (n) {
3102       n[1].f = (GLfloat) left;
3103       n[2].f = (GLfloat) right;
3104       n[3].f = (GLfloat) bottom;
3105       n[4].f = (GLfloat) top;
3106       n[5].f = (GLfloat) nearval;
3107       n[6].f = (GLfloat) farval;
3108    }
3109    if (ctx->ExecuteFlag) {
3110       CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
3111    }
3112 }
3113
3114
3115 void GLAPIENTRY
3116 save_PatchParameteri(GLenum pname, const GLint value)
3117 {
3118    GET_CURRENT_CONTEXT(ctx);
3119    Node *n;
3120    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3121    n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_I, 2);
3122    if (n) {
3123       n[1].e = pname;
3124       n[2].i = value;
3125    }
3126    if (ctx->ExecuteFlag) {
3127       CALL_PatchParameteri(ctx->Exec, (pname, value));
3128    }
3129 }
3130
3131
3132 void GLAPIENTRY
3133 save_PatchParameterfv(GLenum pname, const GLfloat *params)
3134 {
3135    GET_CURRENT_CONTEXT(ctx);
3136    Node *n;
3137    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3138
3139    if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3140       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_OUTER, 5);
3141    } else {
3142       assert(pname == GL_PATCH_DEFAULT_INNER_LEVEL);
3143       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_INNER, 3);
3144    }
3145    if (n) {
3146       n[1].e = pname;
3147       if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3148          n[2].f = params[0];
3149          n[3].f = params[1];
3150          n[4].f = params[2];
3151          n[5].f = params[3];
3152       } else {
3153          n[2].f = params[0];
3154          n[3].f = params[1];
3155       }
3156    }
3157    if (ctx->ExecuteFlag) {
3158       CALL_PatchParameterfv(ctx->Exec, (pname, params));
3159    }
3160 }
3161
3162
3163 void GLAPIENTRY
3164 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
3165 {
3166    GET_CURRENT_CONTEXT(ctx);
3167    Node *n;
3168    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3169    n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 2 + POINTER_DWORDS);
3170    if (n) {
3171       n[1].e = map;
3172       n[2].i = mapsize;
3173       save_pointer(&n[3], memdup(values, mapsize * sizeof(GLfloat)));
3174    }
3175    if (ctx->ExecuteFlag) {
3176       CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
3177    }
3178 }
3179
3180
3181 void GLAPIENTRY
3182 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
3183 {
3184    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3185    GLint i;
3186    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3187       for (i = 0; i < mapsize; i++) {
3188          fvalues[i] = (GLfloat) values[i];
3189       }
3190    }
3191    else {
3192       for (i = 0; i < mapsize; i++) {
3193          fvalues[i] = UINT_TO_FLOAT(values[i]);
3194       }
3195    }
3196    save_PixelMapfv(map, mapsize, fvalues);
3197 }
3198
3199
3200 void GLAPIENTRY
3201 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
3202 {
3203    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3204    GLint i;
3205    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3206       for (i = 0; i < mapsize; i++) {
3207          fvalues[i] = (GLfloat) values[i];
3208       }
3209    }
3210    else {
3211       for (i = 0; i < mapsize; i++) {
3212          fvalues[i] = USHORT_TO_FLOAT(values[i]);
3213       }
3214    }
3215    save_PixelMapfv(map, mapsize, fvalues);
3216 }
3217
3218
3219 void GLAPIENTRY
3220 save_PixelTransferf(GLenum pname, GLfloat param)
3221 {
3222    GET_CURRENT_CONTEXT(ctx);
3223    Node *n;
3224    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3225    n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
3226    if (n) {
3227       n[1].e = pname;
3228       n[2].f = param;
3229    }
3230    if (ctx->ExecuteFlag) {
3231       CALL_PixelTransferf(ctx->Exec, (pname, param));
3232    }
3233 }
3234
3235
3236 void GLAPIENTRY
3237 save_PixelTransferi(GLenum pname, GLint param)
3238 {
3239    save_PixelTransferf(pname, (GLfloat) param);
3240 }
3241
3242
3243 void GLAPIENTRY
3244 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
3245 {
3246    GET_CURRENT_CONTEXT(ctx);
3247    Node *n;
3248    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3249    n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
3250    if (n) {
3251       n[1].f = xfactor;
3252       n[2].f = yfactor;
3253    }
3254    if (ctx->ExecuteFlag) {
3255       CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
3256    }
3257 }
3258
3259
3260 void GLAPIENTRY
3261 save_PointParameterfv(GLenum pname, const GLfloat *params)
3262 {
3263    GET_CURRENT_CONTEXT(ctx);
3264    Node *n;
3265    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3266    n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
3267    if (n) {
3268       n[1].e = pname;
3269       n[2].f = params[0];
3270       n[3].f = params[1];
3271       n[4].f = params[2];
3272    }
3273    if (ctx->ExecuteFlag) {
3274       CALL_PointParameterfv(ctx->Exec, (pname, params));
3275    }
3276 }
3277
3278
3279 void GLAPIENTRY
3280 save_PointParameterf(GLenum pname, GLfloat param)
3281 {
3282    GLfloat parray[3];
3283    parray[0] = param;
3284    parray[1] = parray[2] = 0.0F;
3285    save_PointParameterfv(pname, parray);
3286 }
3287
3288 void GLAPIENTRY
3289 save_PointParameteri(GLenum pname, GLint param)
3290 {
3291    GLfloat parray[3];
3292    parray[0] = (GLfloat) param;
3293    parray[1] = parray[2] = 0.0F;
3294    save_PointParameterfv(pname, parray);
3295 }
3296
3297 void GLAPIENTRY
3298 save_PointParameteriv(GLenum pname, const GLint * param)
3299 {
3300    GLfloat parray[3];
3301    parray[0] = (GLfloat) param[0];
3302    parray[1] = parray[2] = 0.0F;
3303    save_PointParameterfv(pname, parray);
3304 }
3305
3306
3307 void GLAPIENTRY
3308 save_PointSize(GLfloat size)
3309 {
3310    GET_CURRENT_CONTEXT(ctx);
3311    Node *n;
3312    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3313    n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
3314    if (n) {
3315       n[1].f = size;
3316    }
3317    if (ctx->ExecuteFlag) {
3318       CALL_PointSize(ctx->Exec, (size));
3319    }
3320 }
3321
3322
3323 void GLAPIENTRY
3324 save_PolygonMode(GLenum face, GLenum mode)
3325 {
3326    GET_CURRENT_CONTEXT(ctx);
3327    Node *n;
3328    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3329    n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
3330    if (n) {
3331       n[1].e = face;
3332       n[2].e = mode;
3333    }
3334    if (ctx->ExecuteFlag) {
3335       CALL_PolygonMode(ctx->Exec, (face, mode));
3336    }
3337 }
3338
3339
3340 void GLAPIENTRY
3341 save_PolygonStipple(const GLubyte * pattern)
3342 {
3343    GET_CURRENT_CONTEXT(ctx);
3344    Node *n;
3345
3346    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3347
3348    n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, POINTER_DWORDS);
3349    if (n) {
3350       save_pointer(&n[1],
3351                    unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
3352                                 pattern, &ctx->Unpack));
3353    }
3354    if (ctx->ExecuteFlag) {
3355       CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
3356    }
3357 }
3358
3359
3360 void GLAPIENTRY
3361 save_PolygonOffset(GLfloat factor, GLfloat units)
3362 {
3363    GET_CURRENT_CONTEXT(ctx);
3364    Node *n;
3365    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3366    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
3367    if (n) {
3368       n[1].f = factor;
3369       n[2].f = units;
3370    }
3371    if (ctx->ExecuteFlag) {
3372       CALL_PolygonOffset(ctx->Exec, (factor, units));
3373    }
3374 }
3375
3376
3377 void GLAPIENTRY
3378 save_PolygonOffsetClampEXT(GLfloat factor, GLfloat units, GLfloat clamp)
3379 {
3380    GET_CURRENT_CONTEXT(ctx);
3381    Node *n;
3382    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3383    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET_CLAMP, 3);
3384    if (n) {
3385       n[1].f = factor;
3386       n[2].f = units;
3387       n[3].f = clamp;
3388    }
3389    if (ctx->ExecuteFlag) {
3390       CALL_PolygonOffsetClampEXT(ctx->Exec, (factor, units, clamp));
3391    }
3392 }
3393
3394 void GLAPIENTRY
3395 save_PopAttrib(void)
3396 {
3397    GET_CURRENT_CONTEXT(ctx);
3398    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3399    (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
3400    if (ctx->ExecuteFlag) {
3401       CALL_PopAttrib(ctx->Exec, ());
3402    }
3403 }
3404
3405
3406 void GLAPIENTRY
3407 save_PopMatrix(void)
3408 {
3409    GET_CURRENT_CONTEXT(ctx);
3410    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3411    (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
3412    if (ctx->ExecuteFlag) {
3413       CALL_PopMatrix(ctx->Exec, ());
3414    }
3415 }
3416
3417
3418 void GLAPIENTRY
3419 save_PopName(void)
3420 {
3421    GET_CURRENT_CONTEXT(ctx);
3422    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3423    (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
3424    if (ctx->ExecuteFlag) {
3425       CALL_PopName(ctx->Exec, ());
3426    }
3427 }
3428
3429
3430 void GLAPIENTRY
3431 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
3432                         const GLclampf * priorities)
3433 {
3434    GET_CURRENT_CONTEXT(ctx);
3435    GLint i;
3436    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3437
3438    for (i = 0; i < num; i++) {
3439       Node *n;
3440       n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
3441       if (n) {
3442          n[1].ui = textures[i];
3443          n[2].f = priorities[i];
3444       }
3445    }
3446    if (ctx->ExecuteFlag) {
3447       CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
3448    }
3449 }
3450
3451
3452 void GLAPIENTRY
3453 save_PushAttrib(GLbitfield mask)
3454 {
3455    GET_CURRENT_CONTEXT(ctx);
3456    Node *n;
3457    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3458    n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
3459    if (n) {
3460       n[1].bf = mask;
3461    }
3462    if (ctx->ExecuteFlag) {
3463       CALL_PushAttrib(ctx->Exec, (mask));
3464    }
3465 }
3466
3467
3468 void GLAPIENTRY
3469 save_PushMatrix(void)
3470 {
3471    GET_CURRENT_CONTEXT(ctx);
3472    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3473    (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
3474    if (ctx->ExecuteFlag) {
3475       CALL_PushMatrix(ctx->Exec, ());
3476    }
3477 }
3478
3479
3480 void GLAPIENTRY
3481 save_PushName(GLuint name)
3482 {
3483    GET_CURRENT_CONTEXT(ctx);
3484    Node *n;
3485    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3486    n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
3487    if (n) {
3488       n[1].ui = name;
3489    }
3490    if (ctx->ExecuteFlag) {
3491       CALL_PushName(ctx->Exec, (name));
3492    }
3493 }
3494
3495
3496 void GLAPIENTRY
3497 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3498 {
3499    GET_CURRENT_CONTEXT(ctx);
3500    Node *n;
3501    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3502    n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
3503    if (n) {
3504       n[1].f = x;
3505       n[2].f = y;
3506       n[3].f = z;
3507       n[4].f = w;
3508    }
3509    if (ctx->ExecuteFlag) {
3510       CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
3511    }
3512 }
3513
3514 void GLAPIENTRY
3515 save_RasterPos2d(GLdouble x, GLdouble y)
3516 {
3517    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3518 }
3519
3520 void GLAPIENTRY
3521 save_RasterPos2f(GLfloat x, GLfloat y)
3522 {
3523    save_RasterPos4f(x, y, 0.0F, 1.0F);
3524 }
3525
3526 void GLAPIENTRY
3527 save_RasterPos2i(GLint x, GLint y)
3528 {
3529    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3530 }
3531
3532 void GLAPIENTRY
3533 save_RasterPos2s(GLshort x, GLshort y)
3534 {
3535    save_RasterPos4f(x, y, 0.0F, 1.0F);
3536 }
3537
3538 void GLAPIENTRY
3539 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
3540 {
3541    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3542 }
3543
3544 void GLAPIENTRY
3545 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
3546 {
3547    save_RasterPos4f(x, y, z, 1.0F);
3548 }
3549
3550 void GLAPIENTRY
3551 save_RasterPos3i(GLint x, GLint y, GLint z)
3552 {
3553    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3554 }
3555
3556 void GLAPIENTRY
3557 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
3558 {
3559    save_RasterPos4f(x, y, z, 1.0F);
3560 }
3561
3562 void GLAPIENTRY
3563 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3564 {
3565    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3566 }
3567
3568 void GLAPIENTRY
3569 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
3570 {
3571    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3572 }
3573
3574 void GLAPIENTRY
3575 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
3576 {
3577    save_RasterPos4f(x, y, z, w);
3578 }
3579
3580 void GLAPIENTRY
3581 save_RasterPos2dv(const GLdouble * v)
3582 {
3583    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3584 }
3585
3586 void GLAPIENTRY
3587 save_RasterPos2fv(const GLfloat * v)
3588 {
3589    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3590 }
3591
3592 void GLAPIENTRY
3593 save_RasterPos2iv(const GLint * v)
3594 {
3595    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3596 }
3597
3598 void GLAPIENTRY
3599 save_RasterPos2sv(const GLshort * v)
3600 {
3601    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3602 }
3603
3604 void GLAPIENTRY
3605 save_RasterPos3dv(const GLdouble * v)
3606 {
3607    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3608 }
3609
3610 void GLAPIENTRY
3611 save_RasterPos3fv(const GLfloat * v)
3612 {
3613    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3614 }
3615
3616 void GLAPIENTRY
3617 save_RasterPos3iv(const GLint * v)
3618 {
3619    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3620 }
3621
3622 void GLAPIENTRY
3623 save_RasterPos3sv(const GLshort * v)
3624 {
3625    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3626 }
3627
3628 void GLAPIENTRY
3629 save_RasterPos4dv(const GLdouble * v)
3630 {
3631    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3632                     (GLfloat) v[2], (GLfloat) v[3]);
3633 }
3634
3635 void GLAPIENTRY
3636 save_RasterPos4fv(const GLfloat * v)
3637 {
3638    save_RasterPos4f(v[0], v[1], v[2], v[3]);
3639 }
3640
3641 void GLAPIENTRY
3642 save_RasterPos4iv(const GLint * v)
3643 {
3644    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3645                     (GLfloat) v[2], (GLfloat) v[3]);
3646 }
3647
3648 void GLAPIENTRY
3649 save_RasterPos4sv(const GLshort * v)
3650 {
3651    save_RasterPos4f(v[0], v[1], v[2], v[3]);
3652 }
3653
3654
3655 void GLAPIENTRY
3656 save_PassThrough(GLfloat token)
3657 {
3658    GET_CURRENT_CONTEXT(ctx);
3659    Node *n;
3660    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3661    n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
3662    if (n) {
3663       n[1].f = token;
3664    }
3665    if (ctx->ExecuteFlag) {
3666       CALL_PassThrough(ctx->Exec, (token));
3667    }
3668 }
3669
3670
3671 void GLAPIENTRY
3672 save_ReadBuffer(GLenum mode)
3673 {
3674    GET_CURRENT_CONTEXT(ctx);
3675    Node *n;
3676    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3677    n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
3678    if (n) {
3679       n[1].e = mode;
3680    }
3681    if (ctx->ExecuteFlag) {
3682       CALL_ReadBuffer(ctx->Exec, (mode));
3683    }
3684 }
3685
3686
3687 void GLAPIENTRY
3688 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
3689 {
3690    GET_CURRENT_CONTEXT(ctx);
3691    Node *n;
3692    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3693    n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
3694    if (n) {
3695       n[1].f = angle;
3696       n[2].f = x;
3697       n[3].f = y;
3698       n[4].f = z;
3699    }
3700    if (ctx->ExecuteFlag) {
3701       CALL_Rotatef(ctx->Exec, (angle, x, y, z));
3702    }
3703 }
3704
3705
3706 void GLAPIENTRY
3707 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
3708 {
3709    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
3710 }
3711
3712
3713 void GLAPIENTRY
3714 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
3715 {
3716    GET_CURRENT_CONTEXT(ctx);
3717    Node *n;
3718    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3719    n = alloc_instruction(ctx, OPCODE_SCALE, 3);
3720    if (n) {
3721       n[1].f = x;
3722       n[2].f = y;
3723       n[3].f = z;
3724    }
3725    if (ctx->ExecuteFlag) {
3726       CALL_Scalef(ctx->Exec, (x, y, z));
3727    }
3728 }
3729
3730
3731 void GLAPIENTRY
3732 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
3733 {
3734    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
3735 }
3736
3737
3738 void GLAPIENTRY
3739 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
3740 {
3741    GET_CURRENT_CONTEXT(ctx);
3742    Node *n;
3743    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3744    n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
3745    if (n) {
3746       n[1].i = x;
3747       n[2].i = y;
3748       n[3].i = width;
3749       n[4].i = height;
3750    }
3751    if (ctx->ExecuteFlag) {
3752       CALL_Scissor(ctx->Exec, (x, y, width, height));
3753    }
3754 }
3755
3756
3757 void GLAPIENTRY
3758 save_ShadeModel(GLenum mode)
3759 {
3760    GET_CURRENT_CONTEXT(ctx);
3761    Node *n;
3762    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
3763
3764    if (ctx->ExecuteFlag) {
3765       CALL_ShadeModel(ctx->Exec, (mode));
3766    }
3767
3768    /* Don't compile this call if it's a no-op.
3769     * By avoiding this state change we have a better chance of
3770     * coalescing subsequent drawing commands into one batch.
3771     */
3772    if (ctx->ListState.Current.ShadeModel == mode)
3773       return;
3774
3775    SAVE_FLUSH_VERTICES(ctx);
3776
3777    ctx->ListState.Current.ShadeModel = mode;
3778
3779    n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
3780    if (n) {
3781       n[1].e = mode;
3782    }
3783 }
3784
3785
3786 void GLAPIENTRY
3787 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
3788 {
3789    GET_CURRENT_CONTEXT(ctx);
3790    Node *n;
3791    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3792    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
3793    if (n) {
3794       n[1].e = func;
3795       n[2].i = ref;
3796       n[3].ui = mask;
3797    }
3798    if (ctx->ExecuteFlag) {
3799       CALL_StencilFunc(ctx->Exec, (func, ref, mask));
3800    }
3801 }
3802
3803
3804 void GLAPIENTRY
3805 save_StencilMask(GLuint mask)
3806 {
3807    GET_CURRENT_CONTEXT(ctx);
3808    Node *n;
3809    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3810    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
3811    if (n) {
3812       n[1].ui = mask;
3813    }
3814    if (ctx->ExecuteFlag) {
3815       CALL_StencilMask(ctx->Exec, (mask));
3816    }
3817 }
3818
3819
3820 void GLAPIENTRY
3821 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3822 {
3823    GET_CURRENT_CONTEXT(ctx);
3824    Node *n;
3825    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3826    n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
3827    if (n) {
3828       n[1].e = fail;
3829       n[2].e = zfail;
3830       n[3].e = zpass;
3831    }
3832    if (ctx->ExecuteFlag) {
3833       CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
3834    }
3835 }
3836
3837
3838 void GLAPIENTRY
3839 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3840 {
3841    GET_CURRENT_CONTEXT(ctx);
3842    Node *n;
3843    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3844    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3845    if (n) {
3846       n[1].e = face;
3847       n[2].e = func;
3848       n[3].i = ref;
3849       n[4].ui = mask;
3850    }
3851    if (ctx->ExecuteFlag) {
3852       CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
3853    }
3854 }
3855
3856
3857 void GLAPIENTRY
3858 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
3859                             GLuint mask)
3860 {
3861    GET_CURRENT_CONTEXT(ctx);
3862    Node *n;
3863    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3864    /* GL_FRONT */
3865    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3866    if (n) {
3867       n[1].e = GL_FRONT;
3868       n[2].e = frontfunc;
3869       n[3].i = ref;
3870       n[4].ui = mask;
3871    }
3872    /* GL_BACK */
3873    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
3874    if (n) {
3875       n[1].e = GL_BACK;
3876       n[2].e = backfunc;
3877       n[3].i = ref;
3878       n[4].ui = mask;
3879    }
3880    if (ctx->ExecuteFlag) {
3881       CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
3882       CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
3883    }
3884 }
3885
3886
3887 void GLAPIENTRY
3888 save_StencilMaskSeparate(GLenum face, GLuint mask)
3889 {
3890    GET_CURRENT_CONTEXT(ctx);
3891    Node *n;
3892    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3893    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
3894    if (n) {
3895       n[1].e = face;
3896       n[2].ui = mask;
3897    }
3898    if (ctx->ExecuteFlag) {
3899       CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
3900    }
3901 }
3902
3903
3904 void GLAPIENTRY
3905 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3906 {
3907    GET_CURRENT_CONTEXT(ctx);
3908    Node *n;
3909    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3910    n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
3911    if (n) {
3912       n[1].e = face;
3913       n[2].e = fail;
3914       n[3].e = zfail;
3915       n[4].e = zpass;
3916    }
3917    if (ctx->ExecuteFlag) {
3918       CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
3919    }
3920 }
3921
3922
3923 void GLAPIENTRY
3924 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
3925 {
3926    GET_CURRENT_CONTEXT(ctx);
3927    Node *n;
3928    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3929    n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
3930    if (n) {
3931       n[1].e = target;
3932       n[2].e = pname;
3933       if (pname == GL_TEXTURE_ENV_COLOR) {
3934          n[3].f = params[0];
3935          n[4].f = params[1];
3936          n[5].f = params[2];
3937          n[6].f = params[3];
3938       }
3939       else {
3940          n[3].f = params[0];
3941          n[4].f = n[5].f = n[6].f = 0.0F;
3942       }
3943    }
3944    if (ctx->ExecuteFlag) {
3945       CALL_TexEnvfv(ctx->Exec, (target, pname, params));
3946    }
3947 }
3948
3949
3950 void GLAPIENTRY
3951 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
3952 {
3953    GLfloat parray[4];
3954    parray[0] = (GLfloat) param;
3955    parray[1] = parray[2] = parray[3] = 0.0F;
3956    save_TexEnvfv(target, pname, parray);
3957 }
3958
3959
3960 void GLAPIENTRY
3961 save_TexEnvi(GLenum target, GLenum pname, GLint param)
3962 {
3963    GLfloat p[4];
3964    p[0] = (GLfloat) param;
3965    p[1] = p[2] = p[3] = 0.0F;
3966    save_TexEnvfv(target, pname, p);
3967 }
3968
3969
3970 void GLAPIENTRY
3971 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
3972 {
3973    GLfloat p[4];
3974    if (pname == GL_TEXTURE_ENV_COLOR) {
3975       p[0] = INT_TO_FLOAT(param[0]);
3976       p[1] = INT_TO_FLOAT(param[1]);
3977       p[2] = INT_TO_FLOAT(param[2]);
3978       p[3] = INT_TO_FLOAT(param[3]);
3979    }
3980    else {
3981       p[0] = (GLfloat) param[0];
3982       p[1] = p[2] = p[3] = 0.0F;
3983    }
3984    save_TexEnvfv(target, pname, p);
3985 }
3986
3987
3988 void GLAPIENTRY
3989 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
3990 {
3991    GET_CURRENT_CONTEXT(ctx);
3992    Node *n;
3993    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3994    n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
3995    if (n) {
3996       n[1].e = coord;
3997       n[2].e = pname;
3998       n[3].f = params[0];
3999       n[4].f = params[1];
4000       n[5].f = params[2];
4001       n[6].f = params[3];
4002    }
4003    if (ctx->ExecuteFlag) {
4004       CALL_TexGenfv(ctx->Exec, (coord, pname, params));
4005    }
4006 }
4007
4008
4009 void GLAPIENTRY
4010 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
4011 {
4012    GLfloat p[4];
4013    p[0] = (GLfloat) params[0];
4014    p[1] = (GLfloat) params[1];
4015    p[2] = (GLfloat) params[2];
4016    p[3] = (GLfloat) params[3];
4017    save_TexGenfv(coord, pname, p);
4018 }
4019
4020
4021 void GLAPIENTRY
4022 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
4023 {
4024    GLfloat parray[4];
4025    parray[0] = (GLfloat) param;
4026    parray[1] = parray[2] = parray[3] = 0.0F;
4027    save_TexGenfv(coord, pname, parray);
4028 }
4029
4030
4031 void GLAPIENTRY
4032 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
4033 {
4034    GLfloat p[4];
4035    p[0] = (GLfloat) params[0];
4036    p[1] = (GLfloat) params[1];
4037    p[2] = (GLfloat) params[2];
4038    p[3] = (GLfloat) params[3];
4039    save_TexGenfv(coord, pname, p);
4040 }
4041
4042
4043 void GLAPIENTRY
4044 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
4045 {
4046    GLfloat parray[4];
4047    parray[0] = param;
4048    parray[1] = parray[2] = parray[3] = 0.0F;
4049    save_TexGenfv(coord, pname, parray);
4050 }
4051
4052
4053 void GLAPIENTRY
4054 save_TexGeni(GLenum coord, GLenum pname, GLint param)
4055 {
4056    GLint parray[4];
4057    parray[0] = param;
4058    parray[1] = parray[2] = parray[3] = 0;
4059    save_TexGeniv(coord, pname, parray);
4060 }
4061
4062
4063 void GLAPIENTRY
4064 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
4065 {
4066    GET_CURRENT_CONTEXT(ctx);
4067    Node *n;
4068    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4069    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
4070    if (n) {
4071       n[1].e = target;
4072       n[2].e = pname;
4073       n[3].f = params[0];
4074       n[4].f = params[1];
4075       n[5].f = params[2];
4076       n[6].f = params[3];
4077    }
4078    if (ctx->ExecuteFlag) {
4079       CALL_TexParameterfv(ctx->Exec, (target, pname, params));
4080    }
4081 }
4082
4083
4084 void GLAPIENTRY
4085 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
4086 {
4087    GLfloat parray[4];
4088    parray[0] = param;
4089    parray[1] = parray[2] = parray[3] = 0.0F;
4090    save_TexParameterfv(target, pname, parray);
4091 }
4092
4093
4094 void GLAPIENTRY
4095 save_TexParameteri(GLenum target, GLenum pname, GLint param)
4096 {
4097    GLfloat fparam[4];
4098    fparam[0] = (GLfloat) param;
4099    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4100    save_TexParameterfv(target, pname, fparam);
4101 }
4102
4103
4104 void GLAPIENTRY
4105 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
4106 {
4107    GLfloat fparam[4];
4108    fparam[0] = (GLfloat) params[0];
4109    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4110    save_TexParameterfv(target, pname, fparam);
4111 }
4112
4113
4114 void GLAPIENTRY
4115 save_TexImage1D(GLenum target,
4116                 GLint level, GLint components,
4117                 GLsizei width, GLint border,
4118                 GLenum format, GLenum type, const GLvoid * pixels)
4119 {
4120    GET_CURRENT_CONTEXT(ctx);
4121    if (target == GL_PROXY_TEXTURE_1D) {
4122       /* don't compile, execute immediately */
4123       CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4124                                   border, format, type, pixels));
4125    }
4126    else {
4127       Node *n;
4128       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4129       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 7 + POINTER_DWORDS);
4130       if (n) {
4131          n[1].e = target;
4132          n[2].i = level;
4133          n[3].i = components;
4134          n[4].i = (GLint) width;
4135          n[5].i = border;
4136          n[6].e = format;
4137          n[7].e = type;
4138          save_pointer(&n[8],
4139                       unpack_image(ctx, 1, width, 1, 1, format, type,
4140                                    pixels, &ctx->Unpack));
4141       }
4142       if (ctx->ExecuteFlag) {
4143          CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4144                                      border, format, type, pixels));
4145       }
4146    }
4147 }
4148
4149
4150 void GLAPIENTRY
4151 save_TexImage2D(GLenum target,
4152                 GLint level, GLint components,
4153                 GLsizei width, GLsizei height, GLint border,
4154                 GLenum format, GLenum type, const GLvoid * pixels)
4155 {
4156    GET_CURRENT_CONTEXT(ctx);
4157    if (target == GL_PROXY_TEXTURE_2D) {
4158       /* don't compile, execute immediately */
4159       CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4160                                   height, border, format, type, pixels));
4161    }
4162    else {
4163       Node *n;
4164       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4165       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 8 + POINTER_DWORDS);
4166       if (n) {
4167          n[1].e = target;
4168          n[2].i = level;
4169          n[3].i = components;
4170          n[4].i = (GLint) width;
4171          n[5].i = (GLint) height;
4172          n[6].i = border;
4173          n[7].e = format;
4174          n[8].e = type;
4175          save_pointer(&n[9],
4176                       unpack_image(ctx, 2, width, height, 1, format, type,
4177                                    pixels, &ctx->Unpack));
4178       }
4179       if (ctx->ExecuteFlag) {
4180          CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4181                                      height, border, format, type, pixels));
4182       }
4183    }
4184 }
4185
4186
4187 void GLAPIENTRY
4188 save_TexImage3D(GLenum target,
4189                 GLint level, GLint internalFormat,
4190                 GLsizei width, GLsizei height, GLsizei depth,
4191                 GLint border,
4192                 GLenum format, GLenum type, const GLvoid * pixels)
4193 {
4194    GET_CURRENT_CONTEXT(ctx);
4195    if (target == GL_PROXY_TEXTURE_3D) {
4196       /* don't compile, execute immediately */
4197       CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4198                                   height, depth, border, format, type,
4199                                   pixels));
4200    }
4201    else {
4202       Node *n;
4203       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4204       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 9 + POINTER_DWORDS);
4205       if (n) {
4206          n[1].e = target;
4207          n[2].i = level;
4208          n[3].i = (GLint) internalFormat;
4209          n[4].i = (GLint) width;
4210          n[5].i = (GLint) height;
4211          n[6].i = (GLint) depth;
4212          n[7].i = border;
4213          n[8].e = format;
4214          n[9].e = type;
4215          save_pointer(&n[10],
4216                       unpack_image(ctx, 3, width, height, depth, format, type,
4217                                    pixels, &ctx->Unpack));
4218       }
4219       if (ctx->ExecuteFlag) {
4220          CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4221                                      height, depth, border, format, type,
4222                                      pixels));
4223       }
4224    }
4225 }
4226
4227
4228 void GLAPIENTRY
4229 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
4230                    GLsizei width, GLenum format, GLenum type,
4231                    const GLvoid * pixels)
4232 {
4233    GET_CURRENT_CONTEXT(ctx);
4234    Node *n;
4235
4236    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4237
4238    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 6 + POINTER_DWORDS);
4239    if (n) {
4240       n[1].e = target;
4241       n[2].i = level;
4242       n[3].i = xoffset;
4243       n[4].i = (GLint) width;
4244       n[5].e = format;
4245       n[6].e = type;
4246       save_pointer(&n[7],
4247                    unpack_image(ctx, 1, width, 1, 1, format, type,
4248                                 pixels, &ctx->Unpack));
4249    }
4250    if (ctx->ExecuteFlag) {
4251       CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
4252                                      format, type, pixels));
4253    }
4254 }
4255
4256
4257 void GLAPIENTRY
4258 save_TexSubImage2D(GLenum target, GLint level,
4259                    GLint xoffset, GLint yoffset,
4260                    GLsizei width, GLsizei height,
4261                    GLenum format, GLenum type, const GLvoid * pixels)
4262 {
4263    GET_CURRENT_CONTEXT(ctx);
4264    Node *n;
4265
4266    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4267
4268    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 8 + POINTER_DWORDS);
4269    if (n) {
4270       n[1].e = target;
4271       n[2].i = level;
4272       n[3].i = xoffset;
4273       n[4].i = yoffset;
4274       n[5].i = (GLint) width;
4275       n[6].i = (GLint) height;
4276       n[7].e = format;
4277       n[8].e = type;
4278       save_pointer(&n[9],
4279                    unpack_image(ctx, 2, width, height, 1, format, type,
4280                                 pixels, &ctx->Unpack));
4281    }
4282    if (ctx->ExecuteFlag) {
4283       CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
4284                                      width, height, format, type, pixels));
4285    }
4286 }
4287
4288
4289 void GLAPIENTRY
4290 save_TexSubImage3D(GLenum target, GLint level,
4291                    GLint xoffset, GLint yoffset, GLint zoffset,
4292                    GLsizei width, GLsizei height, GLsizei depth,
4293                    GLenum format, GLenum type, const GLvoid * pixels)
4294 {
4295    GET_CURRENT_CONTEXT(ctx);
4296    Node *n;
4297
4298    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4299
4300    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 10 + POINTER_DWORDS);
4301    if (n) {
4302       n[1].e = target;
4303       n[2].i = level;
4304       n[3].i = xoffset;
4305       n[4].i = yoffset;
4306       n[5].i = zoffset;
4307       n[6].i = (GLint) width;
4308       n[7].i = (GLint) height;
4309       n[8].i = (GLint) depth;
4310       n[9].e = format;
4311       n[10].e = type;
4312       save_pointer(&n[11],
4313                    unpack_image(ctx, 3, width, height, depth, format, type,
4314                                 pixels, &ctx->Unpack));
4315    }
4316    if (ctx->ExecuteFlag) {
4317       CALL_TexSubImage3D(ctx->Exec, (target, level,
4318                                      xoffset, yoffset, zoffset,
4319                                      width, height, depth, format, type,
4320                                      pixels));
4321    }
4322 }
4323
4324
4325 void GLAPIENTRY
4326 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
4327 {
4328    GET_CURRENT_CONTEXT(ctx);
4329    Node *n;
4330    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4331    n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
4332    if (n) {
4333       n[1].f = x;
4334       n[2].f = y;
4335       n[3].f = z;
4336    }
4337    if (ctx->ExecuteFlag) {
4338       CALL_Translatef(ctx->Exec, (x, y, z));
4339    }
4340 }
4341
4342
4343 void GLAPIENTRY
4344 save_Translated(GLdouble x, GLdouble y, GLdouble z)
4345 {
4346    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4347 }
4348
4349
4350
4351 void GLAPIENTRY
4352 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
4353 {
4354    GET_CURRENT_CONTEXT(ctx);
4355    Node *n;
4356    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4357    n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
4358    if (n) {
4359       n[1].i = x;
4360       n[2].i = y;
4361       n[3].i = (GLint) width;
4362       n[4].i = (GLint) height;
4363    }
4364    if (ctx->ExecuteFlag) {
4365       CALL_Viewport(ctx->Exec, (x, y, width, height));
4366    }
4367 }
4368
4369 void GLAPIENTRY
4370 save_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat width,
4371                       GLfloat height)
4372 {
4373    GET_CURRENT_CONTEXT(ctx);
4374    Node *n;
4375    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4376    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_F, 5);
4377    if (n) {
4378       n[1].ui = index;
4379       n[2].f = x;
4380       n[3].f = y;
4381       n[4].f = width;
4382       n[5].f = height;
4383    }
4384    if (ctx->ExecuteFlag) {
4385       CALL_ViewportIndexedf(ctx->Exec, (index, x, y, width, height));
4386    }
4387 }
4388
4389 void GLAPIENTRY
4390 save_ViewportIndexedfv(GLuint index, const GLfloat *v)
4391 {
4392    GET_CURRENT_CONTEXT(ctx);
4393    Node *n;
4394    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4395    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_FV, 5);
4396    if (n) {
4397       n[1].ui = index;
4398       n[2].f = v[0];
4399       n[3].f = v[1];
4400       n[4].f = v[2];
4401       n[5].f = v[3];
4402    }
4403    if (ctx->ExecuteFlag) {
4404       CALL_ViewportIndexedfv(ctx->Exec, (index, v));
4405    }
4406 }
4407
4408 void GLAPIENTRY
4409 save_ViewportArrayv(GLuint first, GLsizei count, const GLfloat *v)
4410 {
4411    GET_CURRENT_CONTEXT(ctx);
4412    Node *n;
4413    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4414    n = alloc_instruction(ctx, OPCODE_VIEWPORT_ARRAY_V, 2 + POINTER_DWORDS);
4415    if (n) {
4416       n[1].ui = first;
4417       n[2].si = count;
4418       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
4419    }
4420    if (ctx->ExecuteFlag) {
4421       CALL_ViewportArrayv(ctx->Exec, (first, count, v));
4422    }
4423 }
4424
4425 void GLAPIENTRY
4426 save_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width,
4427                     GLsizei height)
4428 {
4429    GET_CURRENT_CONTEXT(ctx);
4430    Node *n;
4431    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4432    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED, 5);
4433    if (n) {
4434       n[1].ui = index;
4435       n[2].i = left;
4436       n[3].i = bottom;
4437       n[4].si = width;
4438       n[5].si = height;
4439    }
4440    if (ctx->ExecuteFlag) {
4441       CALL_ScissorIndexed(ctx->Exec, (index, left, bottom, width, height));
4442    }
4443 }
4444
4445 void GLAPIENTRY
4446 save_ScissorIndexedv(GLuint index, const GLint *v)
4447 {
4448    GET_CURRENT_CONTEXT(ctx);
4449    Node *n;
4450    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4451    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED_V, 5);
4452    if (n) {
4453       n[1].ui = index;
4454       n[2].i = v[0];
4455       n[3].i = v[1];
4456       n[4].si = v[2];
4457       n[5].si = v[3];
4458    }
4459    if (ctx->ExecuteFlag) {
4460       CALL_ScissorIndexedv(ctx->Exec, (index, v));
4461    }
4462 }
4463
4464 void GLAPIENTRY
4465 save_ScissorArrayv(GLuint first, GLsizei count, const GLint *v)
4466 {
4467    GET_CURRENT_CONTEXT(ctx);
4468    Node *n;
4469    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4470    n = alloc_instruction(ctx, OPCODE_SCISSOR_ARRAY_V, 2 + POINTER_DWORDS);
4471    if (n) {
4472       n[1].ui = first;
4473       n[2].si = count;
4474       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint)));
4475    }
4476    if (ctx->ExecuteFlag) {
4477       CALL_ScissorArrayv(ctx->Exec, (first, count, v));
4478    }
4479 }
4480
4481 void GLAPIENTRY
4482 save_DepthRangeIndexed(GLuint index, GLclampd n, GLclampd f)
4483 {
4484    GET_CURRENT_CONTEXT(ctx);
4485    Node *node;
4486    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4487    node = alloc_instruction(ctx, OPCODE_DEPTH_INDEXED, 3);
4488    if (node) {
4489       node[1].ui = index;
4490       /* Mesa stores these as floats internally so we deliberately convert
4491        * them to a float here.
4492        */
4493       node[2].f = n;
4494       node[3].f = f;
4495    }
4496    if (ctx->ExecuteFlag) {
4497       CALL_DepthRangeIndexed(ctx->Exec, (index, n, f));
4498    }
4499 }
4500
4501 void GLAPIENTRY
4502 save_DepthRangeArrayv(GLuint first, GLsizei count, const GLclampd *v)
4503 {
4504    GET_CURRENT_CONTEXT(ctx);
4505    Node *n;
4506    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4507    n = alloc_instruction(ctx, OPCODE_DEPTH_ARRAY_V, 2 + POINTER_DWORDS);
4508    if (n) {
4509       n[1].ui = first;
4510       n[2].si = count;
4511       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLclampd)));
4512    }
4513    if (ctx->ExecuteFlag) {
4514       CALL_DepthRangeArrayv(ctx->Exec, (first, count, v));
4515    }
4516 }
4517
4518 void GLAPIENTRY
4519 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4520 {
4521    GET_CURRENT_CONTEXT(ctx);
4522    Node *n;
4523    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4524    n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
4525    if (n) {
4526       n[1].f = x;
4527       n[2].f = y;
4528       n[3].f = z;
4529       n[4].f = w;
4530    }
4531    if (ctx->ExecuteFlag) {
4532       CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
4533    }
4534 }
4535
4536 void GLAPIENTRY
4537 save_WindowPos2d(GLdouble x, GLdouble y)
4538 {
4539    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4540 }
4541
4542 void GLAPIENTRY
4543 save_WindowPos2f(GLfloat x, GLfloat y)
4544 {
4545    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4546 }
4547
4548 void GLAPIENTRY
4549 save_WindowPos2i(GLint x, GLint y)
4550 {
4551    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4552 }
4553
4554 void GLAPIENTRY
4555 save_WindowPos2s(GLshort x, GLshort y)
4556 {
4557    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4558 }
4559
4560 void GLAPIENTRY
4561 save_WindowPos3d(GLdouble x, GLdouble y, GLdouble z)
4562 {
4563    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4564 }
4565
4566 void GLAPIENTRY
4567 save_WindowPos3f(GLfloat x, GLfloat y, GLfloat z)
4568 {
4569    save_WindowPos4fMESA(x, y, z, 1.0F);
4570 }
4571
4572 void GLAPIENTRY
4573 save_WindowPos3i(GLint x, GLint y, GLint z)
4574 {
4575    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4576 }
4577
4578 void GLAPIENTRY
4579 save_WindowPos3s(GLshort x, GLshort y, GLshort z)
4580 {
4581    save_WindowPos4fMESA(x, y, z, 1.0F);
4582 }
4583
4584 void GLAPIENTRY
4585 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4586 {
4587    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4588 }
4589
4590 void GLAPIENTRY
4591 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
4592 {
4593    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4594 }
4595
4596 void GLAPIENTRY
4597 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
4598 {
4599    save_WindowPos4fMESA(x, y, z, w);
4600 }
4601
4602 void GLAPIENTRY
4603 save_WindowPos2dv(const GLdouble * v)
4604 {
4605    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4606 }
4607
4608 void GLAPIENTRY
4609 save_WindowPos2fv(const GLfloat * v)
4610 {
4611    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4612 }
4613
4614 void GLAPIENTRY
4615 save_WindowPos2iv(const GLint * v)
4616 {
4617    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4618 }
4619
4620 void GLAPIENTRY
4621 save_WindowPos2sv(const GLshort * v)
4622 {
4623    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4624 }
4625
4626 void GLAPIENTRY
4627 save_WindowPos3dv(const GLdouble * v)
4628 {
4629    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4630 }
4631
4632 void GLAPIENTRY
4633 save_WindowPos3fv(const GLfloat * v)
4634 {
4635    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4636 }
4637
4638 void GLAPIENTRY
4639 save_WindowPos3iv(const GLint * v)
4640 {
4641    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4642 }
4643
4644 void GLAPIENTRY
4645 save_WindowPos3sv(const GLshort * v)
4646 {
4647    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
4648 }
4649
4650 void GLAPIENTRY
4651 save_WindowPos4dvMESA(const GLdouble * v)
4652 {
4653    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4654                         (GLfloat) v[2], (GLfloat) v[3]);
4655 }
4656
4657 void GLAPIENTRY
4658 save_WindowPos4fvMESA(const GLfloat * v)
4659 {
4660    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4661 }
4662
4663 void GLAPIENTRY
4664 save_WindowPos4ivMESA(const GLint * v)
4665 {
4666    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
4667                         (GLfloat) v[2], (GLfloat) v[3]);
4668 }
4669
4670 void GLAPIENTRY
4671 save_WindowPos4svMESA(const GLshort * v)
4672 {
4673    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
4674 }
4675
4676
4677
4678 /* GL_ARB_multitexture */
4679 void GLAPIENTRY
4680 save_ActiveTexture(GLenum target)
4681 {
4682    GET_CURRENT_CONTEXT(ctx);
4683    Node *n;
4684    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4685    n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
4686    if (n) {
4687       n[1].e = target;
4688    }
4689    if (ctx->ExecuteFlag) {
4690       CALL_ActiveTexture(ctx->Exec, (target));
4691    }
4692 }
4693
4694
4695 /* GL_ARB_transpose_matrix */
4696
4697 void GLAPIENTRY
4698 save_LoadTransposeMatrixd(const GLdouble *m)
4699 {
4700    GLfloat tm[16];
4701    _math_transposefd(tm, m);
4702    save_LoadMatrixf(tm);
4703 }
4704
4705
4706 void GLAPIENTRY
4707 save_LoadTransposeMatrixf(const GLfloat *m)
4708 {
4709    GLfloat tm[16];
4710    _math_transposef(tm, m);
4711    save_LoadMatrixf(tm);
4712 }
4713
4714
4715 void GLAPIENTRY
4716 save_MultTransposeMatrixd(const GLdouble *m)
4717 {
4718    GLfloat tm[16];
4719    _math_transposefd(tm, m);
4720    save_MultMatrixf(tm);
4721 }
4722
4723
4724 void GLAPIENTRY
4725 save_MultTransposeMatrixf(const GLfloat *m)
4726 {
4727    GLfloat tm[16];
4728    _math_transposef(tm, m);
4729    save_MultMatrixf(tm);
4730 }
4731
4732 static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func)
4733 {
4734    GET_CURRENT_CONTEXT(ctx);
4735    GLvoid *image;
4736
4737    if (!data)
4738       return NULL;
4739
4740    image = malloc(size);
4741    if (!image) {
4742       _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
4743       return NULL;
4744    }
4745    memcpy(image, data, size);
4746
4747    return image;
4748 }
4749
4750
4751 /* GL_ARB_texture_compression */
4752 void GLAPIENTRY
4753 save_CompressedTexImage1D(GLenum target, GLint level,
4754                              GLenum internalFormat, GLsizei width,
4755                              GLint border, GLsizei imageSize,
4756                              const GLvoid * data)
4757 {
4758    GET_CURRENT_CONTEXT(ctx);
4759    if (target == GL_PROXY_TEXTURE_1D) {
4760       /* don't compile, execute immediately */
4761       CALL_CompressedTexImage1D(ctx->Exec, (target, level, internalFormat,
4762                                                width, border, imageSize,
4763                                                data));
4764    }
4765    else {
4766       Node *n;
4767       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4768
4769       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D,
4770                             6 + POINTER_DWORDS);
4771       if (n) {
4772          n[1].e = target;
4773          n[2].i = level;
4774          n[3].e = internalFormat;
4775          n[4].i = (GLint) width;
4776          n[5].i = border;
4777          n[6].i = imageSize;
4778          save_pointer(&n[7],
4779                       copy_data(data, imageSize, "glCompressedTexImage1DARB"));
4780       }
4781       if (ctx->ExecuteFlag) {
4782          CALL_CompressedTexImage1D(ctx->Exec,
4783                                       (target, level, internalFormat, width,
4784                                        border, imageSize, data));
4785       }
4786    }
4787 }
4788
4789
4790 void GLAPIENTRY
4791 save_CompressedTexImage2D(GLenum target, GLint level,
4792                              GLenum internalFormat, GLsizei width,
4793                              GLsizei height, GLint border, GLsizei imageSize,
4794                              const GLvoid * data)
4795 {
4796    GET_CURRENT_CONTEXT(ctx);
4797    if (target == GL_PROXY_TEXTURE_2D) {
4798       /* don't compile, execute immediately */
4799       CALL_CompressedTexImage2D(ctx->Exec, (target, level, internalFormat,
4800                                                width, height, border,
4801                                                imageSize, data));
4802    }
4803    else {
4804       Node *n;
4805       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4806
4807       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D,
4808                             7 + POINTER_DWORDS);
4809       if (n) {
4810          n[1].e = target;
4811          n[2].i = level;
4812          n[3].e = internalFormat;
4813          n[4].i = (GLint) width;
4814          n[5].i = (GLint) height;
4815          n[6].i = border;
4816          n[7].i = imageSize;
4817          save_pointer(&n[8],
4818                       copy_data(data, imageSize, "glCompressedTexImage2DARB"));
4819       }
4820       if (ctx->ExecuteFlag) {
4821          CALL_CompressedTexImage2D(ctx->Exec,
4822                                       (target, level, internalFormat, width,
4823                                        height, border, imageSize, data));
4824       }
4825    }
4826 }
4827
4828
4829 void GLAPIENTRY
4830 save_CompressedTexImage3D(GLenum target, GLint level,
4831                              GLenum internalFormat, GLsizei width,
4832                              GLsizei height, GLsizei depth, GLint border,
4833                              GLsizei imageSize, const GLvoid * data)
4834 {
4835    GET_CURRENT_CONTEXT(ctx);
4836    if (target == GL_PROXY_TEXTURE_3D) {
4837       /* don't compile, execute immediately */
4838       CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat,
4839                                                width, height, depth, border,
4840                                                imageSize, data));
4841    }
4842    else {
4843       Node *n;
4844       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4845
4846       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D,
4847                             8 + POINTER_DWORDS);
4848       if (n) {
4849          n[1].e = target;
4850          n[2].i = level;
4851          n[3].e = internalFormat;
4852          n[4].i = (GLint) width;
4853          n[5].i = (GLint) height;
4854          n[6].i = (GLint) depth;
4855          n[7].i = border;
4856          n[8].i = imageSize;
4857          save_pointer(&n[9],
4858                       copy_data(data, imageSize, "glCompressedTexImage3DARB"));
4859       }
4860       if (ctx->ExecuteFlag) {
4861          CALL_CompressedTexImage3D(ctx->Exec,
4862                                       (target, level, internalFormat, width,
4863                                        height, depth, border, imageSize,
4864                                        data));
4865       }
4866    }
4867 }
4868
4869
4870 void GLAPIENTRY
4871 save_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
4872                                 GLsizei width, GLenum format,
4873                                 GLsizei imageSize, const GLvoid * data)
4874 {
4875    Node *n;
4876    GET_CURRENT_CONTEXT(ctx);
4877    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4878
4879    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
4880                          6 + POINTER_DWORDS);
4881    if (n) {
4882       n[1].e = target;
4883       n[2].i = level;
4884       n[3].i = xoffset;
4885       n[4].i = (GLint) width;
4886       n[5].e = format;
4887       n[6].i = imageSize;
4888       save_pointer(&n[7],
4889                    copy_data(data, imageSize, "glCompressedTexSubImage1DARB"));
4890    }
4891    if (ctx->ExecuteFlag) {
4892       CALL_CompressedTexSubImage1D(ctx->Exec, (target, level, xoffset,
4893                                                   width, format, imageSize,
4894                                                   data));
4895    }
4896 }
4897
4898
4899 void GLAPIENTRY
4900 save_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
4901                                 GLint yoffset, GLsizei width, GLsizei height,
4902                                 GLenum format, GLsizei imageSize,
4903                                 const GLvoid * data)
4904 {
4905    Node *n;
4906    GET_CURRENT_CONTEXT(ctx);
4907    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4908
4909    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
4910                          8 + POINTER_DWORDS);
4911    if (n) {
4912       n[1].e = target;
4913       n[2].i = level;
4914       n[3].i = xoffset;
4915       n[4].i = yoffset;
4916       n[5].i = (GLint) width;
4917       n[6].i = (GLint) height;
4918       n[7].e = format;
4919       n[8].i = imageSize;
4920       save_pointer(&n[9],
4921                    copy_data(data, imageSize, "glCompressedTexSubImage2DARB"));
4922    }
4923    if (ctx->ExecuteFlag) {
4924       CALL_CompressedTexSubImage2D(ctx->Exec,
4925                                       (target, level, xoffset, yoffset, width,
4926                                        height, format, imageSize, data));
4927    }
4928 }
4929
4930
4931 void GLAPIENTRY
4932 save_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
4933                                 GLint yoffset, GLint zoffset, GLsizei width,
4934                                 GLsizei height, GLsizei depth, GLenum format,
4935                                 GLsizei imageSize, const GLvoid * data)
4936 {
4937    Node *n;
4938    GET_CURRENT_CONTEXT(ctx);
4939    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4940
4941    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
4942                          10 + POINTER_DWORDS);
4943    if (n) {
4944       n[1].e = target;
4945       n[2].i = level;
4946       n[3].i = xoffset;
4947       n[4].i = yoffset;
4948       n[5].i = zoffset;
4949       n[6].i = (GLint) width;
4950       n[7].i = (GLint) height;
4951       n[8].i = (GLint) depth;
4952       n[9].e = format;
4953       n[10].i = imageSize;
4954       save_pointer(&n[11],
4955                    copy_data(data, imageSize, "glCompressedTexSubImage3DARB"));
4956    }
4957    if (ctx->ExecuteFlag) {
4958       CALL_CompressedTexSubImage3D(ctx->Exec,
4959                                       (target, level, xoffset, yoffset,
4960                                        zoffset, width, height, depth, format,
4961                                        imageSize, data));
4962    }
4963 }
4964
4965
4966 /* GL_ARB_multisample */
4967 void GLAPIENTRY
4968 save_SampleCoverage(GLclampf value, GLboolean invert)
4969 {
4970    GET_CURRENT_CONTEXT(ctx);
4971    Node *n;
4972    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4973    n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
4974    if (n) {
4975       n[1].f = value;
4976       n[2].b = invert;
4977    }
4978    if (ctx->ExecuteFlag) {
4979       CALL_SampleCoverage(ctx->Exec, (value, invert));
4980    }
4981 }
4982
4983
4984 /*
4985  * GL_ARB_vertex_program
4986  */
4987 void GLAPIENTRY
4988 save_BindProgramARB(GLenum target, GLuint id)
4989 {
4990    GET_CURRENT_CONTEXT(ctx);
4991    Node *n;
4992    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4993    n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_ARB, 2);
4994    if (n) {
4995       n[1].e = target;
4996       n[2].ui = id;
4997    }
4998    if (ctx->ExecuteFlag) {
4999       CALL_BindProgramARB(ctx->Exec, (target, id));
5000    }
5001 }
5002
5003 void GLAPIENTRY
5004 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
5005                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5006 {
5007    GET_CURRENT_CONTEXT(ctx);
5008    Node *n;
5009    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5010    n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5011    if (n) {
5012       n[1].e = target;
5013       n[2].ui = index;
5014       n[3].f = x;
5015       n[4].f = y;
5016       n[5].f = z;
5017       n[6].f = w;
5018    }
5019    if (ctx->ExecuteFlag) {
5020       CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5021    }
5022 }
5023
5024
5025 void GLAPIENTRY
5026 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
5027                                const GLfloat *params)
5028 {
5029    save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
5030                                  params[2], params[3]);
5031 }
5032
5033
5034 void GLAPIENTRY
5035 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5036                                 const GLfloat * params)
5037 {
5038    GET_CURRENT_CONTEXT(ctx);
5039    Node *n;
5040    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5041
5042    if (count > 0) {
5043       GLint i;
5044       const GLfloat * p = params;
5045
5046       for (i = 0 ; i < count ; i++) {
5047          n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5048          if (n) {
5049             n[1].e = target;
5050             n[2].ui = index;
5051             n[3].f = p[0];
5052             n[4].f = p[1];
5053             n[5].f = p[2];
5054             n[6].f = p[3];
5055             p += 4;
5056          }
5057       }
5058    }
5059
5060    if (ctx->ExecuteFlag) {
5061       CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
5062    }
5063 }
5064
5065
5066 void GLAPIENTRY
5067 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
5068                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5069 {
5070    save_ProgramEnvParameter4fARB(target, index,
5071                                  (GLfloat) x,
5072                                  (GLfloat) y, (GLfloat) z, (GLfloat) w);
5073 }
5074
5075
5076 void GLAPIENTRY
5077 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
5078                                const GLdouble *params)
5079 {
5080    save_ProgramEnvParameter4fARB(target, index,
5081                                  (GLfloat) params[0],
5082                                  (GLfloat) params[1],
5083                                  (GLfloat) params[2], (GLfloat) params[3]);
5084 }
5085
5086
5087 void GLAPIENTRY
5088 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
5089                                 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5090 {
5091    GET_CURRENT_CONTEXT(ctx);
5092    Node *n;
5093    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5094    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5095    if (n) {
5096       n[1].e = target;
5097       n[2].ui = index;
5098       n[3].f = x;
5099       n[4].f = y;
5100       n[5].f = z;
5101       n[6].f = w;
5102    }
5103    if (ctx->ExecuteFlag) {
5104       CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5105    }
5106 }
5107
5108
5109 void GLAPIENTRY
5110 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
5111                                  const GLfloat *params)
5112 {
5113    GET_CURRENT_CONTEXT(ctx);
5114    Node *n;
5115    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5116    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5117    if (n) {
5118       n[1].e = target;
5119       n[2].ui = index;
5120       n[3].f = params[0];
5121       n[4].f = params[1];
5122       n[5].f = params[2];
5123       n[6].f = params[3];
5124    }
5125    if (ctx->ExecuteFlag) {
5126       CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
5127    }
5128 }
5129
5130
5131 void GLAPIENTRY
5132 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5133                                   const GLfloat *params)
5134 {
5135    GET_CURRENT_CONTEXT(ctx);
5136    Node *n;
5137    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5138
5139    if (count > 0) {
5140       GLint i;
5141       const GLfloat * p = params;
5142
5143       for (i = 0 ; i < count ; i++) {
5144          n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5145          if (n) {
5146             n[1].e = target;
5147             n[2].ui = index;
5148             n[3].f = p[0];
5149             n[4].f = p[1];
5150             n[5].f = p[2];
5151             n[6].f = p[3];
5152             p += 4;
5153          }
5154       }
5155    }
5156
5157    if (ctx->ExecuteFlag) {
5158       CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
5159    }
5160 }
5161
5162
5163 void GLAPIENTRY
5164 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
5165                                 GLdouble x, GLdouble y,
5166                                 GLdouble z, GLdouble w)
5167 {
5168    GET_CURRENT_CONTEXT(ctx);
5169    Node *n;
5170    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5171    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5172    if (n) {
5173       n[1].e = target;
5174       n[2].ui = index;
5175       n[3].f = (GLfloat) x;
5176       n[4].f = (GLfloat) y;
5177       n[5].f = (GLfloat) z;
5178       n[6].f = (GLfloat) w;
5179    }
5180    if (ctx->ExecuteFlag) {
5181       CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
5182    }
5183 }
5184
5185
5186 void GLAPIENTRY
5187 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
5188                                  const GLdouble *params)
5189 {
5190    GET_CURRENT_CONTEXT(ctx);
5191    Node *n;
5192    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5193    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5194    if (n) {
5195       n[1].e = target;
5196       n[2].ui = index;
5197       n[3].f = (GLfloat) params[0];
5198       n[4].f = (GLfloat) params[1];
5199       n[5].f = (GLfloat) params[2];
5200       n[6].f = (GLfloat) params[3];
5201    }
5202    if (ctx->ExecuteFlag) {
5203       CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
5204    }
5205 }
5206
5207
5208 /* GL_EXT_stencil_two_side */
5209 void GLAPIENTRY
5210 save_ActiveStencilFaceEXT(GLenum face)
5211 {
5212    GET_CURRENT_CONTEXT(ctx);
5213    Node *n;
5214    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5215    n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
5216    if (n) {
5217       n[1].e = face;
5218    }
5219    if (ctx->ExecuteFlag) {
5220       CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
5221    }
5222 }
5223
5224
5225 /* GL_EXT_depth_bounds_test */
5226 void GLAPIENTRY
5227 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
5228 {
5229    GET_CURRENT_CONTEXT(ctx);
5230    Node *n;
5231    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5232    n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
5233    if (n) {
5234       n[1].f = (GLfloat) zmin;
5235       n[2].f = (GLfloat) zmax;
5236    }
5237    if (ctx->ExecuteFlag) {
5238       CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
5239    }
5240 }
5241
5242
5243
5244 void GLAPIENTRY
5245 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
5246                       const GLvoid * string)
5247 {
5248    GET_CURRENT_CONTEXT(ctx);
5249    Node *n;
5250
5251    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5252
5253    n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 3 + POINTER_DWORDS);
5254    if (n) {
5255       GLubyte *programCopy = malloc(len);
5256       if (!programCopy) {
5257          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5258          return;
5259       }
5260       memcpy(programCopy, string, len);
5261       n[1].e = target;
5262       n[2].e = format;
5263       n[3].i = len;
5264       save_pointer(&n[4], programCopy);
5265    }
5266    if (ctx->ExecuteFlag) {
5267       CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
5268    }
5269 }
5270
5271
5272 void GLAPIENTRY
5273 save_BeginQuery(GLenum target, GLuint id)
5274 {
5275    GET_CURRENT_CONTEXT(ctx);
5276    Node *n;
5277    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5278    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
5279    if (n) {
5280       n[1].e = target;
5281       n[2].ui = id;
5282    }
5283    if (ctx->ExecuteFlag) {
5284       CALL_BeginQuery(ctx->Exec, (target, id));
5285    }
5286 }
5287
5288 void GLAPIENTRY
5289 save_EndQuery(GLenum target)
5290 {
5291    GET_CURRENT_CONTEXT(ctx);
5292    Node *n;
5293    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5294    n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
5295    if (n) {
5296       n[1].e = target;
5297    }
5298    if (ctx->ExecuteFlag) {
5299       CALL_EndQuery(ctx->Exec, (target));
5300    }
5301 }
5302
5303 void GLAPIENTRY
5304 save_QueryCounter(GLuint id, GLenum target)
5305 {
5306    GET_CURRENT_CONTEXT(ctx);
5307    Node *n;
5308    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5309    n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2);
5310    if (n) {
5311       n[1].ui = id;
5312       n[2].e = target;
5313    }
5314    if (ctx->ExecuteFlag) {
5315       CALL_QueryCounter(ctx->Exec, (id, target));
5316    }
5317 }
5318
5319 void GLAPIENTRY
5320 save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
5321 {
5322    GET_CURRENT_CONTEXT(ctx);
5323    Node *n;
5324    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5325    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3);
5326    if (n) {
5327       n[1].e = target;
5328       n[2].ui = index;
5329       n[3].ui = id;
5330    }
5331    if (ctx->ExecuteFlag) {
5332       CALL_BeginQueryIndexed(ctx->Exec, (target, index, id));
5333    }
5334 }
5335
5336 void GLAPIENTRY
5337 save_EndQueryIndexed(GLenum target, GLuint index)
5338 {
5339    GET_CURRENT_CONTEXT(ctx);
5340    Node *n;
5341    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5342    n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2);
5343    if (n) {
5344       n[1].e = target;
5345       n[2].ui = index;
5346    }
5347    if (ctx->ExecuteFlag) {
5348       CALL_EndQueryIndexed(ctx->Exec, (target, index));
5349    }
5350 }
5351
5352
5353 void GLAPIENTRY
5354 save_DrawBuffers(GLsizei count, const GLenum * buffers)
5355 {
5356    GET_CURRENT_CONTEXT(ctx);
5357    Node *n;
5358    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5359    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
5360    if (n) {
5361       GLint i;
5362       n[1].i = count;
5363       if (count > MAX_DRAW_BUFFERS)
5364          count = MAX_DRAW_BUFFERS;
5365       for (i = 0; i < count; i++) {
5366          n[2 + i].e = buffers[i];
5367       }
5368    }
5369    if (ctx->ExecuteFlag) {
5370       CALL_DrawBuffers(ctx->Exec, (count, buffers));
5371    }
5372 }
5373
5374 void GLAPIENTRY
5375 save_BindFragmentShaderATI(GLuint id)
5376 {
5377    GET_CURRENT_CONTEXT(ctx);
5378    Node *n;
5379
5380    n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
5381    if (n) {
5382       n[1].ui = id;
5383    }
5384    if (ctx->ExecuteFlag) {
5385       CALL_BindFragmentShaderATI(ctx->Exec, (id));
5386    }
5387 }
5388
5389 void GLAPIENTRY
5390 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
5391 {
5392    GET_CURRENT_CONTEXT(ctx);
5393    Node *n;
5394
5395    n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
5396    if (n) {
5397       n[1].ui = dst;
5398       n[2].f = value[0];
5399       n[3].f = value[1];
5400       n[4].f = value[2];
5401       n[5].f = value[3];
5402    }
5403    if (ctx->ExecuteFlag) {
5404       CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
5405    }
5406 }
5407
5408 static void GLAPIENTRY
5409 save_EvalCoord1f(GLfloat x)
5410 {
5411    GET_CURRENT_CONTEXT(ctx);
5412    Node *n;
5413    SAVE_FLUSH_VERTICES(ctx);
5414    n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
5415    if (n) {
5416       n[1].f = x;
5417    }
5418    if (ctx->ExecuteFlag) {
5419       CALL_EvalCoord1f(ctx->Exec, (x));
5420    }
5421 }
5422
5423 static void GLAPIENTRY
5424 save_EvalCoord1fv(const GLfloat * v)
5425 {
5426    save_EvalCoord1f(v[0]);
5427 }
5428
5429 static void GLAPIENTRY
5430 save_EvalCoord2f(GLfloat x, GLfloat y)
5431 {
5432    GET_CURRENT_CONTEXT(ctx);
5433    Node *n;
5434    SAVE_FLUSH_VERTICES(ctx);
5435    n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
5436    if (n) {
5437       n[1].f = x;
5438       n[2].f = y;
5439    }
5440    if (ctx->ExecuteFlag) {
5441       CALL_EvalCoord2f(ctx->Exec, (x, y));
5442    }
5443 }
5444
5445 static void GLAPIENTRY
5446 save_EvalCoord2fv(const GLfloat * v)
5447 {
5448    save_EvalCoord2f(v[0], v[1]);
5449 }
5450
5451
5452 static void GLAPIENTRY
5453 save_EvalPoint1(GLint x)
5454 {
5455    GET_CURRENT_CONTEXT(ctx);
5456    Node *n;
5457    SAVE_FLUSH_VERTICES(ctx);
5458    n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
5459    if (n) {
5460       n[1].i = x;
5461    }
5462    if (ctx->ExecuteFlag) {
5463       CALL_EvalPoint1(ctx->Exec, (x));
5464    }
5465 }
5466
5467 static void GLAPIENTRY
5468 save_EvalPoint2(GLint x, GLint y)
5469 {
5470    GET_CURRENT_CONTEXT(ctx);
5471    Node *n;
5472    SAVE_FLUSH_VERTICES(ctx);
5473    n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
5474    if (n) {
5475       n[1].i = x;
5476       n[2].i = y;
5477    }
5478    if (ctx->ExecuteFlag) {
5479       CALL_EvalPoint2(ctx->Exec, (x, y));
5480    }
5481 }
5482
5483
5484 /**
5485  * Compare 'count' elements of vectors 'a' and 'b'.
5486  * \return GL_TRUE if equal, GL_FALSE if different.
5487  */
5488 static inline GLboolean
5489 compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
5490 {
5491    return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5492 }
5493
5494
5495 /**
5496  * This glMaterial function is used for glMaterial calls that are outside
5497  * a glBegin/End pair.  For glMaterial inside glBegin/End, see the VBO code.
5498  */
5499 static void GLAPIENTRY
5500 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5501 {
5502    GET_CURRENT_CONTEXT(ctx);
5503    Node *n;
5504    int args, i;
5505    GLuint bitmask;
5506
5507    switch (face) {
5508    case GL_BACK:
5509    case GL_FRONT:
5510    case GL_FRONT_AND_BACK:
5511       break;
5512    default:
5513       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
5514       return;
5515    }
5516
5517    switch (pname) {
5518    case GL_EMISSION:
5519    case GL_AMBIENT:
5520    case GL_DIFFUSE:
5521    case GL_SPECULAR:
5522    case GL_AMBIENT_AND_DIFFUSE:
5523       args = 4;
5524       break;
5525    case GL_SHININESS:
5526       args = 1;
5527       break;
5528    case GL_COLOR_INDEXES:
5529       args = 3;
5530       break;
5531    default:
5532       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
5533       return;
5534    }
5535
5536    if (ctx->ExecuteFlag) {
5537       CALL_Materialfv(ctx->Exec, (face, pname, param));
5538    }
5539
5540    bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5541
5542    /* Try to eliminate redundant statechanges.  Because it is legal to
5543     * call glMaterial even inside begin/end calls, don't need to worry
5544     * about ctx->Driver.CurrentSavePrimitive here.
5545     */
5546    for (i = 0; i < MAT_ATTRIB_MAX; i++) {
5547       if (bitmask & (1 << i)) {
5548          if (ctx->ListState.ActiveMaterialSize[i] == args &&
5549              compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
5550             /* no change in material value */
5551             bitmask &= ~(1 << i);
5552          }
5553          else {
5554             ctx->ListState.ActiveMaterialSize[i] = args;
5555             COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5556          }
5557       }
5558    }
5559
5560    /* If this call has no effect, return early */
5561    if (bitmask == 0)
5562       return;
5563
5564    SAVE_FLUSH_VERTICES(ctx);
5565
5566    n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
5567    if (n) {
5568       n[1].e = face;
5569       n[2].e = pname;
5570       for (i = 0; i < args; i++)
5571          n[3 + i].f = param[i];
5572    }
5573 }
5574
5575 static void GLAPIENTRY
5576 save_Begin(GLenum mode)
5577 {
5578    GET_CURRENT_CONTEXT(ctx);
5579
5580    if (!_mesa_is_valid_prim_mode(ctx, mode)) {
5581       /* compile this error into the display list */
5582       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)");
5583    }
5584    else if (_mesa_inside_dlist_begin_end(ctx)) {
5585       /* compile this error into the display list */
5586       _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive glBegin");
5587    }
5588    else {
5589       ctx->Driver.CurrentSavePrimitive = mode;
5590
5591       vbo_save_NotifyBegin(ctx, mode, false);
5592    }
5593 }
5594
5595 static void GLAPIENTRY
5596 save_End(void)
5597 {
5598    GET_CURRENT_CONTEXT(ctx);
5599    SAVE_FLUSH_VERTICES(ctx);
5600    (void) alloc_instruction(ctx, OPCODE_END, 0);
5601    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
5602    if (ctx->ExecuteFlag) {
5603       CALL_End(ctx->Exec, ());
5604    }
5605 }
5606
5607 static void GLAPIENTRY
5608 save_PrimitiveRestartNV(void)
5609 {
5610    /* Note: this is used when outside a glBegin/End pair in a display list */
5611    GET_CURRENT_CONTEXT(ctx);
5612    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5613    (void) alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0);
5614    if (ctx->ExecuteFlag) {
5615       CALL_PrimitiveRestartNV(ctx->Exec, ());
5616    }
5617 }
5618
5619
5620 void GLAPIENTRY
5621 save_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
5622                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
5623                         GLbitfield mask, GLenum filter)
5624 {
5625    GET_CURRENT_CONTEXT(ctx);
5626    Node *n;
5627    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5628    n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
5629    if (n) {
5630       n[1].i = srcX0;
5631       n[2].i = srcY0;
5632       n[3].i = srcX1;
5633       n[4].i = srcY1;
5634       n[5].i = dstX0;
5635       n[6].i = dstY0;
5636       n[7].i = dstX1;
5637       n[8].i = dstY1;
5638       n[9].i = mask;
5639       n[10].e = filter;
5640    }
5641    if (ctx->ExecuteFlag) {
5642       CALL_BlitFramebuffer(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
5643                                           dstX0, dstY0, dstX1, dstY1,
5644                                           mask, filter));
5645    }
5646 }
5647
5648
5649 /** GL_EXT_provoking_vertex */
5650 void GLAPIENTRY
5651 save_ProvokingVertex(GLenum mode)
5652 {
5653    GET_CURRENT_CONTEXT(ctx);
5654    Node *n;
5655    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5656    n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
5657    if (n) {
5658       n[1].e = mode;
5659    }
5660    if (ctx->ExecuteFlag) {
5661       /*CALL_ProvokingVertex(ctx->Exec, (mode));*/
5662       _mesa_ProvokingVertex(mode);
5663    }
5664 }
5665
5666
5667 /** GL_EXT_transform_feedback */
5668 void GLAPIENTRY
5669 save_BeginTransformFeedback(GLenum mode)
5670 {
5671    GET_CURRENT_CONTEXT(ctx);
5672    Node *n;
5673    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5674    n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1);
5675    if (n) {
5676       n[1].e = mode;
5677    }
5678    if (ctx->ExecuteFlag) {
5679       CALL_BeginTransformFeedback(ctx->Exec, (mode));
5680    }
5681 }
5682
5683
5684 /** GL_EXT_transform_feedback */
5685 void GLAPIENTRY
5686 save_EndTransformFeedback(void)
5687 {
5688    GET_CURRENT_CONTEXT(ctx);
5689    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5690    (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0);
5691    if (ctx->ExecuteFlag) {
5692       CALL_EndTransformFeedback(ctx->Exec, ());
5693    }
5694 }
5695
5696 void GLAPIENTRY
5697 save_BindTransformFeedback(GLenum target, GLuint name)
5698 {
5699    GET_CURRENT_CONTEXT(ctx);
5700    Node *n;
5701    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5702    n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2);
5703    if (n) {
5704       n[1].e = target;
5705       n[2].ui = name;
5706    }
5707    if (ctx->ExecuteFlag) {
5708       CALL_BindTransformFeedback(ctx->Exec, (target, name));
5709    }
5710 }
5711
5712 void GLAPIENTRY
5713 save_PauseTransformFeedback(void)
5714 {
5715    GET_CURRENT_CONTEXT(ctx);
5716    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5717    (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0);
5718    if (ctx->ExecuteFlag) {
5719       CALL_PauseTransformFeedback(ctx->Exec, ());
5720    }
5721 }
5722
5723 void GLAPIENTRY
5724 save_ResumeTransformFeedback(void)
5725 {
5726    GET_CURRENT_CONTEXT(ctx);
5727    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5728    (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0);
5729    if (ctx->ExecuteFlag) {
5730       CALL_ResumeTransformFeedback(ctx->Exec, ());
5731    }
5732 }
5733
5734 void GLAPIENTRY
5735 save_DrawTransformFeedback(GLenum mode, GLuint name)
5736 {
5737    GET_CURRENT_CONTEXT(ctx);
5738    Node *n;
5739    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5740    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2);
5741    if (n) {
5742       n[1].e = mode;
5743       n[2].ui = name;
5744    }
5745    if (ctx->ExecuteFlag) {
5746       CALL_DrawTransformFeedback(ctx->Exec, (mode, name));
5747    }
5748 }
5749
5750 void GLAPIENTRY
5751 save_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream)
5752 {
5753    GET_CURRENT_CONTEXT(ctx);
5754    Node *n;
5755    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5756    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM, 3);
5757    if (n) {
5758       n[1].e = mode;
5759       n[2].ui = name;
5760       n[3].ui = stream;
5761    }
5762    if (ctx->ExecuteFlag) {
5763       CALL_DrawTransformFeedbackStream(ctx->Exec, (mode, name, stream));
5764    }
5765 }
5766
5767 void GLAPIENTRY
5768 save_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
5769                                     GLsizei primcount)
5770 {
5771    GET_CURRENT_CONTEXT(ctx);
5772    Node *n;
5773    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5774    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED, 3);
5775    if (n) {
5776       n[1].e = mode;
5777       n[2].ui = name;
5778       n[3].si = primcount;
5779    }
5780    if (ctx->ExecuteFlag) {
5781       CALL_DrawTransformFeedbackInstanced(ctx->Exec, (mode, name, primcount));
5782    }
5783 }
5784
5785 void GLAPIENTRY
5786 save_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
5787                                           GLuint stream, GLsizei primcount)
5788 {
5789    GET_CURRENT_CONTEXT(ctx);
5790    Node *n;
5791    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5792    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED, 4);
5793    if (n) {
5794       n[1].e = mode;
5795       n[2].ui = name;
5796       n[3].ui = stream;
5797       n[4].si = primcount;
5798    }
5799    if (ctx->ExecuteFlag) {
5800       CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec, (mode, name, stream,
5801                                                             primcount));
5802    }
5803 }
5804
5805 void GLAPIENTRY
5806 save_DispatchCompute(GLuint num_groups_x, GLuint num_groups_y,
5807                      GLuint num_groups_z)
5808 {
5809    GET_CURRENT_CONTEXT(ctx);
5810    Node *n;
5811    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5812    n = alloc_instruction(ctx, OPCODE_DISPATCH_COMPUTE, 3);
5813    if (n) {
5814       n[1].ui = num_groups_x;
5815       n[2].ui = num_groups_y;
5816       n[3].ui = num_groups_z;
5817    }
5818    if (ctx->ExecuteFlag) {
5819       CALL_DispatchCompute(ctx->Exec, (num_groups_x, num_groups_y,
5820                                        num_groups_z));
5821    }
5822 }
5823
5824 void GLAPIENTRY
5825 save_DispatchComputeIndirect(GLintptr indirect)
5826 {
5827    GET_CURRENT_CONTEXT(ctx);
5828    _mesa_error(ctx, GL_INVALID_OPERATION,
5829                "glDispatchComputeIndirect() during display list compile");
5830 }
5831
5832 static void ALWAYS_INLINE
5833 save_Attr32bit(struct gl_context *ctx, unsigned attr, unsigned size,
5834                GLenum type, uint32_t x, uint32_t y, uint32_t z, uint32_t w)
5835 {
5836    Node *n;
5837    SAVE_FLUSH_VERTICES(ctx);
5838    unsigned base_op;
5839    unsigned index = attr;
5840
5841    /* We don't care about GL_INT vs GL_UNSIGNED_INT. The idea is to get W=1
5842     * right for 3 or lower number of components, so only distinguish between
5843     * FLOAT and INT.
5844     */
5845    if (type == GL_FLOAT) {
5846       if (VERT_BIT(attr) & VERT_BIT_GENERIC_ALL) {
5847          base_op = OPCODE_ATTR_1F_ARB;
5848          attr -= VERT_ATTRIB_GENERIC0;
5849       } else {
5850          base_op = OPCODE_ATTR_1F_NV;
5851       }
5852    } else {
5853       base_op = OPCODE_ATTR_1I;
5854       attr -= VERT_ATTRIB_GENERIC0;
5855    }
5856
5857    n = alloc_instruction(ctx, base_op + size - 1, 1 + size);
5858    if (n) {
5859       n[1].ui = attr;
5860       n[2].ui = x;
5861       if (size >= 2) n[3].ui = y;
5862       if (size >= 3) n[4].ui = z;
5863       if (size >= 4) n[5].ui = w;
5864    }
5865
5866    ctx->ListState.ActiveAttribSize[index] = size;
5867    ASSIGN_4V(ctx->ListState.CurrentAttrib[index], x, y, z, w);
5868
5869    if (ctx->ExecuteFlag) {
5870       if (type == GL_FLOAT) {
5871          if (base_op == OPCODE_ATTR_1F_NV) {
5872             if (size == 4)
5873                CALL_VertexAttrib4fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
5874             else if (size == 3)
5875                CALL_VertexAttrib3fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
5876             else if (size == 2)
5877                CALL_VertexAttrib2fNV(ctx->Exec, (attr, uif(x), uif(y)));
5878             else
5879                CALL_VertexAttrib1fNV(ctx->Exec, (attr, uif(x)));
5880          } else {
5881             if (size == 4)
5882                CALL_VertexAttrib4fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
5883             else if (size == 3)
5884                CALL_VertexAttrib3fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
5885             else if (size == 2)
5886                CALL_VertexAttrib2fARB(ctx->Exec, (attr, uif(x), uif(y)));
5887             else
5888                CALL_VertexAttrib1fARB(ctx->Exec, (attr, uif(x)));
5889          }
5890       } else {
5891          if (size == 4)
5892             CALL_VertexAttribI4iEXT(ctx->Exec, (attr, x, y, z, w));
5893          else if (size == 3)
5894             CALL_VertexAttribI3iEXT(ctx->Exec, (attr, x, y, z));
5895          else if (size == 2)
5896             CALL_VertexAttribI2iEXT(ctx->Exec, (attr, x, y));
5897          else
5898             CALL_VertexAttribI1iEXT(ctx->Exec, (attr, x));
5899       }
5900    }
5901 }
5902
5903 static void ALWAYS_INLINE
5904 save_Attr64bit(struct gl_context *ctx, unsigned attr, unsigned size,
5905                GLenum type, uint64_t x, uint64_t y, uint64_t z, uint64_t w)
5906 {
5907    Node *n;
5908    SAVE_FLUSH_VERTICES(ctx);
5909    unsigned base_op;
5910    unsigned index = attr;
5911
5912    if (type == GL_DOUBLE) {
5913       base_op = OPCODE_ATTR_1D;
5914    } else {
5915       base_op = OPCODE_ATTR_1UI64;
5916       assert(size == 1);
5917    }
5918
5919    attr -= VERT_ATTRIB_GENERIC0;
5920    n = alloc_instruction(ctx, base_op + size - 1, 1 + size * 2);
5921    if (n) {
5922       n[1].ui = attr;
5923       ASSIGN_UINT64_TO_NODES(n, 2, x);
5924       if (size >= 2) ASSIGN_UINT64_TO_NODES(n, 4, y);
5925       if (size >= 3) ASSIGN_UINT64_TO_NODES(n, 6, z);
5926       if (size >= 4) ASSIGN_UINT64_TO_NODES(n, 8, w);
5927    }
5928
5929    ctx->ListState.ActiveAttribSize[index] = size;
5930    memcpy(ctx->ListState.CurrentAttrib[index], &n[2], size * sizeof(uint64_t));
5931
5932    if (ctx->ExecuteFlag) {
5933       uint64_t v[] = {x, y, z, w};
5934       if (type == GL_DOUBLE) {
5935          if (size == 4)
5936             CALL_VertexAttribL4dv(ctx->Exec, (attr, (GLdouble*)v));
5937          else if (size == 3)
5938             CALL_VertexAttribL3dv(ctx->Exec, (attr, (GLdouble*)v));
5939          else if (size == 2)
5940             CALL_VertexAttribL2dv(ctx->Exec, (attr, (GLdouble*)v));
5941          else
5942             CALL_VertexAttribL1d(ctx->Exec, (attr, UINT64_AS_DOUBLE(x)));
5943       } else {
5944          CALL_VertexAttribL1ui64ARB(ctx->Exec, (attr, x));
5945       }
5946    }
5947 }
5948
5949 /**
5950  * If index=0, does glVertexAttrib*() alias glVertex() to emit a vertex?
5951  * It depends on a few things, including whether we're inside or outside
5952  * of glBegin/glEnd.
5953  */
5954 static inline bool
5955 is_vertex_position(const struct gl_context *ctx, GLuint index)
5956 {
5957    return (index == 0 &&
5958            _mesa_attr_zero_aliases_vertex(ctx) &&
5959            _mesa_inside_dlist_begin_end(ctx));
5960 }
5961
5962 /**
5963  * This macro is used to implement all the glVertex, glColor, glTexCoord,
5964  * glVertexAttrib, etc functions.
5965  * \param A  VBO_ATTRIB_x attribute index
5966  * \param N  attribute size (1..4)
5967  * \param T  type (GL_FLOAT, GL_DOUBLE, GL_INT, GL_UNSIGNED_INT)
5968  * \param C  cast type (uint32_t or uint64_t)
5969  * \param V0, V1, v2, V3  attribute value
5970  */
5971 #define ATTR_UNION(A, N, T, C, V0, V1, V2, V3)                          \
5972 do {                                                                    \
5973    if (sizeof(C) == 4) {                                                \
5974       save_Attr32bit(ctx, A, N, T, V0, V1, V2, V3);                     \
5975    } else {                                                             \
5976       save_Attr64bit(ctx, A, N, T, V0, V1, V2, V3);                     \
5977    }                                                                    \
5978 } while (0)
5979
5980 #undef ERROR
5981 #define ERROR(err) _mesa_error(ctx, err, __func__)
5982 #define TAG(x) save_##x
5983
5984 #define VBO_ATTRIB_POS           VERT_ATTRIB_POS
5985 #define VBO_ATTRIB_NORMAL        VERT_ATTRIB_NORMAL
5986 #define VBO_ATTRIB_COLOR0        VERT_ATTRIB_COLOR0
5987 #define VBO_ATTRIB_COLOR1        VERT_ATTRIB_COLOR1
5988 #define VBO_ATTRIB_FOG           VERT_ATTRIB_FOG
5989 #define VBO_ATTRIB_COLOR_INDEX   VERT_ATTRIB_COLOR_INDEX
5990 #define VBO_ATTRIB_EDGEFLAG      VERT_ATTRIB_EDGEFLAG
5991 #define VBO_ATTRIB_TEX0          VERT_ATTRIB_TEX0
5992 #define VBO_ATTRIB_GENERIC0      VERT_ATTRIB_GENERIC0
5993 #define VBO_ATTRIB_MAX           VERT_ATTRIB_MAX
5994
5995 #include "vbo/vbo_attrib_tmp.h"
5996
5997 void GLAPIENTRY
5998 save_UseProgram(GLuint program)
5999 {
6000    GET_CURRENT_CONTEXT(ctx);
6001    Node *n;
6002    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6003    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
6004    if (n) {
6005       n[1].ui = program;
6006    }
6007    if (ctx->ExecuteFlag) {
6008       CALL_UseProgram(ctx->Exec, (program));
6009    }
6010 }
6011
6012
6013 void GLAPIENTRY
6014 save_Uniform1f(GLint location, GLfloat x)
6015 {
6016    GET_CURRENT_CONTEXT(ctx);
6017    Node *n;
6018    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6019    n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
6020    if (n) {
6021       n[1].i = location;
6022       n[2].f = x;
6023    }
6024    if (ctx->ExecuteFlag) {
6025       CALL_Uniform1f(ctx->Exec, (location, x));
6026    }
6027 }
6028
6029
6030 void GLAPIENTRY
6031 save_Uniform2f(GLint location, GLfloat x, GLfloat y)
6032 {
6033    GET_CURRENT_CONTEXT(ctx);
6034    Node *n;
6035    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6036    n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3);
6037    if (n) {
6038       n[1].i = location;
6039       n[2].f = x;
6040       n[3].f = y;
6041    }
6042    if (ctx->ExecuteFlag) {
6043       CALL_Uniform2f(ctx->Exec, (location, x, y));
6044    }
6045 }
6046
6047
6048 void GLAPIENTRY
6049 save_Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
6050 {
6051    GET_CURRENT_CONTEXT(ctx);
6052    Node *n;
6053    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6054    n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
6055    if (n) {
6056       n[1].i = location;
6057       n[2].f = x;
6058       n[3].f = y;
6059       n[4].f = z;
6060    }
6061    if (ctx->ExecuteFlag) {
6062       CALL_Uniform3f(ctx->Exec, (location, x, y, z));
6063    }
6064 }
6065
6066
6067 void GLAPIENTRY
6068 save_Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6069 {
6070    GET_CURRENT_CONTEXT(ctx);
6071    Node *n;
6072    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6073    n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
6074    if (n) {
6075       n[1].i = location;
6076       n[2].f = x;
6077       n[3].f = y;
6078       n[4].f = z;
6079       n[5].f = w;
6080    }
6081    if (ctx->ExecuteFlag) {
6082       CALL_Uniform4f(ctx->Exec, (location, x, y, z, w));
6083    }
6084 }
6085
6086
6087 void GLAPIENTRY
6088 save_Uniform1fv(GLint location, GLsizei count, const GLfloat *v)
6089 {
6090    GET_CURRENT_CONTEXT(ctx);
6091    Node *n;
6092    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6093    n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 2 + POINTER_DWORDS);
6094    if (n) {
6095       n[1].i = location;
6096       n[2].i = count;
6097       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLfloat)));
6098    }
6099    if (ctx->ExecuteFlag) {
6100       CALL_Uniform1fv(ctx->Exec, (location, count, v));
6101    }
6102 }
6103
6104 void GLAPIENTRY
6105 save_Uniform2fv(GLint location, GLsizei count, const GLfloat *v)
6106 {
6107    GET_CURRENT_CONTEXT(ctx);
6108    Node *n;
6109    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6110    n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 2 + POINTER_DWORDS);
6111    if (n) {
6112       n[1].i = location;
6113       n[2].i = count;
6114       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLfloat)));
6115    }
6116    if (ctx->ExecuteFlag) {
6117       CALL_Uniform2fv(ctx->Exec, (location, count, v));
6118    }
6119 }
6120
6121 void GLAPIENTRY
6122 save_Uniform3fv(GLint location, GLsizei count, const GLfloat *v)
6123 {
6124    GET_CURRENT_CONTEXT(ctx);
6125    Node *n;
6126    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6127    n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 2 + POINTER_DWORDS);
6128    if (n) {
6129       n[1].i = location;
6130       n[2].i = count;
6131       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLfloat)));
6132    }
6133    if (ctx->ExecuteFlag) {
6134       CALL_Uniform3fv(ctx->Exec, (location, count, v));
6135    }
6136 }
6137
6138 void GLAPIENTRY
6139 save_Uniform4fv(GLint location, GLsizei count, const GLfloat *v)
6140 {
6141    GET_CURRENT_CONTEXT(ctx);
6142    Node *n;
6143    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6144    n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 2 + POINTER_DWORDS);
6145    if (n) {
6146       n[1].i = location;
6147       n[2].i = count;
6148       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6149    }
6150    if (ctx->ExecuteFlag) {
6151       CALL_Uniform4fv(ctx->Exec, (location, count, v));
6152    }
6153 }
6154
6155
6156 void GLAPIENTRY
6157 save_Uniform1d(GLint location, GLdouble x)
6158 {
6159    GET_CURRENT_CONTEXT(ctx);
6160    Node *n;
6161    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6162    n = alloc_instruction(ctx, OPCODE_UNIFORM_1D, 3);
6163    if (n) {
6164       n[1].i = location;
6165       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6166    }
6167    if (ctx->ExecuteFlag) {
6168       CALL_Uniform1d(ctx->Exec, (location, x));
6169    }
6170 }
6171
6172
6173 void GLAPIENTRY
6174 save_Uniform2d(GLint location, GLdouble x, GLdouble y)
6175 {
6176    GET_CURRENT_CONTEXT(ctx);
6177    Node *n;
6178    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6179    n = alloc_instruction(ctx, OPCODE_UNIFORM_2D, 5);
6180    if (n) {
6181       n[1].i = location;
6182       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6183       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6184    }
6185    if (ctx->ExecuteFlag) {
6186       CALL_Uniform2d(ctx->Exec, (location, x, y));
6187    }
6188 }
6189
6190
6191 void GLAPIENTRY
6192 save_Uniform3d(GLint location, GLdouble x, GLdouble y, GLdouble z)
6193 {
6194    GET_CURRENT_CONTEXT(ctx);
6195    Node *n;
6196    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6197    n = alloc_instruction(ctx, OPCODE_UNIFORM_3D, 7);
6198    if (n) {
6199       n[1].i = location;
6200       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6201       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6202       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6203    }
6204    if (ctx->ExecuteFlag) {
6205       CALL_Uniform3d(ctx->Exec, (location, x, y, z));
6206    }
6207 }
6208
6209
6210 void GLAPIENTRY
6211 save_Uniform4d(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
6212 {
6213    GET_CURRENT_CONTEXT(ctx);
6214    Node *n;
6215    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6216    n = alloc_instruction(ctx, OPCODE_UNIFORM_4D, 9);
6217    if (n) {
6218       n[1].i = location;
6219       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6220       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6221       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6222       ASSIGN_DOUBLE_TO_NODES(n, 8, w);
6223    }
6224    if (ctx->ExecuteFlag) {
6225       CALL_Uniform4d(ctx->Exec, (location, x, y, z, w));
6226    }
6227 }
6228
6229
6230 void GLAPIENTRY
6231 save_Uniform1dv(GLint location, GLsizei count, const GLdouble *v)
6232 {
6233    GET_CURRENT_CONTEXT(ctx);
6234    Node *n;
6235    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6236    n = alloc_instruction(ctx, OPCODE_UNIFORM_1DV, 2 + POINTER_DWORDS);
6237    if (n) {
6238       n[1].i = location;
6239       n[2].i = count;
6240       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLdouble)));
6241    }
6242    if (ctx->ExecuteFlag) {
6243       CALL_Uniform1dv(ctx->Exec, (location, count, v));
6244    }
6245 }
6246
6247
6248 void GLAPIENTRY
6249 save_Uniform2dv(GLint location, GLsizei count, const GLdouble *v)
6250 {
6251    GET_CURRENT_CONTEXT(ctx);
6252    Node *n;
6253    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6254    n = alloc_instruction(ctx, OPCODE_UNIFORM_2DV, 2 + POINTER_DWORDS);
6255    if (n) {
6256       n[1].i = location;
6257       n[2].i = count;
6258       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLdouble)));
6259    }
6260    if (ctx->ExecuteFlag) {
6261       CALL_Uniform2dv(ctx->Exec, (location, count, v));
6262    }
6263 }
6264
6265
6266 void GLAPIENTRY
6267 save_Uniform3dv(GLint location, GLsizei count, const GLdouble *v)
6268 {
6269    GET_CURRENT_CONTEXT(ctx);
6270    Node *n;
6271    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6272    n = alloc_instruction(ctx, OPCODE_UNIFORM_3DV, 2 + POINTER_DWORDS);
6273    if (n) {
6274       n[1].i = location;
6275       n[2].i = count;
6276       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLdouble)));
6277    }
6278    if (ctx->ExecuteFlag) {
6279       CALL_Uniform3dv(ctx->Exec, (location, count, v));
6280    }
6281 }
6282
6283
6284 void GLAPIENTRY
6285 save_Uniform4dv(GLint location, GLsizei count, const GLdouble *v)
6286 {
6287    GET_CURRENT_CONTEXT(ctx);
6288    Node *n;
6289    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6290    n = alloc_instruction(ctx, OPCODE_UNIFORM_4DV, 2 + POINTER_DWORDS);
6291    if (n) {
6292       n[1].i = location;
6293       n[2].i = count;
6294       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLdouble)));
6295    }
6296    if (ctx->ExecuteFlag) {
6297       CALL_Uniform4dv(ctx->Exec, (location, count, v));
6298    }
6299 }
6300
6301
6302 void GLAPIENTRY
6303 save_Uniform1i(GLint location, GLint x)
6304 {
6305    GET_CURRENT_CONTEXT(ctx);
6306    Node *n;
6307    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6308    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
6309    if (n) {
6310       n[1].i = location;
6311       n[2].i = x;
6312    }
6313    if (ctx->ExecuteFlag) {
6314       CALL_Uniform1i(ctx->Exec, (location, x));
6315    }
6316 }
6317
6318 void GLAPIENTRY
6319 save_Uniform2i(GLint location, GLint x, GLint y)
6320 {
6321    GET_CURRENT_CONTEXT(ctx);
6322    Node *n;
6323    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6324    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
6325    if (n) {
6326       n[1].i = location;
6327       n[2].i = x;
6328       n[3].i = y;
6329    }
6330    if (ctx->ExecuteFlag) {
6331       CALL_Uniform2i(ctx->Exec, (location, x, y));
6332    }
6333 }
6334
6335 void GLAPIENTRY
6336 save_Uniform3i(GLint location, GLint x, GLint y, GLint z)
6337 {
6338    GET_CURRENT_CONTEXT(ctx);
6339    Node *n;
6340    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6341    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
6342    if (n) {
6343       n[1].i = location;
6344       n[2].i = x;
6345       n[3].i = y;
6346       n[4].i = z;
6347    }
6348    if (ctx->ExecuteFlag) {
6349       CALL_Uniform3i(ctx->Exec, (location, x, y, z));
6350    }
6351 }
6352
6353 void GLAPIENTRY
6354 save_Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
6355 {
6356    GET_CURRENT_CONTEXT(ctx);
6357    Node *n;
6358    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6359    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
6360    if (n) {
6361       n[1].i = location;
6362       n[2].i = x;
6363       n[3].i = y;
6364       n[4].i = z;
6365       n[5].i = w;
6366    }
6367    if (ctx->ExecuteFlag) {
6368       CALL_Uniform4i(ctx->Exec, (location, x, y, z, w));
6369    }
6370 }
6371
6372
6373
6374 void GLAPIENTRY
6375 save_Uniform1iv(GLint location, GLsizei count, const GLint *v)
6376 {
6377    GET_CURRENT_CONTEXT(ctx);
6378    Node *n;
6379    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6380    n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 2 + POINTER_DWORDS);
6381    if (n) {
6382       n[1].i = location;
6383       n[2].i = count;
6384       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint)));
6385    }
6386    if (ctx->ExecuteFlag) {
6387       CALL_Uniform1iv(ctx->Exec, (location, count, v));
6388    }
6389 }
6390
6391 void GLAPIENTRY
6392 save_Uniform2iv(GLint location, GLsizei count, const GLint *v)
6393 {
6394    GET_CURRENT_CONTEXT(ctx);
6395    Node *n;
6396    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6397    n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 2 + POINTER_DWORDS);
6398    if (n) {
6399       n[1].i = location;
6400       n[2].i = count;
6401       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint)));
6402    }
6403    if (ctx->ExecuteFlag) {
6404       CALL_Uniform2iv(ctx->Exec, (location, count, v));
6405    }
6406 }
6407
6408 void GLAPIENTRY
6409 save_Uniform3iv(GLint location, GLsizei count, const GLint *v)
6410 {
6411    GET_CURRENT_CONTEXT(ctx);
6412    Node *n;
6413    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6414    n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 2 + POINTER_DWORDS);
6415    if (n) {
6416       n[1].i = location;
6417       n[2].i = count;
6418       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint)));
6419    }
6420    if (ctx->ExecuteFlag) {
6421       CALL_Uniform3iv(ctx->Exec, (location, count, v));
6422    }
6423 }
6424
6425 void GLAPIENTRY
6426 save_Uniform4iv(GLint location, GLsizei count, const GLint *v)
6427 {
6428    GET_CURRENT_CONTEXT(ctx);
6429    Node *n;
6430    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6431    n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 2 + POINTER_DWORDS);
6432    if (n) {
6433       n[1].i = location;
6434       n[2].i = count;
6435       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6436    }
6437    if (ctx->ExecuteFlag) {
6438       CALL_Uniform4iv(ctx->Exec, (location, count, v));
6439    }
6440 }
6441
6442
6443
6444 void GLAPIENTRY
6445 save_Uniform1ui(GLint location, GLuint x)
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_1UI, 2);
6451    if (n) {
6452       n[1].i = location;
6453       n[2].i = x;
6454    }
6455    if (ctx->ExecuteFlag) {
6456       CALL_Uniform1ui(ctx->Exec, (location, x));
6457    }
6458 }
6459
6460 void GLAPIENTRY
6461 save_Uniform2ui(GLint location, GLuint x, GLuint y)
6462 {
6463    GET_CURRENT_CONTEXT(ctx);
6464    Node *n;
6465    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6466    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3);
6467    if (n) {
6468       n[1].i = location;
6469       n[2].i = x;
6470       n[3].i = y;
6471    }
6472    if (ctx->ExecuteFlag) {
6473       CALL_Uniform2ui(ctx->Exec, (location, x, y));
6474    }
6475 }
6476
6477 void GLAPIENTRY
6478 save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z)
6479 {
6480    GET_CURRENT_CONTEXT(ctx);
6481    Node *n;
6482    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6483    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4);
6484    if (n) {
6485       n[1].i = location;
6486       n[2].i = x;
6487       n[3].i = y;
6488       n[4].i = z;
6489    }
6490    if (ctx->ExecuteFlag) {
6491       CALL_Uniform3ui(ctx->Exec, (location, x, y, z));
6492    }
6493 }
6494
6495 void GLAPIENTRY
6496 save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w)
6497 {
6498    GET_CURRENT_CONTEXT(ctx);
6499    Node *n;
6500    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6501    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5);
6502    if (n) {
6503       n[1].i = location;
6504       n[2].i = x;
6505       n[3].i = y;
6506       n[4].i = z;
6507       n[5].i = w;
6508    }
6509    if (ctx->ExecuteFlag) {
6510       CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));
6511    }
6512 }
6513
6514
6515
6516 void GLAPIENTRY
6517 save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v)
6518 {
6519    GET_CURRENT_CONTEXT(ctx);
6520    Node *n;
6521    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6522    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 2 + POINTER_DWORDS);
6523    if (n) {
6524       n[1].i = location;
6525       n[2].i = count;
6526       save_pointer(&n[3], memdup(v, count * 1 * sizeof(*v)));
6527    }
6528    if (ctx->ExecuteFlag) {
6529       CALL_Uniform1uiv(ctx->Exec, (location, count, v));
6530    }
6531 }
6532
6533 void GLAPIENTRY
6534 save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v)
6535 {
6536    GET_CURRENT_CONTEXT(ctx);
6537    Node *n;
6538    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6539    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 2 + POINTER_DWORDS);
6540    if (n) {
6541       n[1].i = location;
6542       n[2].i = count;
6543       save_pointer(&n[3], memdup(v, count * 2 * sizeof(*v)));
6544    }
6545    if (ctx->ExecuteFlag) {
6546       CALL_Uniform2uiv(ctx->Exec, (location, count, v));
6547    }
6548 }
6549
6550 void GLAPIENTRY
6551 save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v)
6552 {
6553    GET_CURRENT_CONTEXT(ctx);
6554    Node *n;
6555    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6556    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 2 + POINTER_DWORDS);
6557    if (n) {
6558       n[1].i = location;
6559       n[2].i = count;
6560       save_pointer(&n[3], memdup(v, count * 3 * sizeof(*v)));
6561    }
6562    if (ctx->ExecuteFlag) {
6563       CALL_Uniform3uiv(ctx->Exec, (location, count, v));
6564    }
6565 }
6566
6567 void GLAPIENTRY
6568 save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v)
6569 {
6570    GET_CURRENT_CONTEXT(ctx);
6571    Node *n;
6572    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6573    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 2 + POINTER_DWORDS);
6574    if (n) {
6575       n[1].i = location;
6576       n[2].i = count;
6577       save_pointer(&n[3], memdup(v, count * 4 * sizeof(*v)));
6578    }
6579    if (ctx->ExecuteFlag) {
6580       CALL_Uniform4uiv(ctx->Exec, (location, count, v));
6581    }
6582 }
6583
6584
6585
6586 void GLAPIENTRY
6587 save_UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose,
6588                          const GLfloat *m)
6589 {
6590    GET_CURRENT_CONTEXT(ctx);
6591    Node *n;
6592    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6593    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 3 + POINTER_DWORDS);
6594    if (n) {
6595       n[1].i = location;
6596       n[2].i = count;
6597       n[3].b = transpose;
6598       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLfloat)));
6599    }
6600    if (ctx->ExecuteFlag) {
6601       CALL_UniformMatrix2fv(ctx->Exec, (location, count, transpose, m));
6602    }
6603 }
6604
6605 void GLAPIENTRY
6606 save_UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose,
6607                          const GLfloat *m)
6608 {
6609    GET_CURRENT_CONTEXT(ctx);
6610    Node *n;
6611    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6612    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 3 + POINTER_DWORDS);
6613    if (n) {
6614       n[1].i = location;
6615       n[2].i = count;
6616       n[3].b = transpose;
6617       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLfloat)));
6618    }
6619    if (ctx->ExecuteFlag) {
6620       CALL_UniformMatrix3fv(ctx->Exec, (location, count, transpose, m));
6621    }
6622 }
6623
6624 void GLAPIENTRY
6625 save_UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
6626                          const GLfloat *m)
6627 {
6628    GET_CURRENT_CONTEXT(ctx);
6629    Node *n;
6630    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6631    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 3 + POINTER_DWORDS);
6632    if (n) {
6633       n[1].i = location;
6634       n[2].i = count;
6635       n[3].b = transpose;
6636       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLfloat)));
6637    }
6638    if (ctx->ExecuteFlag) {
6639       CALL_UniformMatrix4fv(ctx->Exec, (location, count, transpose, m));
6640    }
6641 }
6642
6643
6644 void GLAPIENTRY
6645 save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
6646                         const GLfloat *m)
6647 {
6648    GET_CURRENT_CONTEXT(ctx);
6649    Node *n;
6650    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6651    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 3 + POINTER_DWORDS);
6652    if (n) {
6653       n[1].i = location;
6654       n[2].i = count;
6655       n[3].b = transpose;
6656       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLfloat)));
6657    }
6658    if (ctx->ExecuteFlag) {
6659       CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m));
6660    }
6661 }
6662
6663 void GLAPIENTRY
6664 save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
6665                         const GLfloat *m)
6666 {
6667    GET_CURRENT_CONTEXT(ctx);
6668    Node *n;
6669    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6670    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 3 + POINTER_DWORDS);
6671    if (n) {
6672       n[1].i = location;
6673       n[2].i = count;
6674       n[3].b = transpose;
6675       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLfloat)));
6676    }
6677    if (ctx->ExecuteFlag) {
6678       CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m));
6679    }
6680 }
6681
6682
6683 void GLAPIENTRY
6684 save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
6685                         const GLfloat *m)
6686 {
6687    GET_CURRENT_CONTEXT(ctx);
6688    Node *n;
6689    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6690    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 3 + POINTER_DWORDS);
6691    if (n) {
6692       n[1].i = location;
6693       n[2].i = count;
6694       n[3].b = transpose;
6695       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLfloat)));
6696    }
6697    if (ctx->ExecuteFlag) {
6698       CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m));
6699    }
6700 }
6701
6702 void GLAPIENTRY
6703 save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
6704                         const GLfloat *m)
6705 {
6706    GET_CURRENT_CONTEXT(ctx);
6707    Node *n;
6708    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6709    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 3 + POINTER_DWORDS);
6710    if (n) {
6711       n[1].i = location;
6712       n[2].i = count;
6713       n[3].b = transpose;
6714       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLfloat)));
6715    }
6716    if (ctx->ExecuteFlag) {
6717       CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m));
6718    }
6719 }
6720
6721
6722 void GLAPIENTRY
6723 save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
6724                         const GLfloat *m)
6725 {
6726    GET_CURRENT_CONTEXT(ctx);
6727    Node *n;
6728    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6729    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 3 + POINTER_DWORDS);
6730    if (n) {
6731       n[1].i = location;
6732       n[2].i = count;
6733       n[3].b = transpose;
6734       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLfloat)));
6735    }
6736    if (ctx->ExecuteFlag) {
6737       CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m));
6738    }
6739 }
6740
6741 void GLAPIENTRY
6742 save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
6743                         const GLfloat *m)
6744 {
6745    GET_CURRENT_CONTEXT(ctx);
6746    Node *n;
6747    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6748    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 3 + POINTER_DWORDS);
6749    if (n) {
6750       n[1].i = location;
6751       n[2].i = count;
6752       n[3].b = transpose;
6753       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLfloat)));
6754    }
6755    if (ctx->ExecuteFlag) {
6756       CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m));
6757    }
6758 }
6759
6760
6761 void GLAPIENTRY
6762 save_UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose,
6763                       const GLdouble *m)
6764 {
6765    GET_CURRENT_CONTEXT(ctx);
6766    Node *n;
6767    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6768    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22D, 3 + POINTER_DWORDS);
6769    if (n) {
6770       n[1].i = location;
6771       n[2].i = count;
6772       n[3].b = transpose;
6773       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLdouble)));
6774    }
6775    if (ctx->ExecuteFlag) {
6776       CALL_UniformMatrix2dv(ctx->Exec, (location, count, transpose, m));
6777    }
6778 }
6779
6780 void GLAPIENTRY
6781 save_UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose,
6782                       const GLdouble *m)
6783 {
6784    GET_CURRENT_CONTEXT(ctx);
6785    Node *n;
6786    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6787    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33D, 3 + POINTER_DWORDS);
6788    if (n) {
6789       n[1].i = location;
6790       n[2].i = count;
6791       n[3].b = transpose;
6792       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLdouble)));
6793    }
6794    if (ctx->ExecuteFlag) {
6795       CALL_UniformMatrix3dv(ctx->Exec, (location, count, transpose, m));
6796    }
6797 }
6798
6799 void GLAPIENTRY
6800 save_UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose,
6801                       const GLdouble *m)
6802 {
6803    GET_CURRENT_CONTEXT(ctx);
6804    Node *n;
6805    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6806    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44D, 3 + POINTER_DWORDS);
6807    if (n) {
6808       n[1].i = location;
6809       n[2].i = count;
6810       n[3].b = transpose;
6811       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLdouble)));
6812    }
6813    if (ctx->ExecuteFlag) {
6814       CALL_UniformMatrix4dv(ctx->Exec, (location, count, transpose, m));
6815    }
6816 }
6817
6818
6819 void GLAPIENTRY
6820 save_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose,
6821                         const GLdouble *m)
6822 {
6823    GET_CURRENT_CONTEXT(ctx);
6824    Node *n;
6825    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6826    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23D, 3 + POINTER_DWORDS);
6827    if (n) {
6828       n[1].i = location;
6829       n[2].i = count;
6830       n[3].b = transpose;
6831       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLdouble)));
6832    }
6833    if (ctx->ExecuteFlag) {
6834       CALL_UniformMatrix2x3dv(ctx->Exec, (location, count, transpose, m));
6835    }
6836 }
6837
6838
6839 void GLAPIENTRY
6840 save_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose,
6841                         const GLdouble *m)
6842 {
6843    GET_CURRENT_CONTEXT(ctx);
6844    Node *n;
6845    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6846    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32D, 3 + POINTER_DWORDS);
6847    if (n) {
6848       n[1].i = location;
6849       n[2].i = count;
6850       n[3].b = transpose;
6851       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLdouble)));
6852    }
6853    if (ctx->ExecuteFlag) {
6854       CALL_UniformMatrix3x2dv(ctx->Exec, (location, count, transpose, m));
6855    }
6856 }
6857
6858
6859 void GLAPIENTRY
6860 save_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose,
6861                         const GLdouble *m)
6862 {
6863    GET_CURRENT_CONTEXT(ctx);
6864    Node *n;
6865    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6866    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24D, 3 + POINTER_DWORDS);
6867    if (n) {
6868       n[1].i = location;
6869       n[2].i = count;
6870       n[3].b = transpose;
6871       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLdouble)));
6872    }
6873    if (ctx->ExecuteFlag) {
6874       CALL_UniformMatrix2x4dv(ctx->Exec, (location, count, transpose, m));
6875    }
6876 }
6877
6878 void GLAPIENTRY
6879 save_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose,
6880                         const GLdouble *m)
6881 {
6882    GET_CURRENT_CONTEXT(ctx);
6883    Node *n;
6884    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6885    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42D, 3 + POINTER_DWORDS);
6886    if (n) {
6887       n[1].i = location;
6888       n[2].i = count;
6889       n[3].b = transpose;
6890       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLdouble)));
6891    }
6892    if (ctx->ExecuteFlag) {
6893       CALL_UniformMatrix4x2dv(ctx->Exec, (location, count, transpose, m));
6894    }
6895 }
6896
6897
6898 void GLAPIENTRY
6899 save_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose,
6900                         const GLdouble *m)
6901 {
6902    GET_CURRENT_CONTEXT(ctx);
6903    Node *n;
6904    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6905    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34D, 3 + POINTER_DWORDS);
6906    if (n) {
6907       n[1].i = location;
6908       n[2].i = count;
6909       n[3].b = transpose;
6910       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLdouble)));
6911    }
6912    if (ctx->ExecuteFlag) {
6913       CALL_UniformMatrix3x4dv(ctx->Exec, (location, count, transpose, m));
6914    }
6915 }
6916
6917
6918 void GLAPIENTRY
6919 save_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose,
6920                         const GLdouble *m)
6921 {
6922    GET_CURRENT_CONTEXT(ctx);
6923    Node *n;
6924    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6925    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43D, 3 + POINTER_DWORDS);
6926    if (n) {
6927       n[1].i = location;
6928       n[2].i = count;
6929       n[3].b = transpose;
6930       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLdouble)));
6931    }
6932    if (ctx->ExecuteFlag) {
6933       CALL_UniformMatrix4x3dv(ctx->Exec, (location, count, transpose, m));
6934    }
6935 }
6936
6937 void GLAPIENTRY
6938 save_Uniform1i64ARB(GLint location, GLint64 x)
6939 {
6940    GET_CURRENT_CONTEXT(ctx);
6941    Node *n;
6942    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6943    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64, 3);
6944    if (n) {
6945       n[1].i = location;
6946       ASSIGN_INT64_TO_NODES(n, 2, x);
6947    }
6948    if (ctx->ExecuteFlag) {
6949       CALL_Uniform1i64ARB(ctx->Exec, (location, x));
6950    }
6951 }
6952
6953 void GLAPIENTRY
6954 save_Uniform2i64ARB(GLint location, GLint64 x, GLint64 y)
6955 {
6956    GET_CURRENT_CONTEXT(ctx);
6957    Node *n;
6958    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6959    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64, 5);
6960    if (n) {
6961       n[1].i = location;
6962       ASSIGN_INT64_TO_NODES(n, 2, x);
6963       ASSIGN_INT64_TO_NODES(n, 4, y);
6964    }
6965    if (ctx->ExecuteFlag) {
6966       CALL_Uniform2i64ARB(ctx->Exec, (location, x, y));
6967    }
6968 }
6969
6970 void GLAPIENTRY
6971 save_Uniform3i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z)
6972 {
6973    GET_CURRENT_CONTEXT(ctx);
6974    Node *n;
6975    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6976    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64, 7);
6977    if (n) {
6978       n[1].i = location;
6979       ASSIGN_INT64_TO_NODES(n, 2, x);
6980       ASSIGN_INT64_TO_NODES(n, 4, y);
6981       ASSIGN_INT64_TO_NODES(n, 6, z);
6982    }
6983    if (ctx->ExecuteFlag) {
6984       CALL_Uniform3i64ARB(ctx->Exec, (location, x, y, z));
6985    }
6986 }
6987
6988 void GLAPIENTRY
6989 save_Uniform4i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w)
6990 {
6991    GET_CURRENT_CONTEXT(ctx);
6992    Node *n;
6993    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6994    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64, 9);
6995    if (n) {
6996       n[1].i = location;
6997       ASSIGN_INT64_TO_NODES(n, 2, x);
6998       ASSIGN_INT64_TO_NODES(n, 4, y);
6999       ASSIGN_INT64_TO_NODES(n, 6, z);
7000       ASSIGN_INT64_TO_NODES(n, 8, w);
7001    }
7002    if (ctx->ExecuteFlag) {
7003       CALL_Uniform4i64ARB(ctx->Exec, (location, x, y, z, w));
7004    }
7005 }
7006
7007 void GLAPIENTRY
7008 save_Uniform1i64vARB(GLint location, GLsizei count, const GLint64 *v)
7009 {
7010    GET_CURRENT_CONTEXT(ctx);
7011    Node *n;
7012    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7013    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64V, 2 + POINTER_DWORDS);
7014    if (n) {
7015      n[1].i = location;
7016      n[2].i = count;
7017      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint64)));
7018    }
7019    if (ctx->ExecuteFlag) {
7020       CALL_Uniform1i64vARB(ctx->Exec, (location, count, v));
7021    }
7022 }
7023
7024 void GLAPIENTRY
7025 save_Uniform2i64vARB(GLint location, GLsizei count, const GLint64 *v)
7026 {
7027    GET_CURRENT_CONTEXT(ctx);
7028    Node *n;
7029    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7030    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64V, 2 + POINTER_DWORDS);
7031    if (n) {
7032      n[1].i = location;
7033      n[2].i = count;
7034      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint64)));
7035    }
7036    if (ctx->ExecuteFlag) {
7037       CALL_Uniform2i64vARB(ctx->Exec, (location, count, v));
7038    }
7039 }
7040
7041 void GLAPIENTRY
7042 save_Uniform3i64vARB(GLint location, GLsizei count, const GLint64 *v)
7043 {
7044    GET_CURRENT_CONTEXT(ctx);
7045    Node *n;
7046    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7047    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64V, 2 + POINTER_DWORDS);
7048    if (n) {
7049      n[1].i = location;
7050      n[2].i = count;
7051      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint64)));
7052    }
7053    if (ctx->ExecuteFlag) {
7054       CALL_Uniform3i64vARB(ctx->Exec, (location, count, v));
7055    }
7056 }
7057
7058 void GLAPIENTRY
7059 save_Uniform4i64vARB(GLint location, GLsizei count, const GLint64 *v)
7060 {
7061    GET_CURRENT_CONTEXT(ctx);
7062    Node *n;
7063    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7064    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64V, 2 + POINTER_DWORDS);
7065    if (n) {
7066      n[1].i = location;
7067      n[2].i = count;
7068      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint64)));
7069    }
7070    if (ctx->ExecuteFlag) {
7071       CALL_Uniform4i64vARB(ctx->Exec, (location, count, v));
7072    }
7073 }
7074
7075 void GLAPIENTRY
7076 save_Uniform1ui64ARB(GLint location, GLuint64 x)
7077 {
7078    GET_CURRENT_CONTEXT(ctx);
7079    Node *n;
7080    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7081    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64, 3);
7082    if (n) {
7083       n[1].i = location;
7084       ASSIGN_UINT64_TO_NODES(n, 2, x);
7085    }
7086    if (ctx->ExecuteFlag) {
7087       CALL_Uniform1ui64ARB(ctx->Exec, (location, x));
7088    }
7089 }
7090
7091 void GLAPIENTRY
7092 save_Uniform2ui64ARB(GLint location, GLuint64 x, GLuint64 y)
7093 {
7094    GET_CURRENT_CONTEXT(ctx);
7095    Node *n;
7096    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7097    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64, 5);
7098    if (n) {
7099       n[1].i = location;
7100       ASSIGN_UINT64_TO_NODES(n, 2, x);
7101       ASSIGN_UINT64_TO_NODES(n, 4, y);
7102    }
7103    if (ctx->ExecuteFlag) {
7104       CALL_Uniform2ui64ARB(ctx->Exec, (location, x, y));
7105    }
7106 }
7107
7108 void GLAPIENTRY
7109 save_Uniform3ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z)
7110 {
7111    GET_CURRENT_CONTEXT(ctx);
7112    Node *n;
7113    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7114    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64, 7);
7115    if (n) {
7116       n[1].i = location;
7117       ASSIGN_UINT64_TO_NODES(n, 2, x);
7118       ASSIGN_UINT64_TO_NODES(n, 4, y);
7119       ASSIGN_UINT64_TO_NODES(n, 6, z);
7120    }
7121    if (ctx->ExecuteFlag) {
7122       CALL_Uniform3ui64ARB(ctx->Exec, (location, x, y, z));
7123    }
7124 }
7125
7126 void GLAPIENTRY
7127 save_Uniform4ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w)
7128 {
7129    GET_CURRENT_CONTEXT(ctx);
7130    Node *n;
7131    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7132    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64, 9);
7133    if (n) {
7134       n[1].i = location;
7135       ASSIGN_UINT64_TO_NODES(n, 2, x);
7136       ASSIGN_UINT64_TO_NODES(n, 4, y);
7137       ASSIGN_UINT64_TO_NODES(n, 6, z);
7138       ASSIGN_UINT64_TO_NODES(n, 8, w);
7139    }
7140    if (ctx->ExecuteFlag) {
7141       CALL_Uniform4ui64ARB(ctx->Exec, (location, x, y, z, w));
7142    }
7143 }
7144
7145 void GLAPIENTRY
7146 save_Uniform1ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7147 {
7148    GET_CURRENT_CONTEXT(ctx);
7149    Node *n;
7150    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7151    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64V, 2 + POINTER_DWORDS);
7152    if (n) {
7153      n[1].i = location;
7154      n[2].i = count;
7155      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLuint64)));
7156    }
7157    if (ctx->ExecuteFlag) {
7158       CALL_Uniform1ui64vARB(ctx->Exec, (location, count, v));
7159    }
7160 }
7161
7162 void GLAPIENTRY
7163 save_Uniform2ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7164 {
7165    GET_CURRENT_CONTEXT(ctx);
7166    Node *n;
7167    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7168    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64V, 2 + POINTER_DWORDS);
7169    if (n) {
7170      n[1].i = location;
7171      n[2].i = count;
7172      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLuint64)));
7173    }
7174    if (ctx->ExecuteFlag) {
7175       CALL_Uniform2ui64vARB(ctx->Exec, (location, count, v));
7176    }
7177 }
7178
7179 void GLAPIENTRY
7180 save_Uniform3ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7181 {
7182    GET_CURRENT_CONTEXT(ctx);
7183    Node *n;
7184    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7185    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64V, 2 + POINTER_DWORDS);
7186    if (n) {
7187      n[1].i = location;
7188      n[2].i = count;
7189      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLuint64)));
7190    }
7191    if (ctx->ExecuteFlag) {
7192       CALL_Uniform3ui64vARB(ctx->Exec, (location, count, v));
7193    }
7194 }
7195
7196 void GLAPIENTRY
7197 save_Uniform4ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7198 {
7199    GET_CURRENT_CONTEXT(ctx);
7200    Node *n;
7201    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7202    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64V, 2 + POINTER_DWORDS);
7203    if (n) {
7204      n[1].i = location;
7205      n[2].i = count;
7206      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLuint64)));
7207    }
7208    if (ctx->ExecuteFlag) {
7209       CALL_Uniform4ui64vARB(ctx->Exec, (location, count, v));
7210    }
7211 }
7212
7213 void GLAPIENTRY
7214 save_ProgramUniform1i64ARB(GLuint program, GLint location, GLint64 x)
7215 {
7216    GET_CURRENT_CONTEXT(ctx);
7217    Node *n;
7218    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7219    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I64, 4);
7220    if (n) {
7221       n[1].ui = program;
7222       n[2].i = location;
7223       ASSIGN_INT64_TO_NODES(n, 3, x);
7224    }
7225    if (ctx->ExecuteFlag) {
7226       CALL_ProgramUniform1i64ARB(ctx->Exec, (program, location, x));
7227    }
7228 }
7229
7230 void GLAPIENTRY
7231 save_ProgramUniform2i64ARB(GLuint program, GLint location, GLint64 x,
7232                            GLint64 y)
7233 {
7234    GET_CURRENT_CONTEXT(ctx);
7235    Node *n;
7236    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7237    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64, 6);
7238    if (n) {
7239       n[1].ui = program;
7240       n[2].i = location;
7241       ASSIGN_INT64_TO_NODES(n, 3, x);
7242       ASSIGN_INT64_TO_NODES(n, 5, y);
7243    }
7244    if (ctx->ExecuteFlag) {
7245       CALL_ProgramUniform2i64ARB(ctx->Exec, (program, location, x, y));
7246    }
7247 }
7248
7249 void GLAPIENTRY
7250 save_ProgramUniform3i64ARB(GLuint program, GLint location, GLint64 x,
7251                            GLint64 y, GLint64 z)
7252 {
7253    GET_CURRENT_CONTEXT(ctx);
7254    Node *n;
7255    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7256    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64, 8);
7257    if (n) {
7258       n[1].ui = program;
7259       n[2].i = location;
7260       ASSIGN_INT64_TO_NODES(n, 3, x);
7261       ASSIGN_INT64_TO_NODES(n, 5, y);
7262       ASSIGN_INT64_TO_NODES(n, 7, z);
7263    }
7264    if (ctx->ExecuteFlag) {
7265       CALL_ProgramUniform3i64ARB(ctx->Exec, (program, location, x, y, z));
7266    }
7267 }
7268
7269 void GLAPIENTRY
7270 save_ProgramUniform4i64ARB(GLuint program, GLint location, GLint64 x,
7271                            GLint64 y, GLint64 z, GLint64 w)
7272 {
7273    GET_CURRENT_CONTEXT(ctx);
7274    Node *n;
7275    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7276    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I64, 10);
7277    if (n) {
7278       n[1].ui = program;
7279       n[2].i = location;
7280       ASSIGN_INT64_TO_NODES(n, 3, x);
7281       ASSIGN_INT64_TO_NODES(n, 5, y);
7282       ASSIGN_INT64_TO_NODES(n, 7, z);
7283       ASSIGN_INT64_TO_NODES(n, 9, w);
7284    }
7285    if (ctx->ExecuteFlag) {
7286       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7287    }
7288 }
7289
7290 void GLAPIENTRY
7291 save_ProgramUniform1i64vARB(GLuint program, GLint location, GLsizei count,
7292                             const GLint64 *v)
7293 {
7294    GET_CURRENT_CONTEXT(ctx);
7295    Node *n;
7296    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7297    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I64V, 3 + POINTER_DWORDS);
7298    if (n) {
7299       n[1].ui = program;
7300       n[2].i = location;
7301       n[3].i = count;
7302       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7303    }
7304    if (ctx->ExecuteFlag) {
7305       CALL_ProgramUniform1i64vARB(ctx->Exec, (program, location, count, v));
7306    }
7307 }
7308
7309 void GLAPIENTRY
7310 save_ProgramUniform2i64vARB(GLuint program, GLint location, GLsizei count,
7311                             const GLint64 *v)
7312 {
7313    GET_CURRENT_CONTEXT(ctx);
7314    Node *n;
7315    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7316    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64V, 3 + POINTER_DWORDS);
7317    if (n) {
7318       n[1].ui = program;
7319       n[2].i = location;
7320       n[3].i = count;
7321       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7322    }
7323    if (ctx->ExecuteFlag) {
7324       CALL_ProgramUniform2i64vARB(ctx->Exec, (program, location, count, v));
7325    }
7326 }
7327
7328 void GLAPIENTRY
7329 save_ProgramUniform3i64vARB(GLuint program, GLint location, GLsizei count,
7330                             const GLint64 *v)
7331 {
7332    GET_CURRENT_CONTEXT(ctx);
7333    Node *n;
7334    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7335    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64V, 3 + POINTER_DWORDS);
7336    if (n) {
7337       n[1].ui = program;
7338       n[2].i = location;
7339       n[3].i = count;
7340       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7341    }
7342    if (ctx->ExecuteFlag) {
7343       CALL_ProgramUniform3i64vARB(ctx->Exec, (program, location, count, v));
7344    }
7345 }
7346
7347 void GLAPIENTRY
7348 save_ProgramUniform4i64vARB(GLuint program, GLint location, GLsizei count,
7349                             const GLint64 *v)
7350 {
7351    GET_CURRENT_CONTEXT(ctx);
7352    Node *n;
7353    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7354    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I64V, 3 + POINTER_DWORDS);
7355    if (n) {
7356       n[1].ui = program;
7357       n[2].i = location;
7358       n[3].i = count;
7359       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7360    }
7361    if (ctx->ExecuteFlag) {
7362       CALL_ProgramUniform4i64vARB(ctx->Exec, (program, location, count, v));
7363    }
7364 }
7365
7366 void GLAPIENTRY
7367 save_ProgramUniform1ui64ARB(GLuint program, GLint location, GLuint64 x)
7368 {
7369    GET_CURRENT_CONTEXT(ctx);
7370    Node *n;
7371    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7372    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64, 4);
7373    if (n) {
7374       n[1].ui = program;
7375       n[2].i = location;
7376       ASSIGN_UINT64_TO_NODES(n, 3, x);
7377    }
7378    if (ctx->ExecuteFlag) {
7379       CALL_ProgramUniform1ui64ARB(ctx->Exec, (program, location, x));
7380    }
7381 }
7382
7383 void GLAPIENTRY
7384 save_ProgramUniform2ui64ARB(GLuint program, GLint location, GLuint64 x,
7385                             GLuint64 y)
7386 {
7387    GET_CURRENT_CONTEXT(ctx);
7388    Node *n;
7389    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7390    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI64, 6);
7391    if (n) {
7392       n[1].ui = program;
7393       n[2].i = location;
7394       ASSIGN_UINT64_TO_NODES(n, 3, x);
7395       ASSIGN_UINT64_TO_NODES(n, 5, y);
7396    }
7397    if (ctx->ExecuteFlag) {
7398       CALL_ProgramUniform2ui64ARB(ctx->Exec, (program, location, x, y));
7399    }
7400 }
7401
7402 void GLAPIENTRY
7403 save_ProgramUniform3ui64ARB(GLuint program, GLint location, GLuint64 x,
7404                             GLuint64 y, GLuint64 z)
7405 {
7406    GET_CURRENT_CONTEXT(ctx);
7407    Node *n;
7408    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7409    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI64, 8);
7410    if (n) {
7411       n[1].ui = program;
7412       n[2].i = location;
7413       ASSIGN_UINT64_TO_NODES(n, 3, x);
7414       ASSIGN_UINT64_TO_NODES(n, 5, y);
7415       ASSIGN_UINT64_TO_NODES(n, 7, z);
7416    }
7417    if (ctx->ExecuteFlag) {
7418       CALL_ProgramUniform3ui64ARB(ctx->Exec, (program, location, x, y, z));
7419    }
7420 }
7421
7422 void GLAPIENTRY
7423 save_ProgramUniform4ui64ARB(GLuint program, GLint location, GLuint64 x,
7424                             GLuint64 y, GLuint64 z, GLuint64 w)
7425 {
7426    GET_CURRENT_CONTEXT(ctx);
7427    Node *n;
7428    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7429    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64, 10);
7430    if (n) {
7431       n[1].ui = program;
7432       n[2].i = location;
7433       ASSIGN_UINT64_TO_NODES(n, 3, x);
7434       ASSIGN_UINT64_TO_NODES(n, 5, y);
7435       ASSIGN_UINT64_TO_NODES(n, 7, z);
7436       ASSIGN_UINT64_TO_NODES(n, 9, w);
7437    }
7438    if (ctx->ExecuteFlag) {
7439       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7440    }
7441 }
7442
7443 void GLAPIENTRY
7444 save_ProgramUniform1ui64vARB(GLuint program, GLint location, GLsizei count,
7445                              const GLuint64 *v)
7446 {
7447    GET_CURRENT_CONTEXT(ctx);
7448    Node *n;
7449    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7450    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64V,
7451                          3 + POINTER_DWORDS);
7452    if (n) {
7453       n[1].ui = program;
7454       n[2].i = location;
7455       n[3].i = count;
7456       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7457    }
7458    if (ctx->ExecuteFlag) {
7459       CALL_ProgramUniform1ui64vARB(ctx->Exec, (program, location, count, v));
7460    }
7461 }
7462
7463 void GLAPIENTRY
7464 save_ProgramUniform2ui64vARB(GLuint program, GLint location, GLsizei count,
7465                             const GLuint64 *v)
7466 {
7467    GET_CURRENT_CONTEXT(ctx);
7468    Node *n;
7469    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7470    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI64V,
7471                          3 + POINTER_DWORDS);
7472    if (n) {
7473       n[1].ui = program;
7474       n[2].i = location;
7475       n[3].i = count;
7476       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7477    }
7478    if (ctx->ExecuteFlag) {
7479       CALL_ProgramUniform2ui64vARB(ctx->Exec, (program, location, count, v));
7480    }
7481 }
7482
7483 void GLAPIENTRY
7484 save_ProgramUniform3ui64vARB(GLuint program, GLint location, GLsizei count,
7485                              const GLuint64 *v)
7486 {
7487    GET_CURRENT_CONTEXT(ctx);
7488    Node *n;
7489    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7490    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI64V,
7491                          3 + POINTER_DWORDS);
7492    if (n) {
7493       n[1].ui = program;
7494       n[2].i = location;
7495       n[3].i = count;
7496       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7497    }
7498    if (ctx->ExecuteFlag) {
7499       CALL_ProgramUniform3ui64vARB(ctx->Exec, (program, location, count, v));
7500    }
7501 }
7502
7503 void GLAPIENTRY
7504 save_ProgramUniform4ui64vARB(GLuint program, GLint location, GLsizei count,
7505                              const GLuint64 *v)
7506 {
7507    GET_CURRENT_CONTEXT(ctx);
7508    Node *n;
7509    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7510    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64V,
7511                          3 + POINTER_DWORDS);
7512    if (n) {
7513       n[1].ui = program;
7514       n[2].i = location;
7515       n[3].i = count;
7516       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7517    }
7518    if (ctx->ExecuteFlag) {
7519       CALL_ProgramUniform4ui64vARB(ctx->Exec, (program, location, count, v));
7520    }
7521 }
7522
7523
7524 void GLAPIENTRY
7525 save_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
7526 {
7527    GET_CURRENT_CONTEXT(ctx);
7528    Node *n;
7529    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7530    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM_STAGES, 3);
7531    if (n) {
7532       n[1].ui = pipeline;
7533       n[2].ui = stages;
7534       n[3].ui = program;
7535    }
7536    if (ctx->ExecuteFlag) {
7537       CALL_UseProgramStages(ctx->Exec, (pipeline, stages, program));
7538    }
7539 }
7540
7541 void GLAPIENTRY
7542 save_ProgramUniform1f(GLuint program, GLint location, GLfloat x)
7543 {
7544    GET_CURRENT_CONTEXT(ctx);
7545    Node *n;
7546    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7547    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1F, 3);
7548    if (n) {
7549       n[1].ui = program;
7550       n[2].i = location;
7551       n[3].f = x;
7552    }
7553    if (ctx->ExecuteFlag) {
7554       CALL_ProgramUniform1f(ctx->Exec, (program, location, x));
7555    }
7556 }
7557
7558 void GLAPIENTRY
7559 save_ProgramUniform2f(GLuint program, GLint location, GLfloat x, GLfloat y)
7560 {
7561    GET_CURRENT_CONTEXT(ctx);
7562    Node *n;
7563    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7564    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2F, 4);
7565    if (n) {
7566       n[1].ui = program;
7567       n[2].i = location;
7568       n[3].f = x;
7569       n[4].f = y;
7570    }
7571    if (ctx->ExecuteFlag) {
7572       CALL_ProgramUniform2f(ctx->Exec, (program, location, x, y));
7573    }
7574 }
7575
7576 void GLAPIENTRY
7577 save_ProgramUniform3f(GLuint program, GLint location,
7578                       GLfloat x, GLfloat y, GLfloat z)
7579 {
7580    GET_CURRENT_CONTEXT(ctx);
7581    Node *n;
7582    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7583    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3F, 5);
7584    if (n) {
7585       n[1].ui = program;
7586       n[2].i = location;
7587       n[3].f = x;
7588       n[4].f = y;
7589       n[5].f = z;
7590    }
7591    if (ctx->ExecuteFlag) {
7592       CALL_ProgramUniform3f(ctx->Exec, (program, location, x, y, z));
7593    }
7594 }
7595
7596 void GLAPIENTRY
7597 save_ProgramUniform4f(GLuint program, GLint location,
7598                       GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7599 {
7600    GET_CURRENT_CONTEXT(ctx);
7601    Node *n;
7602    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7603    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4F, 6);
7604    if (n) {
7605       n[1].ui = program;
7606       n[2].i = location;
7607       n[3].f = x;
7608       n[4].f = y;
7609       n[5].f = z;
7610       n[6].f = w;
7611    }
7612    if (ctx->ExecuteFlag) {
7613       CALL_ProgramUniform4f(ctx->Exec, (program, location, x, y, z, w));
7614    }
7615 }
7616
7617 void GLAPIENTRY
7618 save_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
7619                        const GLfloat *v)
7620 {
7621    GET_CURRENT_CONTEXT(ctx);
7622    Node *n;
7623    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7624    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1FV, 3 + POINTER_DWORDS);
7625    if (n) {
7626       n[1].ui = program;
7627       n[2].i = location;
7628       n[3].i = count;
7629       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLfloat)));
7630    }
7631    if (ctx->ExecuteFlag) {
7632       CALL_ProgramUniform1fv(ctx->Exec, (program, location, count, v));
7633    }
7634 }
7635
7636 void GLAPIENTRY
7637 save_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
7638                        const GLfloat *v)
7639 {
7640    GET_CURRENT_CONTEXT(ctx);
7641    Node *n;
7642    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7643    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2FV, 3 + POINTER_DWORDS);
7644    if (n) {
7645       n[1].ui = program;
7646       n[2].i = location;
7647       n[3].i = count;
7648       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLfloat)));
7649    }
7650    if (ctx->ExecuteFlag) {
7651       CALL_ProgramUniform2fv(ctx->Exec, (program, location, count, v));
7652    }
7653 }
7654
7655 void GLAPIENTRY
7656 save_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
7657                        const GLfloat *v)
7658 {
7659    GET_CURRENT_CONTEXT(ctx);
7660    Node *n;
7661    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7662    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3FV, 3 + POINTER_DWORDS);
7663    if (n) {
7664       n[1].ui = program;
7665       n[2].i = location;
7666       n[3].i = count;
7667       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLfloat)));
7668    }
7669    if (ctx->ExecuteFlag) {
7670       CALL_ProgramUniform3fv(ctx->Exec, (program, location, count, v));
7671    }
7672 }
7673
7674 void GLAPIENTRY
7675 save_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
7676                        const GLfloat *v)
7677 {
7678    GET_CURRENT_CONTEXT(ctx);
7679    Node *n;
7680    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7681    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4FV, 3 + POINTER_DWORDS);
7682    if (n) {
7683       n[1].ui = program;
7684       n[2].i = location;
7685       n[3].i = count;
7686       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLfloat)));
7687    }
7688    if (ctx->ExecuteFlag) {
7689       CALL_ProgramUniform4fv(ctx->Exec, (program, location, count, v));
7690    }
7691 }
7692
7693 void GLAPIENTRY
7694 save_ProgramUniform1d(GLuint program, GLint location, GLdouble x)
7695 {
7696    GET_CURRENT_CONTEXT(ctx);
7697    Node *n;
7698    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7699    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1D, 4);
7700    if (n) {
7701       n[1].ui = program;
7702       n[2].i = location;
7703       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
7704    }
7705    if (ctx->ExecuteFlag) {
7706       CALL_ProgramUniform1d(ctx->Exec, (program, location, x));
7707    }
7708 }
7709
7710 void GLAPIENTRY
7711 save_ProgramUniform2d(GLuint program, GLint location, GLdouble x, GLdouble y)
7712 {
7713    GET_CURRENT_CONTEXT(ctx);
7714    Node *n;
7715    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7716    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2D, 6);
7717    if (n) {
7718       n[1].ui = program;
7719       n[2].i = location;
7720       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
7721       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
7722    }
7723    if (ctx->ExecuteFlag) {
7724       CALL_ProgramUniform2d(ctx->Exec, (program, location, x, y));
7725    }
7726 }
7727
7728 void GLAPIENTRY
7729 save_ProgramUniform3d(GLuint program, GLint location,
7730                       GLdouble x, GLdouble y, GLdouble z)
7731 {
7732    GET_CURRENT_CONTEXT(ctx);
7733    Node *n;
7734    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7735    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3D, 8);
7736    if (n) {
7737       n[1].ui = program;
7738       n[2].i = location;
7739       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
7740       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
7741       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
7742    }
7743    if (ctx->ExecuteFlag) {
7744       CALL_ProgramUniform3d(ctx->Exec, (program, location, x, y, z));
7745    }
7746 }
7747
7748 void GLAPIENTRY
7749 save_ProgramUniform4d(GLuint program, GLint location,
7750                       GLdouble x, GLdouble y, GLdouble z, GLdouble w)
7751 {
7752    GET_CURRENT_CONTEXT(ctx);
7753    Node *n;
7754    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7755    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4D, 10);
7756    if (n) {
7757       n[1].ui = program;
7758       n[2].i = location;
7759       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
7760       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
7761       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
7762       ASSIGN_DOUBLE_TO_NODES(n, 9, w);
7763    }
7764    if (ctx->ExecuteFlag) {
7765       CALL_ProgramUniform4d(ctx->Exec, (program, location, x, y, z, w));
7766    }
7767 }
7768
7769 void GLAPIENTRY
7770 save_ProgramUniform1dv(GLuint program, GLint location, GLsizei count,
7771                        const GLdouble *v)
7772 {
7773    GET_CURRENT_CONTEXT(ctx);
7774    Node *n;
7775    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7776    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1DV, 3 + POINTER_DWORDS);
7777    if (n) {
7778       n[1].ui = program;
7779       n[2].i = location;
7780       n[3].i = count;
7781       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLdouble)));
7782    }
7783    if (ctx->ExecuteFlag) {
7784       CALL_ProgramUniform1dv(ctx->Exec, (program, location, count, v));
7785    }
7786 }
7787
7788 void GLAPIENTRY
7789 save_ProgramUniform2dv(GLuint program, GLint location, GLsizei count,
7790                        const GLdouble *v)
7791 {
7792    GET_CURRENT_CONTEXT(ctx);
7793    Node *n;
7794    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7795    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2DV, 3 + POINTER_DWORDS);
7796    if (n) {
7797       n[1].ui = program;
7798       n[2].i = location;
7799       n[3].i = count;
7800       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLdouble)));
7801    }
7802    if (ctx->ExecuteFlag) {
7803       CALL_ProgramUniform2dv(ctx->Exec, (program, location, count, v));
7804    }
7805 }
7806
7807 void GLAPIENTRY
7808 save_ProgramUniform3dv(GLuint program, GLint location, GLsizei count,
7809                        const GLdouble *v)
7810 {
7811    GET_CURRENT_CONTEXT(ctx);
7812    Node *n;
7813    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7814    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3DV, 3 + POINTER_DWORDS);
7815    if (n) {
7816       n[1].ui = program;
7817       n[2].i = location;
7818       n[3].i = count;
7819       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLdouble)));
7820    }
7821    if (ctx->ExecuteFlag) {
7822       CALL_ProgramUniform3dv(ctx->Exec, (program, location, count, v));
7823    }
7824 }
7825
7826 void GLAPIENTRY
7827 save_ProgramUniform4dv(GLuint program, GLint location, GLsizei count,
7828                        const GLdouble *v)
7829 {
7830    GET_CURRENT_CONTEXT(ctx);
7831    Node *n;
7832    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7833    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4DV, 3 + POINTER_DWORDS);
7834    if (n) {
7835       n[1].ui = program;
7836       n[2].i = location;
7837       n[3].i = count;
7838       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLdouble)));
7839    }
7840    if (ctx->ExecuteFlag) {
7841       CALL_ProgramUniform4dv(ctx->Exec, (program, location, count, v));
7842    }
7843 }
7844
7845 void GLAPIENTRY
7846 save_ProgramUniform1i(GLuint program, GLint location, GLint x)
7847 {
7848    GET_CURRENT_CONTEXT(ctx);
7849    Node *n;
7850    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7851    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I, 3);
7852    if (n) {
7853       n[1].ui = program;
7854       n[2].i = location;
7855       n[3].i = x;
7856    }
7857    if (ctx->ExecuteFlag) {
7858       CALL_ProgramUniform1i(ctx->Exec, (program, location, x));
7859    }
7860 }
7861
7862 void GLAPIENTRY
7863 save_ProgramUniform2i(GLuint program, GLint location, GLint x, GLint y)
7864 {
7865    GET_CURRENT_CONTEXT(ctx);
7866    Node *n;
7867    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7868    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I, 4);
7869    if (n) {
7870       n[1].ui = program;
7871       n[2].i = location;
7872       n[3].i = x;
7873       n[4].i = y;
7874    }
7875    if (ctx->ExecuteFlag) {
7876       CALL_ProgramUniform2i(ctx->Exec, (program, location, x, y));
7877    }
7878 }
7879
7880 void GLAPIENTRY
7881 save_ProgramUniform3i(GLuint program, GLint location,
7882                       GLint x, GLint y, GLint z)
7883 {
7884    GET_CURRENT_CONTEXT(ctx);
7885    Node *n;
7886    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7887    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I, 5);
7888    if (n) {
7889       n[1].ui = program;
7890       n[2].i = location;
7891       n[3].i = x;
7892       n[4].i = y;
7893       n[5].i = z;
7894    }
7895    if (ctx->ExecuteFlag) {
7896       CALL_ProgramUniform3i(ctx->Exec, (program, location, x, y, z));
7897    }
7898 }
7899
7900 void GLAPIENTRY
7901 save_ProgramUniform4i(GLuint program, GLint location,
7902                       GLint x, GLint y, GLint z, GLint w)
7903 {
7904    GET_CURRENT_CONTEXT(ctx);
7905    Node *n;
7906    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7907    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I, 6);
7908    if (n) {
7909       n[1].ui = program;
7910       n[2].i = location;
7911       n[3].i = x;
7912       n[4].i = y;
7913       n[5].i = z;
7914       n[6].i = w;
7915    }
7916    if (ctx->ExecuteFlag) {
7917       CALL_ProgramUniform4i(ctx->Exec, (program, location, x, y, z, w));
7918    }
7919 }
7920
7921 void GLAPIENTRY
7922 save_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
7923                        const GLint *v)
7924 {
7925    GET_CURRENT_CONTEXT(ctx);
7926    Node *n;
7927    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7928    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1IV, 3 + POINTER_DWORDS);
7929    if (n) {
7930       n[1].ui = program;
7931       n[2].i = location;
7932       n[3].i = count;
7933       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint)));
7934    }
7935    if (ctx->ExecuteFlag) {
7936       CALL_ProgramUniform1iv(ctx->Exec, (program, location, count, v));
7937    }
7938 }
7939
7940 void GLAPIENTRY
7941 save_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
7942                        const GLint *v)
7943 {
7944    GET_CURRENT_CONTEXT(ctx);
7945    Node *n;
7946    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7947    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2IV, 3 + POINTER_DWORDS);
7948    if (n) {
7949       n[1].ui = program;
7950       n[2].i = location;
7951       n[3].i = count;
7952       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLint)));
7953    }
7954    if (ctx->ExecuteFlag) {
7955       CALL_ProgramUniform2iv(ctx->Exec, (program, location, count, v));
7956    }
7957 }
7958
7959 void GLAPIENTRY
7960 save_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
7961                        const GLint *v)
7962 {
7963    GET_CURRENT_CONTEXT(ctx);
7964    Node *n;
7965    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7966    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3IV, 3 + POINTER_DWORDS);
7967    if (n) {
7968       n[1].ui = program;
7969       n[2].i = location;
7970       n[3].i = count;
7971       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLint)));
7972    }
7973    if (ctx->ExecuteFlag) {
7974       CALL_ProgramUniform3iv(ctx->Exec, (program, location, count, v));
7975    }
7976 }
7977
7978 void GLAPIENTRY
7979 save_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
7980                        const GLint *v)
7981 {
7982    GET_CURRENT_CONTEXT(ctx);
7983    Node *n;
7984    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7985    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4IV, 3 + POINTER_DWORDS);
7986    if (n) {
7987       n[1].ui = program;
7988       n[2].i = location;
7989       n[3].i = count;
7990       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLint)));
7991    }
7992    if (ctx->ExecuteFlag) {
7993       CALL_ProgramUniform4iv(ctx->Exec, (program, location, count, v));
7994    }
7995 }
7996
7997 void GLAPIENTRY
7998 save_ProgramUniform1ui(GLuint program, GLint location, GLuint x)
7999 {
8000    GET_CURRENT_CONTEXT(ctx);
8001    Node *n;
8002    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8003    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI, 3);
8004    if (n) {
8005       n[1].ui = program;
8006       n[2].i = location;
8007       n[3].ui = x;
8008    }
8009    if (ctx->ExecuteFlag) {
8010       CALL_ProgramUniform1ui(ctx->Exec, (program, location, x));
8011    }
8012 }
8013
8014 void GLAPIENTRY
8015 save_ProgramUniform2ui(GLuint program, GLint location, GLuint x, GLuint y)
8016 {
8017    GET_CURRENT_CONTEXT(ctx);
8018    Node *n;
8019    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8020    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI, 4);
8021    if (n) {
8022       n[1].ui = program;
8023       n[2].i = location;
8024       n[3].ui = x;
8025       n[4].ui = y;
8026    }
8027    if (ctx->ExecuteFlag) {
8028       CALL_ProgramUniform2ui(ctx->Exec, (program, location, x, y));
8029    }
8030 }
8031
8032 void GLAPIENTRY
8033 save_ProgramUniform3ui(GLuint program, GLint location,
8034                        GLuint x, GLuint y, GLuint z)
8035 {
8036    GET_CURRENT_CONTEXT(ctx);
8037    Node *n;
8038    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8039    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI, 5);
8040    if (n) {
8041       n[1].ui = program;
8042       n[2].i = location;
8043       n[3].ui = x;
8044       n[4].ui = y;
8045       n[5].ui = z;
8046    }
8047    if (ctx->ExecuteFlag) {
8048       CALL_ProgramUniform3ui(ctx->Exec, (program, location, x, y, z));
8049    }
8050 }
8051
8052 void GLAPIENTRY
8053 save_ProgramUniform4ui(GLuint program, GLint location,
8054                        GLuint x, GLuint y, GLuint z, GLuint w)
8055 {
8056    GET_CURRENT_CONTEXT(ctx);
8057    Node *n;
8058    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8059    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI, 6);
8060    if (n) {
8061       n[1].ui = program;
8062       n[2].i = location;
8063       n[3].ui = x;
8064       n[4].ui = y;
8065       n[5].ui = z;
8066       n[6].ui = w;
8067    }
8068    if (ctx->ExecuteFlag) {
8069       CALL_ProgramUniform4ui(ctx->Exec, (program, location, x, y, z, w));
8070    }
8071 }
8072
8073 void GLAPIENTRY
8074 save_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
8075                         const GLuint *v)
8076 {
8077    GET_CURRENT_CONTEXT(ctx);
8078    Node *n;
8079    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8080    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UIV, 3 + POINTER_DWORDS);
8081    if (n) {
8082       n[1].ui = program;
8083       n[2].i = location;
8084       n[3].i = count;
8085       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint)));
8086    }
8087    if (ctx->ExecuteFlag) {
8088       CALL_ProgramUniform1uiv(ctx->Exec, (program, location, count, v));
8089    }
8090 }
8091
8092 void GLAPIENTRY
8093 save_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
8094                         const GLuint *v)
8095 {
8096    GET_CURRENT_CONTEXT(ctx);
8097    Node *n;
8098    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8099    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UIV, 3 + POINTER_DWORDS);
8100    if (n) {
8101       n[1].ui = program;
8102       n[2].i = location;
8103       n[3].i = count;
8104       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLuint)));
8105    }
8106    if (ctx->ExecuteFlag) {
8107       CALL_ProgramUniform2uiv(ctx->Exec, (program, location, count, v));
8108    }
8109 }
8110
8111 void GLAPIENTRY
8112 save_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
8113                         const GLuint *v)
8114 {
8115    GET_CURRENT_CONTEXT(ctx);
8116    Node *n;
8117    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8118    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UIV, 3 + POINTER_DWORDS);
8119    if (n) {
8120       n[1].ui = program;
8121       n[2].i = location;
8122       n[3].i = count;
8123       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLuint)));
8124    }
8125    if (ctx->ExecuteFlag) {
8126       CALL_ProgramUniform3uiv(ctx->Exec, (program, location, count, v));
8127    }
8128 }
8129
8130 void GLAPIENTRY
8131 save_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
8132                         const GLuint *v)
8133 {
8134    GET_CURRENT_CONTEXT(ctx);
8135    Node *n;
8136    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8137    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UIV, 3 + POINTER_DWORDS);
8138    if (n) {
8139       n[1].ui = program;
8140       n[2].i = location;
8141       n[3].i = count;
8142       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLuint)));
8143    }
8144    if (ctx->ExecuteFlag) {
8145       CALL_ProgramUniform4uiv(ctx->Exec, (program, location, count, v));
8146    }
8147 }
8148
8149 void GLAPIENTRY
8150 save_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count,
8151                              GLboolean transpose, const GLfloat *v)
8152 {
8153    GET_CURRENT_CONTEXT(ctx);
8154    Node *n;
8155    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8156    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22F,
8157                          4 + POINTER_DWORDS);
8158    if (n) {
8159       n[1].ui = program;
8160       n[2].i = location;
8161       n[3].i = count;
8162       n[4].b = transpose;
8163       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLfloat)));
8164    }
8165    if (ctx->ExecuteFlag) {
8166       CALL_ProgramUniformMatrix2fv(ctx->Exec,
8167                                    (program, location, count, transpose, v));
8168    }
8169 }
8170
8171 void GLAPIENTRY
8172 save_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count,
8173                                GLboolean transpose, const GLfloat *v)
8174 {
8175    GET_CURRENT_CONTEXT(ctx);
8176    Node *n;
8177    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8178    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23F,
8179                          4 + POINTER_DWORDS);
8180    if (n) {
8181       n[1].ui = program;
8182       n[2].i = location;
8183       n[3].i = count;
8184       n[4].b = transpose;
8185       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLfloat)));
8186    }
8187    if (ctx->ExecuteFlag) {
8188       CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
8189                                      (program, location, count, transpose, v));
8190    }
8191 }
8192
8193 void GLAPIENTRY
8194 save_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count,
8195                                GLboolean transpose, const GLfloat *v)
8196 {
8197    GET_CURRENT_CONTEXT(ctx);
8198    Node *n;
8199    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8200    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24F,
8201                          4 + POINTER_DWORDS);
8202    if (n) {
8203       n[1].ui = program;
8204       n[2].i = location;
8205       n[3].i = count;
8206       n[4].b = transpose;
8207       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLfloat)));
8208    }
8209    if (ctx->ExecuteFlag) {
8210       CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
8211                                      (program, location, count, transpose, v));
8212    }
8213 }
8214
8215 void GLAPIENTRY
8216 save_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count,
8217                                GLboolean transpose, const GLfloat *v)
8218 {
8219    GET_CURRENT_CONTEXT(ctx);
8220    Node *n;
8221    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8222    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32F,
8223                          4 + POINTER_DWORDS);
8224    if (n) {
8225       n[1].ui = program;
8226       n[2].i = location;
8227       n[3].i = count;
8228       n[4].b = transpose;
8229       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLfloat)));
8230    }
8231    if (ctx->ExecuteFlag) {
8232       CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
8233                                      (program, location, count, transpose, v));
8234    }
8235 }
8236
8237 void GLAPIENTRY
8238 save_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count,
8239                              GLboolean transpose, const GLfloat *v)
8240 {
8241    GET_CURRENT_CONTEXT(ctx);
8242    Node *n;
8243    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8244    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33F,
8245                          4 + POINTER_DWORDS);
8246    if (n) {
8247       n[1].ui = program;
8248       n[2].i = location;
8249       n[3].i = count;
8250       n[4].b = transpose;
8251       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLfloat)));
8252    }
8253    if (ctx->ExecuteFlag) {
8254       CALL_ProgramUniformMatrix3fv(ctx->Exec,
8255                                    (program, location, count, transpose, v));
8256    }
8257 }
8258
8259 void GLAPIENTRY
8260 save_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count,
8261                                GLboolean transpose, const GLfloat *v)
8262 {
8263    GET_CURRENT_CONTEXT(ctx);
8264    Node *n;
8265    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8266    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34F,
8267                          4 + POINTER_DWORDS);
8268    if (n) {
8269       n[1].ui = program;
8270       n[2].i = location;
8271       n[3].i = count;
8272       n[4].b = transpose;
8273       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLfloat)));
8274    }
8275    if (ctx->ExecuteFlag) {
8276       CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
8277                                      (program, location, count, transpose, v));
8278    }
8279 }
8280
8281 void GLAPIENTRY
8282 save_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count,
8283                                GLboolean transpose, const GLfloat *v)
8284 {
8285    GET_CURRENT_CONTEXT(ctx);
8286    Node *n;
8287    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8288    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42F,
8289                          4 + POINTER_DWORDS);
8290    if (n) {
8291       n[1].ui = program;
8292       n[2].i = location;
8293       n[3].i = count;
8294       n[4].b = transpose;
8295       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLfloat)));
8296    }
8297    if (ctx->ExecuteFlag) {
8298       CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
8299                                      (program, location, count, transpose, v));
8300    }
8301 }
8302
8303 void GLAPIENTRY
8304 save_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count,
8305                                GLboolean transpose, const GLfloat *v)
8306 {
8307    GET_CURRENT_CONTEXT(ctx);
8308    Node *n;
8309    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8310    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43F,
8311                          4 + POINTER_DWORDS);
8312    if (n) {
8313       n[1].ui = program;
8314       n[2].i = location;
8315       n[3].i = count;
8316       n[4].b = transpose;
8317       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLfloat)));
8318    }
8319    if (ctx->ExecuteFlag) {
8320       CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
8321                                      (program, location, count, transpose, v));
8322    }
8323 }
8324
8325 void GLAPIENTRY
8326 save_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count,
8327                              GLboolean transpose, const GLfloat *v)
8328 {
8329    GET_CURRENT_CONTEXT(ctx);
8330    Node *n;
8331    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8332    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44F,
8333                          4 + POINTER_DWORDS);
8334    if (n) {
8335       n[1].ui = program;
8336       n[2].i = location;
8337       n[3].i = count;
8338       n[4].b = transpose;
8339       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLfloat)));
8340    }
8341    if (ctx->ExecuteFlag) {
8342       CALL_ProgramUniformMatrix4fv(ctx->Exec,
8343                                    (program, location, count, transpose, v));
8344    }
8345 }
8346
8347 void GLAPIENTRY
8348 save_ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count,
8349                              GLboolean transpose, const GLdouble *v)
8350 {
8351    GET_CURRENT_CONTEXT(ctx);
8352    Node *n;
8353    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8354    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22D,
8355                          4 + POINTER_DWORDS);
8356    if (n) {
8357       n[1].ui = program;
8358       n[2].i = location;
8359       n[3].i = count;
8360       n[4].b = transpose;
8361       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLdouble)));
8362    }
8363    if (ctx->ExecuteFlag) {
8364       CALL_ProgramUniformMatrix2dv(ctx->Exec,
8365                                    (program, location, count, transpose, v));
8366    }
8367 }
8368
8369 void GLAPIENTRY
8370 save_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count,
8371                                GLboolean transpose, const GLdouble *v)
8372 {
8373    GET_CURRENT_CONTEXT(ctx);
8374    Node *n;
8375    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8376    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23D,
8377                          4 + POINTER_DWORDS);
8378    if (n) {
8379       n[1].ui = program;
8380       n[2].i = location;
8381       n[3].i = count;
8382       n[4].b = transpose;
8383       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLdouble)));
8384    }
8385    if (ctx->ExecuteFlag) {
8386       CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
8387                                      (program, location, count, transpose, v));
8388    }
8389 }
8390
8391 void GLAPIENTRY
8392 save_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count,
8393                                GLboolean transpose, const GLdouble *v)
8394 {
8395    GET_CURRENT_CONTEXT(ctx);
8396    Node *n;
8397    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8398    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24D,
8399                          4 + POINTER_DWORDS);
8400    if (n) {
8401       n[1].ui = program;
8402       n[2].i = location;
8403       n[3].i = count;
8404       n[4].b = transpose;
8405       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLdouble)));
8406    }
8407    if (ctx->ExecuteFlag) {
8408       CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
8409                                      (program, location, count, transpose, v));
8410    }
8411 }
8412
8413 void GLAPIENTRY
8414 save_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count,
8415                                GLboolean transpose, const GLdouble *v)
8416 {
8417    GET_CURRENT_CONTEXT(ctx);
8418    Node *n;
8419    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8420    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32D,
8421                          4 + POINTER_DWORDS);
8422    if (n) {
8423       n[1].ui = program;
8424       n[2].i = location;
8425       n[3].i = count;
8426       n[4].b = transpose;
8427       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLdouble)));
8428    }
8429    if (ctx->ExecuteFlag) {
8430       CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
8431                                      (program, location, count, transpose, v));
8432    }
8433 }
8434
8435 void GLAPIENTRY
8436 save_ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count,
8437                              GLboolean transpose, const GLdouble *v)
8438 {
8439    GET_CURRENT_CONTEXT(ctx);
8440    Node *n;
8441    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8442    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33D,
8443                          4 + POINTER_DWORDS);
8444    if (n) {
8445       n[1].ui = program;
8446       n[2].i = location;
8447       n[3].i = count;
8448       n[4].b = transpose;
8449       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLdouble)));
8450    }
8451    if (ctx->ExecuteFlag) {
8452       CALL_ProgramUniformMatrix3dv(ctx->Exec,
8453                                    (program, location, count, transpose, v));
8454    }
8455 }
8456
8457 void GLAPIENTRY
8458 save_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count,
8459                                GLboolean transpose, const GLdouble *v)
8460 {
8461    GET_CURRENT_CONTEXT(ctx);
8462    Node *n;
8463    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8464    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34D,
8465                          4 + POINTER_DWORDS);
8466    if (n) {
8467       n[1].ui = program;
8468       n[2].i = location;
8469       n[3].i = count;
8470       n[4].b = transpose;
8471       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLdouble)));
8472    }
8473    if (ctx->ExecuteFlag) {
8474       CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
8475                                      (program, location, count, transpose, v));
8476    }
8477 }
8478
8479 void GLAPIENTRY
8480 save_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count,
8481                                GLboolean transpose, const GLdouble *v)
8482 {
8483    GET_CURRENT_CONTEXT(ctx);
8484    Node *n;
8485    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8486    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42D,
8487                          4 + POINTER_DWORDS);
8488    if (n) {
8489       n[1].ui = program;
8490       n[2].i = location;
8491       n[3].i = count;
8492       n[4].b = transpose;
8493       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLdouble)));
8494    }
8495    if (ctx->ExecuteFlag) {
8496       CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
8497                                      (program, location, count, transpose, v));
8498    }
8499 }
8500
8501 void GLAPIENTRY
8502 save_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
8503                                GLboolean transpose, const GLdouble *v)
8504 {
8505    GET_CURRENT_CONTEXT(ctx);
8506    Node *n;
8507    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8508    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43D,
8509                          4 + POINTER_DWORDS);
8510    if (n) {
8511       n[1].ui = program;
8512       n[2].i = location;
8513       n[3].i = count;
8514       n[4].b = transpose;
8515       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLdouble)));
8516    }
8517    if (ctx->ExecuteFlag) {
8518       CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
8519                                      (program, location, count, transpose, v));
8520    }
8521 }
8522
8523 void GLAPIENTRY
8524 save_ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count,
8525                              GLboolean transpose, const GLdouble *v)
8526 {
8527    GET_CURRENT_CONTEXT(ctx);
8528    Node *n;
8529    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8530    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44D,
8531                          4 + POINTER_DWORDS);
8532    if (n) {
8533       n[1].ui = program;
8534       n[2].i = location;
8535       n[3].i = count;
8536       n[4].b = transpose;
8537       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLdouble)));
8538    }
8539    if (ctx->ExecuteFlag) {
8540       CALL_ProgramUniformMatrix4dv(ctx->Exec,
8541                                    (program, location, count, transpose, v));
8542    }
8543 }
8544
8545 void GLAPIENTRY
8546 save_ClipControl(GLenum origin, GLenum depth)
8547 {
8548    GET_CURRENT_CONTEXT(ctx);
8549    Node *n;
8550    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8551    n = alloc_instruction(ctx, OPCODE_CLIP_CONTROL, 2);
8552    if (n) {
8553       n[1].e = origin;
8554       n[2].e = depth;
8555    }
8556    if (ctx->ExecuteFlag) {
8557       CALL_ClipControl(ctx->Exec, (origin, depth));
8558    }
8559 }
8560
8561 void GLAPIENTRY
8562 save_ClampColor(GLenum target, GLenum clamp)
8563 {
8564    GET_CURRENT_CONTEXT(ctx);
8565    Node *n;
8566    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8567    n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2);
8568    if (n) {
8569       n[1].e = target;
8570       n[2].e = clamp;
8571    }
8572    if (ctx->ExecuteFlag) {
8573       CALL_ClampColor(ctx->Exec, (target, clamp));
8574    }
8575 }
8576
8577 /** GL_EXT_texture_integer */
8578 void GLAPIENTRY
8579 save_ClearColorIiEXT(GLint red, GLint green, GLint blue, GLint alpha)
8580 {
8581    GET_CURRENT_CONTEXT(ctx);
8582    Node *n;
8583    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8584    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4);
8585    if (n) {
8586       n[1].i = red;
8587       n[2].i = green;
8588       n[3].i = blue;
8589       n[4].i = alpha;
8590    }
8591    if (ctx->ExecuteFlag) {
8592       CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha));
8593    }
8594 }
8595
8596 /** GL_EXT_texture_integer */
8597 void GLAPIENTRY
8598 save_ClearColorIuiEXT(GLuint red, GLuint green, GLuint blue, GLuint alpha)
8599 {
8600    GET_CURRENT_CONTEXT(ctx);
8601    Node *n;
8602    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8603    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4);
8604    if (n) {
8605       n[1].ui = red;
8606       n[2].ui = green;
8607       n[3].ui = blue;
8608       n[4].ui = alpha;
8609    }
8610    if (ctx->ExecuteFlag) {
8611       CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha));
8612    }
8613 }
8614
8615 /** GL_EXT_texture_integer */
8616 void GLAPIENTRY
8617 save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
8618 {
8619    GET_CURRENT_CONTEXT(ctx);
8620    Node *n;
8621    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8622    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6);
8623    if (n) {
8624       n[1].e = target;
8625       n[2].e = pname;
8626       n[3].i = params[0];
8627       n[4].i = params[1];
8628       n[5].i = params[2];
8629       n[6].i = params[3];
8630    }
8631    if (ctx->ExecuteFlag) {
8632       CALL_TexParameterIiv(ctx->Exec, (target, pname, params));
8633    }
8634 }
8635
8636 /** GL_EXT_texture_integer */
8637 void GLAPIENTRY
8638 save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
8639 {
8640    GET_CURRENT_CONTEXT(ctx);
8641    Node *n;
8642    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8643    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6);
8644    if (n) {
8645       n[1].e = target;
8646       n[2].e = pname;
8647       n[3].ui = params[0];
8648       n[4].ui = params[1];
8649       n[5].ui = params[2];
8650       n[6].ui = params[3];
8651    }
8652    if (ctx->ExecuteFlag) {
8653       CALL_TexParameterIuiv(ctx->Exec, (target, pname, params));
8654    }
8655 }
8656
8657 /* GL_ARB_instanced_arrays */
8658 void GLAPIENTRY
8659 save_VertexAttribDivisor(GLuint index, GLuint divisor)
8660 {
8661    GET_CURRENT_CONTEXT(ctx);
8662    Node *n;
8663    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8664    n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2);
8665    if (n) {
8666       n[1].ui = index;
8667       n[2].ui = divisor;
8668    }
8669    if (ctx->ExecuteFlag) {
8670       CALL_VertexAttribDivisor(ctx->Exec, (index, divisor));
8671    }
8672 }
8673
8674
8675 /* GL_NV_texture_barrier */
8676 void GLAPIENTRY
8677 save_TextureBarrierNV(void)
8678 {
8679    GET_CURRENT_CONTEXT(ctx);
8680    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8681    alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0);
8682    if (ctx->ExecuteFlag) {
8683       CALL_TextureBarrierNV(ctx->Exec, ());
8684    }
8685 }
8686
8687
8688 /* GL_ARB_sampler_objects */
8689 void GLAPIENTRY
8690 save_BindSampler(GLuint unit, GLuint sampler)
8691 {
8692    Node *n;
8693    GET_CURRENT_CONTEXT(ctx);
8694    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8695    n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2);
8696    if (n) {
8697       n[1].ui = unit;
8698       n[2].ui = sampler;
8699    }
8700    if (ctx->ExecuteFlag) {
8701       CALL_BindSampler(ctx->Exec, (unit, sampler));
8702    }
8703 }
8704
8705 void GLAPIENTRY
8706 save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
8707 {
8708    Node *n;
8709    GET_CURRENT_CONTEXT(ctx);
8710    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8711    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6);
8712    if (n) {
8713       n[1].ui = sampler;
8714       n[2].e = pname;
8715       n[3].i = params[0];
8716       if (pname == GL_TEXTURE_BORDER_COLOR) {
8717          n[4].i = params[1];
8718          n[5].i = params[2];
8719          n[6].i = params[3];
8720       }
8721       else {
8722          n[4].i = n[5].i = n[6].i = 0;
8723       }
8724    }
8725    if (ctx->ExecuteFlag) {
8726       CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params));
8727    }
8728 }
8729
8730 void GLAPIENTRY
8731 save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
8732 {
8733    GLint parray[4];
8734    parray[0] = param;
8735    parray[1] = parray[2] = parray[3] = 0;
8736    save_SamplerParameteriv(sampler, pname, parray);
8737 }
8738
8739 void GLAPIENTRY
8740 save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
8741 {
8742    Node *n;
8743    GET_CURRENT_CONTEXT(ctx);
8744    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8745    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6);
8746    if (n) {
8747       n[1].ui = sampler;
8748       n[2].e = pname;
8749       n[3].f = params[0];
8750       if (pname == GL_TEXTURE_BORDER_COLOR) {
8751          n[4].f = params[1];
8752          n[5].f = params[2];
8753          n[6].f = params[3];
8754       }
8755       else {
8756          n[4].f = n[5].f = n[6].f = 0.0F;
8757       }
8758    }
8759    if (ctx->ExecuteFlag) {
8760       CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params));
8761    }
8762 }
8763
8764 void GLAPIENTRY
8765 save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
8766 {
8767    GLfloat parray[4];
8768    parray[0] = param;
8769    parray[1] = parray[2] = parray[3] = 0.0F;
8770    save_SamplerParameterfv(sampler, pname, parray);
8771 }
8772
8773 void GLAPIENTRY
8774 save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
8775 {
8776    Node *n;
8777    GET_CURRENT_CONTEXT(ctx);
8778    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8779    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6);
8780    if (n) {
8781       n[1].ui = sampler;
8782       n[2].e = pname;
8783       n[3].i = params[0];
8784       if (pname == GL_TEXTURE_BORDER_COLOR) {
8785          n[4].i = params[1];
8786          n[5].i = params[2];
8787          n[6].i = params[3];
8788       }
8789       else {
8790          n[4].i = n[5].i = n[6].i = 0;
8791       }
8792    }
8793    if (ctx->ExecuteFlag) {
8794       CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params));
8795    }
8796 }
8797
8798 void GLAPIENTRY
8799 save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
8800 {
8801    Node *n;
8802    GET_CURRENT_CONTEXT(ctx);
8803    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8804    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6);
8805    if (n) {
8806       n[1].ui = sampler;
8807       n[2].e = pname;
8808       n[3].ui = params[0];
8809       if (pname == GL_TEXTURE_BORDER_COLOR) {
8810          n[4].ui = params[1];
8811          n[5].ui = params[2];
8812          n[6].ui = params[3];
8813       }
8814       else {
8815          n[4].ui = n[5].ui = n[6].ui = 0;
8816       }
8817    }
8818    if (ctx->ExecuteFlag) {
8819       CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params));
8820    }
8821 }
8822
8823 void GLAPIENTRY
8824 save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
8825 {
8826    Node *n;
8827    GET_CURRENT_CONTEXT(ctx);
8828    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8829    n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4);
8830    if (n) {
8831       union uint64_pair p;
8832       p.uint64 = timeout;
8833       n[1].bf = flags;
8834       n[2].ui = p.uint32[0];
8835       n[3].ui = p.uint32[1];
8836       save_pointer(&n[4], sync);
8837    }
8838    if (ctx->ExecuteFlag) {
8839       CALL_WaitSync(ctx->Exec, (sync, flags, timeout));
8840    }
8841 }
8842
8843
8844 /** GL_NV_conditional_render */
8845 void GLAPIENTRY
8846 save_BeginConditionalRender(GLuint queryId, GLenum mode)
8847 {
8848    GET_CURRENT_CONTEXT(ctx);
8849    Node *n;
8850    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8851    n = alloc_instruction(ctx, OPCODE_BEGIN_CONDITIONAL_RENDER, 2);
8852    if (n) {
8853       n[1].i = queryId;
8854       n[2].e = mode;
8855    }
8856    if (ctx->ExecuteFlag) {
8857       CALL_BeginConditionalRender(ctx->Exec, (queryId, mode));
8858    }
8859 }
8860
8861 void GLAPIENTRY
8862 save_EndConditionalRender(void)
8863 {
8864    GET_CURRENT_CONTEXT(ctx);
8865    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8866    alloc_instruction(ctx, OPCODE_END_CONDITIONAL_RENDER, 0);
8867    if (ctx->ExecuteFlag) {
8868       CALL_EndConditionalRender(ctx->Exec, ());
8869    }
8870 }
8871
8872 void GLAPIENTRY
8873 save_UniformBlockBinding(GLuint prog, GLuint index, GLuint binding)
8874 {
8875    GET_CURRENT_CONTEXT(ctx);
8876    Node *n;
8877    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8878    n = alloc_instruction(ctx, OPCODE_UNIFORM_BLOCK_BINDING, 3);
8879    if (n) {
8880       n[1].ui = prog;
8881       n[2].ui = index;
8882       n[3].ui = binding;
8883    }
8884    if (ctx->ExecuteFlag) {
8885       CALL_UniformBlockBinding(ctx->Exec, (prog, index, binding));
8886    }
8887 }
8888
8889 void GLAPIENTRY
8890 save_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
8891                            const GLuint *indices)
8892 {
8893    GET_CURRENT_CONTEXT(ctx);
8894    Node *n;
8895    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8896    n = alloc_instruction(ctx, OPCODE_UNIFORM_SUBROUTINES, 2 + POINTER_DWORDS);
8897    if (n) {
8898       GLint *indices_copy = NULL;
8899
8900       if (count > 0)
8901          indices_copy = memdup(indices, sizeof(GLuint) * 4 * count);
8902       n[1].e = shadertype;
8903       n[2].si = count;
8904       save_pointer(&n[3], indices_copy);
8905    }
8906    if (ctx->ExecuteFlag) {
8907       CALL_UniformSubroutinesuiv(ctx->Exec, (shadertype, count, indices));
8908    }
8909 }
8910
8911 /** GL_EXT_window_rectangles */
8912 void GLAPIENTRY
8913 save_WindowRectanglesEXT(GLenum mode, GLsizei count, const GLint *box)
8914 {
8915    GET_CURRENT_CONTEXT(ctx);
8916    Node *n;
8917    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8918    n = alloc_instruction(ctx, OPCODE_WINDOW_RECTANGLES, 2 + POINTER_DWORDS);
8919    if (n) {
8920       GLint *box_copy = NULL;
8921
8922       if (count > 0)
8923          box_copy = memdup(box, sizeof(GLint) * 4 * count);
8924       n[1].e = mode;
8925       n[2].si = count;
8926       save_pointer(&n[3], box_copy);
8927    }
8928    if (ctx->ExecuteFlag) {
8929       CALL_WindowRectanglesEXT(ctx->Exec, (mode, count, box));
8930    }
8931 }
8932
8933
8934 /** GL_NV_conservative_raster */
8935 void GLAPIENTRY
8936 save_SubpixelPrecisionBiasNV(GLuint xbits, GLuint ybits)
8937 {
8938    GET_CURRENT_CONTEXT(ctx);
8939    Node *n;
8940    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8941    n = alloc_instruction(ctx, OPCODE_SUBPIXEL_PRECISION_BIAS, 2);
8942    if (n) {
8943       n[1].ui = xbits;
8944       n[2].ui = ybits;
8945    }
8946    if (ctx->ExecuteFlag) {
8947       CALL_SubpixelPrecisionBiasNV(ctx->Exec, (xbits, ybits));
8948    }
8949 }
8950
8951 /** GL_NV_conservative_raster_dilate */
8952 void GLAPIENTRY
8953 save_ConservativeRasterParameterfNV(GLenum pname, GLfloat param)
8954 {
8955    GET_CURRENT_CONTEXT(ctx);
8956    Node *n;
8957    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8958    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_F, 2);
8959    if (n) {
8960       n[1].e = pname;
8961       n[2].f = param;
8962    }
8963    if (ctx->ExecuteFlag) {
8964       CALL_ConservativeRasterParameterfNV(ctx->Exec, (pname, param));
8965    }
8966 }
8967
8968 /** GL_NV_conservative_raster_pre_snap_triangles */
8969 void GLAPIENTRY
8970 save_ConservativeRasterParameteriNV(GLenum pname, GLint param)
8971 {
8972    GET_CURRENT_CONTEXT(ctx);
8973    Node *n;
8974    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8975    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_I, 2);
8976    if (n) {
8977       n[1].e = pname;
8978       n[2].i = param;
8979    }
8980    if (ctx->ExecuteFlag) {
8981       CALL_ConservativeRasterParameteriNV(ctx->Exec, (pname, param));
8982    }
8983 }
8984
8985 /** GL_EXT_direct_state_access */
8986
8987 void GLAPIENTRY
8988 save_MatrixLoadfEXT(GLenum matrixMode, const GLfloat *m)
8989 {
8990    GET_CURRENT_CONTEXT(ctx);
8991    Node *n;
8992    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8993    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD, 17);
8994    if (n) {
8995       n[1].e = matrixMode;
8996       for (unsigned i = 0; i < 16; i++) {
8997          n[2 + i].f = m[i];
8998       }
8999    }
9000    if (ctx->ExecuteFlag) {
9001       CALL_MatrixLoadfEXT(ctx->Exec, (matrixMode, m));
9002    }
9003 }
9004
9005 void GLAPIENTRY
9006 save_MatrixLoaddEXT(GLenum matrixMode, const GLdouble *m)
9007 {
9008    GLfloat f[16];
9009    for (unsigned i = 0; i < 16; i++) {
9010       f[i] = (GLfloat) m[i];
9011    }
9012    save_MatrixLoadfEXT(matrixMode, f);
9013 }
9014
9015 void GLAPIENTRY
9016 save_MatrixMultfEXT(GLenum matrixMode, const GLfloat * m)
9017 {
9018    GET_CURRENT_CONTEXT(ctx);
9019    Node *n;
9020    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9021    n = alloc_instruction(ctx, OPCODE_MATRIX_MULT, 17);
9022    if (n) {
9023       n[1].e = matrixMode;
9024       for (unsigned i = 0; i < 16; i++) {
9025          n[2 + i].f = m[i];
9026       }
9027    }
9028    if (ctx->ExecuteFlag) {
9029       CALL_MatrixMultfEXT(ctx->Exec, (matrixMode, m));
9030    }
9031 }
9032
9033 void GLAPIENTRY
9034 save_MatrixMultdEXT(GLenum matrixMode, const GLdouble * m)
9035 {
9036    GLfloat f[16];
9037    for (unsigned i = 0; i < 16; i++) {
9038       f[i] = (GLfloat) m[i];
9039    }
9040    save_MatrixMultfEXT(matrixMode, f);
9041 }
9042
9043 void GLAPIENTRY
9044 save_MatrixRotatefEXT(GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
9045 {
9046    GET_CURRENT_CONTEXT(ctx);
9047    Node *n;
9048    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9049    n = alloc_instruction(ctx, OPCODE_MATRIX_ROTATE, 5);
9050    if (n) {
9051       n[1].e = matrixMode;
9052       n[2].f = angle;
9053       n[3].f = x;
9054       n[4].f = y;
9055       n[5].f = z;
9056    }
9057    if (ctx->ExecuteFlag) {
9058       CALL_MatrixRotatefEXT(ctx->Exec, (matrixMode, angle, x, y, z));
9059    }
9060 }
9061
9062 void GLAPIENTRY
9063 save_MatrixRotatedEXT(GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
9064 {
9065    save_MatrixRotatefEXT(matrixMode, (GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9066 }
9067
9068 void GLAPIENTRY
9069 save_MatrixScalefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9070 {
9071    GET_CURRENT_CONTEXT(ctx);
9072    Node *n;
9073    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9074    n = alloc_instruction(ctx, OPCODE_MATRIX_SCALE, 4);
9075    if (n) {
9076       n[1].e = matrixMode;
9077       n[2].f = x;
9078       n[3].f = y;
9079       n[4].f = z;
9080    }
9081    if (ctx->ExecuteFlag) {
9082       CALL_MatrixScalefEXT(ctx->Exec, (matrixMode, x, y, z));
9083    }
9084 }
9085
9086 void GLAPIENTRY
9087 save_MatrixScaledEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9088 {
9089    save_MatrixScalefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9090 }
9091
9092 void GLAPIENTRY
9093 save_MatrixTranslatefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9094 {
9095    GET_CURRENT_CONTEXT(ctx);
9096    Node *n;
9097    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9098    n = alloc_instruction(ctx, OPCODE_MATRIX_TRANSLATE, 4);
9099    if (n) {
9100       n[1].e = matrixMode;
9101       n[2].f = x;
9102       n[3].f = y;
9103       n[4].f = z;
9104    }
9105    if (ctx->ExecuteFlag) {
9106       CALL_MatrixTranslatefEXT(ctx->Exec, (matrixMode, x, y, z));
9107    }
9108 }
9109
9110 void GLAPIENTRY
9111 save_MatrixTranslatedEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9112 {
9113    save_MatrixTranslatefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9114 }
9115
9116 void GLAPIENTRY
9117 save_MatrixLoadIdentityEXT(GLenum matrixMode)
9118 {
9119    GET_CURRENT_CONTEXT(ctx);
9120    Node *n;
9121    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9122    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD_IDENTITY, 1);
9123    if (n) {
9124       n[1].e = matrixMode;
9125    }
9126    if (ctx->ExecuteFlag) {
9127       CALL_MatrixLoadIdentityEXT(ctx->Exec, (matrixMode));
9128    }
9129 }
9130
9131 void GLAPIENTRY
9132 save_MatrixOrthoEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9133                     GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9134 {
9135    GET_CURRENT_CONTEXT(ctx);
9136    Node *n;
9137    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9138    n = alloc_instruction(ctx, OPCODE_MATRIX_ORTHO, 7);
9139    if (n) {
9140       n[1].e = matrixMode;
9141       n[2].f = (GLfloat) left;
9142       n[3].f = (GLfloat) right;
9143       n[4].f = (GLfloat) bottom;
9144       n[5].f = (GLfloat) top;
9145       n[6].f = (GLfloat) nearval;
9146       n[7].f = (GLfloat) farval;
9147    }
9148    if (ctx->ExecuteFlag) {
9149       CALL_MatrixOrthoEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9150    }
9151 }
9152
9153
9154 void GLAPIENTRY
9155 save_MatrixFrustumEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9156                       GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9157 {
9158    GET_CURRENT_CONTEXT(ctx);
9159    Node *n;
9160    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9161    n = alloc_instruction(ctx, OPCODE_MATRIX_FRUSTUM, 7);
9162    if (n) {
9163       n[1].e = matrixMode;
9164       n[2].f = (GLfloat) left;
9165       n[3].f = (GLfloat) right;
9166       n[4].f = (GLfloat) bottom;
9167       n[5].f = (GLfloat) top;
9168       n[6].f = (GLfloat) nearval;
9169       n[7].f = (GLfloat) farval;
9170    }
9171    if (ctx->ExecuteFlag) {
9172       CALL_MatrixFrustumEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9173    }
9174 }
9175
9176 void GLAPIENTRY
9177 save_MatrixPushEXT(GLenum matrixMode)
9178 {
9179    GET_CURRENT_CONTEXT(ctx);
9180    Node* n;
9181    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9182    n = alloc_instruction(ctx, OPCODE_MATRIX_PUSH, 1);
9183    if (n) {
9184       n[1].e = matrixMode;
9185    }
9186    if (ctx->ExecuteFlag) {
9187       CALL_MatrixPushEXT(ctx->Exec, (matrixMode));
9188    }
9189 }
9190
9191 void GLAPIENTRY
9192 save_MatrixPopEXT(GLenum matrixMode)
9193 {
9194    GET_CURRENT_CONTEXT(ctx);
9195    Node* n;
9196    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9197    n = alloc_instruction(ctx, OPCODE_MATRIX_POP, 1);
9198    if (n) {
9199       n[1].e = matrixMode;
9200    }
9201    if (ctx->ExecuteFlag) {
9202       CALL_MatrixPopEXT(ctx->Exec, (matrixMode));
9203    }
9204 }
9205
9206 void GLAPIENTRY
9207 save_MatrixLoadTransposefEXT(GLenum matrixMode, const GLfloat *m)
9208 {
9209    GLfloat tm[16];
9210    _math_transposef(tm, m);
9211    save_MatrixLoadfEXT(matrixMode, tm);
9212 }
9213
9214 void GLAPIENTRY
9215 save_MatrixLoadTransposedEXT(GLenum matrixMode, const GLdouble *m)
9216 {
9217    GLfloat tm[16];
9218    _math_transposefd(tm, m);
9219    save_MatrixLoadfEXT(matrixMode, tm);
9220 }
9221
9222 void GLAPIENTRY
9223 save_MatrixMultTransposefEXT(GLenum matrixMode, const GLfloat *m)
9224 {
9225    GLfloat tm[16];
9226    _math_transposef(tm, m);
9227    save_MatrixMultfEXT(matrixMode, tm);
9228 }
9229
9230 void GLAPIENTRY
9231 save_MatrixMultTransposedEXT(GLenum matrixMode, const GLdouble *m)
9232 {
9233    GLfloat tm[16];
9234    _math_transposefd(tm, m);
9235    save_MatrixMultfEXT(matrixMode, tm);
9236 }
9237
9238 void GLAPIENTRY
9239 save_TextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname,
9240                            const GLfloat *params)
9241 {
9242    GET_CURRENT_CONTEXT(ctx);
9243    Node *n;
9244    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9245    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_F, 7);
9246    if (n) {
9247       n[1].ui = texture;
9248       n[2].e = target;
9249       n[3].e = pname;
9250       n[4].f = params[0];
9251       n[5].f = params[1];
9252       n[6].f = params[2];
9253       n[7].f = params[3];
9254    }
9255    if (ctx->ExecuteFlag) {
9256       CALL_TextureParameterfvEXT(ctx->Exec, (texture, target, pname, params));
9257    }
9258 }
9259
9260
9261 void GLAPIENTRY
9262 save_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
9263 {
9264    GLfloat parray[4];
9265    parray[0] = param;
9266    parray[1] = parray[2] = parray[3] = 0.0F;
9267    save_TextureParameterfvEXT(texture, target, pname, parray);
9268 }
9269
9270 void GLAPIENTRY
9271 save_TextureParameterivEXT(GLuint texture, GLenum target, GLenum pname, const GLint *params)
9272 {
9273    GET_CURRENT_CONTEXT(ctx);
9274    Node *n;
9275    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9276    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_I, 7);
9277    if (n) {
9278       n[1].ui = texture;
9279       n[2].e = target;
9280       n[3].e = pname;
9281       n[4].i = params[0];
9282       n[5].i = params[1];
9283       n[6].i = params[2];
9284       n[7].i = params[3];
9285    }
9286    if (ctx->ExecuteFlag) {
9287       CALL_TextureParameterivEXT(ctx->Exec, (texture, target, pname, params));
9288    }
9289 }
9290
9291 void GLAPIENTRY
9292 save_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
9293 {
9294    GLint fparam[4];
9295    fparam[0] = param;
9296    fparam[1] = fparam[2] = fparam[3] = 0;
9297    save_TextureParameterivEXT(texture, target, pname, fparam);
9298 }
9299
9300 void GLAPIENTRY
9301 save_TextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, const GLint* params)
9302 {
9303    GET_CURRENT_CONTEXT(ctx);
9304    Node *n;
9305    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9306    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_II, 7);
9307    if (n) {
9308       n[1].ui = texture;
9309       n[2].e = target;
9310       n[3].e = pname;
9311       n[4].i = params[0];
9312       n[5].i = params[1];
9313       n[6].i = params[2];
9314       n[7].i = params[3];
9315    }
9316    if (ctx->ExecuteFlag) {
9317       CALL_TextureParameterIivEXT(ctx->Exec, (texture, target, pname, params));
9318    }
9319 }
9320
9321 void GLAPIENTRY
9322 save_TextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname, const GLuint* params)
9323 {
9324    GET_CURRENT_CONTEXT(ctx);
9325    Node *n;
9326    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9327    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_IUI, 7);
9328    if (n) {
9329       n[1].ui = texture;
9330       n[2].e = target;
9331       n[3].e = pname;
9332       n[4].ui = params[0];
9333       n[5].ui = params[1];
9334       n[6].ui = params[2];
9335       n[7].ui = params[3];
9336    }
9337    if (ctx->ExecuteFlag) {
9338       CALL_TextureParameterIuivEXT(ctx->Exec, (texture, target, pname, params));
9339    }
9340 }
9341
9342
9343 void GLAPIENTRY
9344 save_TextureImage1DEXT(GLuint texture, GLenum target,
9345                        GLint level, GLint components,
9346                        GLsizei width, GLint border,
9347                        GLenum format, GLenum type, const GLvoid * pixels)
9348 {
9349    GET_CURRENT_CONTEXT(ctx);
9350    if (target == GL_PROXY_TEXTURE_1D) {
9351       /* don't compile, execute immediately */
9352       CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9353                                          border, format, type, pixels));
9354    }
9355    else {
9356       Node *n;
9357       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9358       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE1D, 8 + POINTER_DWORDS);
9359       if (n) {
9360          n[1].ui = texture;
9361          n[2].e = target;
9362          n[3].i = level;
9363          n[4].i = components;
9364          n[5].i = (GLint) width;
9365          n[6].i = border;
9366          n[7].e = format;
9367          n[8].e = type;
9368          save_pointer(&n[9],
9369                       unpack_image(ctx, 1, width, 1, 1, format, type,
9370                                    pixels, &ctx->Unpack));
9371       }
9372       if (ctx->ExecuteFlag) {
9373          CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9374                                             border, format, type, pixels));
9375       }
9376    }
9377 }
9378
9379
9380 void GLAPIENTRY
9381 save_TextureImage2DEXT(GLuint texture, GLenum target,
9382                        GLint level, GLint components,
9383                        GLsizei width, GLsizei height, GLint border,
9384                        GLenum format, GLenum type, const GLvoid * pixels)
9385 {
9386    GET_CURRENT_CONTEXT(ctx);
9387    if (target == GL_PROXY_TEXTURE_2D) {
9388       /* don't compile, execute immediately */
9389       CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9390                                          height, border, format, type, pixels));
9391    }
9392    else {
9393       Node *n;
9394       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9395       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE2D, 9 + POINTER_DWORDS);
9396       if (n) {
9397          n[1].ui = texture;
9398          n[2].e = target;
9399          n[3].i = level;
9400          n[4].i = components;
9401          n[5].i = (GLint) width;
9402          n[6].i = (GLint) height;
9403          n[7].i = border;
9404          n[8].e = format;
9405          n[9].e = type;
9406          save_pointer(&n[10],
9407                       unpack_image(ctx, 2, width, height, 1, format, type,
9408                                    pixels, &ctx->Unpack));
9409       }
9410       if (ctx->ExecuteFlag) {
9411          CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9412                                             height, border, format, type, pixels));
9413       }
9414    }
9415 }
9416
9417
9418 void GLAPIENTRY
9419 save_TextureImage3DEXT(GLuint texture, GLenum target,
9420                        GLint level, GLint internalFormat,
9421                        GLsizei width, GLsizei height, GLsizei depth,
9422                        GLint border,
9423                        GLenum format, GLenum type, const GLvoid * pixels)
9424 {
9425    GET_CURRENT_CONTEXT(ctx);
9426    if (target == GL_PROXY_TEXTURE_3D) {
9427       /* don't compile, execute immediately */
9428       CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat, width,
9429                                          height, depth, border, format, type,
9430                                          pixels));
9431    }
9432    else {
9433       Node *n;
9434       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9435       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE3D, 10 + POINTER_DWORDS);
9436       if (n) {
9437          n[1].ui = texture;
9438          n[2].e = target;
9439          n[3].i = level;
9440          n[4].i = (GLint) internalFormat;
9441          n[5].i = (GLint) width;
9442          n[6].i = (GLint) height;
9443          n[7].i = (GLint) depth;
9444          n[8].i = border;
9445          n[9].e = format;
9446          n[10].e = type;
9447          save_pointer(&n[11],
9448                       unpack_image(ctx, 3, width, height, depth, format, type,
9449                                    pixels, &ctx->Unpack));
9450       }
9451       if (ctx->ExecuteFlag) {
9452          CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat,
9453                                             width, height, depth, border, format,
9454                                             type, pixels));
9455       }
9456    }
9457 }
9458
9459
9460 void GLAPIENTRY
9461 save_TextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
9462                    GLsizei width, GLenum format, GLenum type,
9463                    const GLvoid * pixels)
9464 {
9465    GET_CURRENT_CONTEXT(ctx);
9466    Node *n;
9467
9468    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9469
9470    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE1D, 7 + POINTER_DWORDS);
9471    if (n) {
9472       n[1].ui = texture;
9473       n[2].e = target;
9474       n[3].i = level;
9475       n[4].i = xoffset;
9476       n[5].i = (GLint) width;
9477       n[6].e = format;
9478       n[7].e = type;
9479       save_pointer(&n[8],
9480                    unpack_image(ctx, 1, width, 1, 1, format, type,
9481                                 pixels, &ctx->Unpack));
9482    }
9483    if (ctx->ExecuteFlag) {
9484       CALL_TextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset, width,
9485                                             format, type, pixels));
9486    }
9487 }
9488
9489
9490 void GLAPIENTRY
9491 save_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
9492                           GLint xoffset, GLint yoffset,
9493                           GLsizei width, GLsizei height,
9494                           GLenum format, GLenum type, const GLvoid * pixels)
9495 {
9496    GET_CURRENT_CONTEXT(ctx);
9497    Node *n;
9498
9499    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9500
9501    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE2D, 9 + POINTER_DWORDS);
9502    if (n) {
9503       n[1].ui = texture;
9504       n[2].e = target;
9505       n[3].i = level;
9506       n[4].i = xoffset;
9507       n[5].i = yoffset;
9508       n[6].i = (GLint) width;
9509       n[7].i = (GLint) height;
9510       n[8].e = format;
9511       n[9].e = type;
9512       save_pointer(&n[10],
9513                    unpack_image(ctx, 2, width, height, 1, format, type,
9514                                 pixels, &ctx->Unpack));
9515    }
9516    if (ctx->ExecuteFlag) {
9517       CALL_TextureSubImage2DEXT(ctx->Exec, (texture, target, level, xoffset, yoffset,
9518                                             width, height, format, type, pixels));
9519    }
9520 }
9521
9522
9523 void GLAPIENTRY
9524 save_TextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
9525                           GLint xoffset, GLint yoffset, GLint zoffset,
9526                           GLsizei width, GLsizei height, GLsizei depth,
9527                           GLenum format, GLenum type, const GLvoid * pixels)
9528 {
9529    GET_CURRENT_CONTEXT(ctx);
9530    Node *n;
9531
9532    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9533
9534    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE3D, 11 + POINTER_DWORDS);
9535    if (n) {
9536       n[1].ui = texture;
9537       n[2].e = target;
9538       n[3].i = level;
9539       n[4].i = xoffset;
9540       n[5].i = yoffset;
9541       n[6].i = zoffset;
9542       n[7].i = (GLint) width;
9543       n[8].i = (GLint) height;
9544       n[9].i = (GLint) depth;
9545       n[10].e = format;
9546       n[11].e = type;
9547       save_pointer(&n[12],
9548                    unpack_image(ctx, 3, width, height, depth, format, type,
9549                                 pixels, &ctx->Unpack));
9550    }
9551    if (ctx->ExecuteFlag) {
9552       CALL_TextureSubImage3DEXT(ctx->Exec, (texture, target, level,
9553                                             xoffset, yoffset, zoffset,
9554                                             width, height, depth, format, type,
9555                                             pixels));
9556    }
9557 }
9558
9559 void GLAPIENTRY
9560 save_CopyTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
9561                            GLenum internalformat, GLint x, GLint y,
9562                            GLsizei width, GLint border)
9563 {
9564    GET_CURRENT_CONTEXT(ctx);
9565    Node *n;
9566    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9567    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE1D, 8);
9568    if (n) {
9569       n[1].ui = texture;
9570       n[2].e = target;
9571       n[3].i = level;
9572       n[4].e = internalformat;
9573       n[5].i = x;
9574       n[6].i = y;
9575       n[7].i = width;
9576       n[8].i = border;
9577    }
9578    if (ctx->ExecuteFlag) {
9579       CALL_CopyTextureImage1DEXT(ctx->Exec, (texture, target, level,
9580                                              internalformat, x, y,
9581                                              width, border));
9582    }
9583 }
9584
9585 void GLAPIENTRY
9586 save_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
9587                            GLenum internalformat,
9588                            GLint x, GLint y, GLsizei width,
9589                            GLsizei height, GLint border)
9590 {
9591    GET_CURRENT_CONTEXT(ctx);
9592    Node *n;
9593    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9594    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE2D, 9);
9595    if (n) {
9596       n[1].ui = texture;
9597       n[2].e = target;
9598       n[3].i = level;
9599       n[4].e = internalformat;
9600       n[5].i = x;
9601       n[6].i = y;
9602       n[7].i = width;
9603       n[8].i = height;
9604       n[9].i = border;
9605    }
9606    if (ctx->ExecuteFlag) {
9607       CALL_CopyTextureImage2DEXT(ctx->Exec, (texture, target, level,
9608                                              internalformat, x, y,
9609                                              width, height, border));
9610    }
9611 }
9612
9613 void GLAPIENTRY
9614 save_CopyTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level,
9615                               GLint xoffset, GLint x, GLint y, GLsizei width)
9616 {
9617    GET_CURRENT_CONTEXT(ctx);
9618    Node *n;
9619    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9620    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE1D, 7);
9621    if (n) {
9622       n[1].ui = texture;
9623       n[2].e = target;
9624       n[3].i = level;
9625       n[4].i = xoffset;
9626       n[5].i = x;
9627       n[6].i = y;
9628       n[7].i = width;
9629    }
9630    if (ctx->ExecuteFlag) {
9631       CALL_CopyTextureSubImage1DEXT(ctx->Exec,
9632                              (texture, target, level, xoffset, x, y, width));
9633    }
9634 }
9635
9636 void GLAPIENTRY
9637 save_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
9638                               GLint xoffset, GLint yoffset,
9639                               GLint x, GLint y, GLsizei width, GLint height)
9640 {
9641    GET_CURRENT_CONTEXT(ctx);
9642    Node *n;
9643    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9644    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE2D, 9);
9645    if (n) {
9646       n[1].ui = texture;
9647       n[2].e = target;
9648       n[3].i = level;
9649       n[4].i = xoffset;
9650       n[5].i = yoffset;
9651       n[6].i = x;
9652       n[7].i = y;
9653       n[8].i = width;
9654       n[9].i = height;
9655    }
9656    if (ctx->ExecuteFlag) {
9657       CALL_CopyTextureSubImage2DEXT(ctx->Exec, (texture, target, level,
9658                                                 xoffset, yoffset,
9659                                                 x, y, width, height));
9660    }
9661 }
9662
9663
9664 void GLAPIENTRY
9665 save_CopyTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
9666                               GLint xoffset, GLint yoffset, GLint zoffset,
9667                               GLint x, GLint y, GLsizei width, GLint height)
9668 {
9669    GET_CURRENT_CONTEXT(ctx);
9670    Node *n;
9671    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9672    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE3D, 10);
9673    if (n) {
9674       n[1].ui = texture;
9675       n[2].e = target;
9676       n[3].i = level;
9677       n[4].i = xoffset;
9678       n[5].i = yoffset;
9679       n[6].i = zoffset;
9680       n[7].i = x;
9681       n[8].i = y;
9682       n[9].i = width;
9683       n[10].i = height;
9684    }
9685    if (ctx->ExecuteFlag) {
9686       CALL_CopyTextureSubImage3DEXT(ctx->Exec, (texture, target, level,
9687                                                 xoffset, yoffset, zoffset,
9688                                                 x, y, width, height));
9689    }
9690 }
9691
9692
9693 void GLAPIENTRY
9694 save_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture)
9695 {
9696    GET_CURRENT_CONTEXT(ctx);
9697    Node *n;
9698    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9699    n = alloc_instruction(ctx, OPCODE_BIND_MULTITEXTURE, 3);
9700    if (n) {
9701       n[1].e = texunit;
9702       n[2].e = target;
9703       n[3].ui = texture;
9704    }
9705    if (ctx->ExecuteFlag) {
9706       CALL_BindMultiTextureEXT(ctx->Exec, (texunit, target, texture));
9707    }
9708 }
9709
9710
9711 void GLAPIENTRY
9712 save_MultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname,
9713                            const GLfloat *params)
9714 {
9715    GET_CURRENT_CONTEXT(ctx);
9716    Node *n;
9717    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9718    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_F, 7);
9719    if (n) {
9720       n[1].e = texunit;
9721       n[2].e = target;
9722       n[3].e = pname;
9723       n[4].f = params[0];
9724       n[5].f = params[1];
9725       n[6].f = params[2];
9726       n[7].f = params[3];
9727    }
9728    if (ctx->ExecuteFlag) {
9729       CALL_MultiTexParameterfvEXT(ctx->Exec, (texunit, target, pname, params));
9730    }
9731 }
9732
9733
9734 void GLAPIENTRY
9735 save_MultiTexParameterfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
9736 {
9737    GLfloat parray[4];
9738    parray[0] = param;
9739    parray[1] = parray[2] = parray[3] = 0.0F;
9740    save_MultiTexParameterfvEXT(texunit, target, pname, parray);
9741 }
9742
9743 void GLAPIENTRY
9744 save_MultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
9745 {
9746    GET_CURRENT_CONTEXT(ctx);
9747    Node *n;
9748    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9749    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_I, 7);
9750    if (n) {
9751       n[1].e = texunit;
9752       n[2].e = target;
9753       n[3].e = pname;
9754       n[4].i = params[0];
9755       n[5].i = params[1];
9756       n[6].i = params[2];
9757       n[7].i = params[3];
9758    }
9759    if (ctx->ExecuteFlag) {
9760       CALL_MultiTexParameterivEXT(ctx->Exec, (texunit, target, pname, params));
9761    }
9762 }
9763
9764 void GLAPIENTRY
9765 save_MultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
9766 {
9767    GET_CURRENT_CONTEXT(ctx);
9768    Node *n;
9769    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9770    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_II, 7);
9771    if (n) {
9772       n[1].e = texunit;
9773       n[2].e = target;
9774       n[3].e = pname;
9775       n[4].i = params[0];
9776       n[5].i = params[1];
9777       n[6].i = params[2];
9778       n[7].i = params[3];
9779    }
9780    if (ctx->ExecuteFlag) {
9781       CALL_MultiTexParameterIivEXT(ctx->Exec, (texunit, target, pname, params));
9782    }
9783 }
9784
9785 void GLAPIENTRY
9786 save_MultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname, const GLuint *params)
9787 {
9788    GET_CURRENT_CONTEXT(ctx);
9789    Node *n;
9790    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9791    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_IUI, 7);
9792    if (n) {
9793       n[1].e = texunit;
9794       n[2].e = target;
9795       n[3].e = pname;
9796       n[4].ui = params[0];
9797       n[5].ui = params[1];
9798       n[6].ui = params[2];
9799       n[7].ui = params[3];
9800    }
9801    if (ctx->ExecuteFlag) {
9802       CALL_MultiTexParameterIuivEXT(ctx->Exec, (texunit, target, pname, params));
9803    }
9804 }
9805
9806 void GLAPIENTRY
9807 save_MultiTexParameteriEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
9808 {
9809    GLint fparam[4];
9810    fparam[0] = param;
9811    fparam[1] = fparam[2] = fparam[3] = 0;
9812    save_MultiTexParameterivEXT(texunit, target, pname, fparam);
9813 }
9814
9815
9816 void GLAPIENTRY
9817 save_MultiTexImage1DEXT(GLenum texunit, GLenum target,
9818                         GLint level, GLint components,
9819                         GLsizei width, GLint border,
9820                         GLenum format, GLenum type, const GLvoid * pixels)
9821 {
9822    GET_CURRENT_CONTEXT(ctx);
9823    if (target == GL_PROXY_TEXTURE_1D) {
9824       /* don't compile, execute immediately */
9825       CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
9826                                          border, format, type, pixels));
9827    }
9828    else {
9829       Node *n;
9830       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9831       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE1D, 8 + POINTER_DWORDS);
9832       if (n) {
9833          n[1].e = texunit;
9834          n[2].e = target;
9835          n[3].i = level;
9836          n[4].i = components;
9837          n[5].i = (GLint) width;
9838          n[6].i = border;
9839          n[7].e = format;
9840          n[8].e = type;
9841          save_pointer(&n[9],
9842                       unpack_image(ctx, 1, width, 1, 1, format, type,
9843                                    pixels, &ctx->Unpack));
9844       }
9845       if (ctx->ExecuteFlag) {
9846          CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
9847                                             border, format, type, pixels));
9848       }
9849    }
9850 }
9851
9852
9853 void GLAPIENTRY
9854 save_MultiTexImage2DEXT(GLenum texunit, GLenum target,
9855                        GLint level, GLint components,
9856                        GLsizei width, GLsizei height, GLint border,
9857                        GLenum format, GLenum type, const GLvoid * pixels)
9858 {
9859    GET_CURRENT_CONTEXT(ctx);
9860    if (target == GL_PROXY_TEXTURE_2D) {
9861       /* don't compile, execute immediately */
9862       CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
9863                                          height, border, format, type, pixels));
9864    }
9865    else {
9866       Node *n;
9867       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9868       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE2D, 9 + POINTER_DWORDS);
9869       if (n) {
9870          n[1].e = texunit;
9871          n[2].e = target;
9872          n[3].i = level;
9873          n[4].i = components;
9874          n[5].i = (GLint) width;
9875          n[6].i = (GLint) height;
9876          n[7].i = border;
9877          n[8].e = format;
9878          n[9].e = type;
9879          save_pointer(&n[10],
9880                       unpack_image(ctx, 2, width, height, 1, format, type,
9881                                    pixels, &ctx->Unpack));
9882       }
9883       if (ctx->ExecuteFlag) {
9884          CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
9885                                             height, border, format, type, pixels));
9886       }
9887    }
9888 }
9889
9890
9891 void GLAPIENTRY
9892 save_MultiTexImage3DEXT(GLenum texunit, GLenum target,
9893                        GLint level, GLint internalFormat,
9894                        GLsizei width, GLsizei height, GLsizei depth,
9895                        GLint border,
9896                        GLenum format, GLenum type, const GLvoid * pixels)
9897 {
9898    GET_CURRENT_CONTEXT(ctx);
9899    if (target == GL_PROXY_TEXTURE_3D) {
9900       /* don't compile, execute immediately */
9901       CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat, width,
9902                                          height, depth, border, format, type,
9903                                          pixels));
9904    }
9905    else {
9906       Node *n;
9907       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9908       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE3D, 10 + POINTER_DWORDS);
9909       if (n) {
9910          n[1].e = texunit;
9911          n[2].e = target;
9912          n[3].i = level;
9913          n[4].i = (GLint) internalFormat;
9914          n[5].i = (GLint) width;
9915          n[6].i = (GLint) height;
9916          n[7].i = (GLint) depth;
9917          n[8].i = border;
9918          n[9].e = format;
9919          n[10].e = type;
9920          save_pointer(&n[11],
9921                       unpack_image(ctx, 3, width, height, depth, format, type,
9922                                    pixels, &ctx->Unpack));
9923       }
9924       if (ctx->ExecuteFlag) {
9925          CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat,
9926                                             width, height, depth, border, format,
9927                                             type, pixels));
9928       }
9929    }
9930 }
9931
9932
9933 void GLAPIENTRY
9934 save_MultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
9935                    GLsizei width, GLenum format, GLenum type,
9936                    const GLvoid * pixels)
9937 {
9938    GET_CURRENT_CONTEXT(ctx);
9939    Node *n;
9940
9941    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9942
9943    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE1D, 7 + POINTER_DWORDS);
9944    if (n) {
9945       n[1].e = texunit;
9946       n[2].e = target;
9947       n[3].i = level;
9948       n[4].i = xoffset;
9949       n[5].i = (GLint) width;
9950       n[6].e = format;
9951       n[7].e = type;
9952       save_pointer(&n[8],
9953                    unpack_image(ctx, 1, width, 1, 1, format, type,
9954                                 pixels, &ctx->Unpack));
9955    }
9956    if (ctx->ExecuteFlag) {
9957       CALL_MultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset, width,
9958                                             format, type, pixels));
9959    }
9960 }
9961
9962
9963 void GLAPIENTRY
9964 save_MultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
9965                           GLint xoffset, GLint yoffset,
9966                           GLsizei width, GLsizei height,
9967                           GLenum format, GLenum type, const GLvoid * pixels)
9968 {
9969    GET_CURRENT_CONTEXT(ctx);
9970    Node *n;
9971
9972    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9973
9974    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE2D, 9 + POINTER_DWORDS);
9975    if (n) {
9976       n[1].e = texunit;
9977       n[2].e = target;
9978       n[3].i = level;
9979       n[4].i = xoffset;
9980       n[5].i = yoffset;
9981       n[6].i = (GLint) width;
9982       n[7].i = (GLint) height;
9983       n[8].e = format;
9984       n[9].e = type;
9985       save_pointer(&n[10],
9986                    unpack_image(ctx, 2, width, height, 1, format, type,
9987                                 pixels, &ctx->Unpack));
9988    }
9989    if (ctx->ExecuteFlag) {
9990       CALL_MultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level, xoffset, yoffset,
9991                                             width, height, format, type, pixels));
9992    }
9993 }
9994
9995
9996 void GLAPIENTRY
9997 save_MultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
9998                           GLint xoffset, GLint yoffset, GLint zoffset,
9999                           GLsizei width, GLsizei height, GLsizei depth,
10000                           GLenum format, GLenum type, const GLvoid * pixels)
10001 {
10002    GET_CURRENT_CONTEXT(ctx);
10003    Node *n;
10004
10005    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10006
10007    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE3D, 11 + POINTER_DWORDS);
10008    if (n) {
10009       n[1].e = texunit;
10010       n[2].e = target;
10011       n[3].i = level;
10012       n[4].i = xoffset;
10013       n[5].i = yoffset;
10014       n[6].i = zoffset;
10015       n[7].i = (GLint) width;
10016       n[8].i = (GLint) height;
10017       n[9].i = (GLint) depth;
10018       n[10].e = format;
10019       n[11].e = type;
10020       save_pointer(&n[12],
10021                    unpack_image(ctx, 3, width, height, depth, format, type,
10022                                 pixels, &ctx->Unpack));
10023    }
10024    if (ctx->ExecuteFlag) {
10025       CALL_MultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10026                                             xoffset, yoffset, zoffset,
10027                                             width, height, depth, format, type,
10028                                             pixels));
10029    }
10030 }
10031
10032
10033 void GLAPIENTRY
10034 save_CopyMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
10035                            GLenum internalformat, GLint x, GLint y,
10036                            GLsizei width, GLint border)
10037 {
10038    GET_CURRENT_CONTEXT(ctx);
10039    Node *n;
10040    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10041    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE1D, 8);
10042    if (n) {
10043       n[1].e = texunit;
10044       n[2].e = target;
10045       n[3].i = level;
10046       n[4].e = internalformat;
10047       n[5].i = x;
10048       n[6].i = y;
10049       n[7].i = width;
10050       n[8].i = border;
10051    }
10052    if (ctx->ExecuteFlag) {
10053       CALL_CopyMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
10054                                              internalformat, x, y,
10055                                              width, border));
10056    }
10057 }
10058
10059
10060 void GLAPIENTRY
10061 save_CopyMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
10062                            GLenum internalformat,
10063                            GLint x, GLint y, GLsizei width,
10064                            GLsizei height, GLint border)
10065 {
10066    GET_CURRENT_CONTEXT(ctx);
10067    Node *n;
10068    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10069    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE2D, 9);
10070    if (n) {
10071       n[1].e = texunit;
10072       n[2].e = target;
10073       n[3].i = level;
10074       n[4].e = internalformat;
10075       n[5].i = x;
10076       n[6].i = y;
10077       n[7].i = width;
10078       n[8].i = height;
10079       n[9].i = border;
10080    }
10081    if (ctx->ExecuteFlag) {
10082       CALL_CopyMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
10083                                              internalformat, x, y,
10084                                              width, height, border));
10085    }
10086 }
10087
10088
10089 void GLAPIENTRY
10090 save_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level,
10091                               GLint xoffset, GLint x, GLint y, GLsizei width)
10092 {
10093    GET_CURRENT_CONTEXT(ctx);
10094    Node *n;
10095    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10096    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE1D, 7);
10097    if (n) {
10098       n[1].e = texunit;
10099       n[2].e = target;
10100       n[3].i = level;
10101       n[4].i = xoffset;
10102       n[5].i = x;
10103       n[6].i = y;
10104       n[7].i = width;
10105    }
10106    if (ctx->ExecuteFlag) {
10107       CALL_CopyMultiTexSubImage1DEXT(ctx->Exec,
10108                              (texunit, target, level, xoffset, x, y, width));
10109    }
10110 }
10111
10112
10113 void GLAPIENTRY
10114 save_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
10115                               GLint xoffset, GLint yoffset,
10116                               GLint x, GLint y, GLsizei width, GLint height)
10117 {
10118    GET_CURRENT_CONTEXT(ctx);
10119    Node *n;
10120    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10121    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE2D, 9);
10122    if (n) {
10123       n[1].e = texunit;
10124       n[2].e = target;
10125       n[3].i = level;
10126       n[4].i = xoffset;
10127       n[5].i = yoffset;
10128       n[6].i = x;
10129       n[7].i = y;
10130       n[8].i = width;
10131       n[9].i = height;
10132    }
10133    if (ctx->ExecuteFlag) {
10134       CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level,
10135                                                 xoffset, yoffset,
10136                                                 x, y, width, height));
10137    }
10138 }
10139
10140
10141 void GLAPIENTRY
10142 save_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
10143                               GLint xoffset, GLint yoffset, GLint zoffset,
10144                               GLint x, GLint y, GLsizei width, GLint height)
10145 {
10146    GET_CURRENT_CONTEXT(ctx);
10147    Node *n;
10148    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10149    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE3D, 10);
10150    if (n) {
10151       n[1].e = texunit;
10152       n[2].e = target;
10153       n[3].i = level;
10154       n[4].i = xoffset;
10155       n[5].i = yoffset;
10156       n[6].i = zoffset;
10157       n[7].i = x;
10158       n[8].i = y;
10159       n[9].i = width;
10160       n[10].i = height;
10161    }
10162    if (ctx->ExecuteFlag) {
10163       CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10164                                                 xoffset, yoffset, zoffset,
10165                                                 x, y, width, height));
10166    }
10167 }
10168
10169
10170 void GLAPIENTRY
10171 save_MultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
10172 {
10173    GET_CURRENT_CONTEXT(ctx);
10174    Node *n;
10175    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10176    n = alloc_instruction(ctx, OPCODE_MULTITEXENV, 7);
10177    if (n) {
10178       n[1].e = texunit;
10179       n[2].e = target;
10180       n[3].e = pname;
10181       if (pname == GL_TEXTURE_ENV_COLOR) {
10182          n[4].f = params[0];
10183          n[5].f = params[1];
10184          n[6].f = params[2];
10185          n[7].f = params[3];
10186       }
10187       else {
10188          n[4].f = params[0];
10189          n[5].f = n[6].f = n[7].f = 0.0F;
10190       }
10191    }
10192    if (ctx->ExecuteFlag) {
10193       CALL_MultiTexEnvfvEXT(ctx->Exec, (texunit, target, pname, params));
10194    }
10195 }
10196
10197
10198 void GLAPIENTRY
10199 save_MultiTexEnvfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
10200 {
10201    GLfloat parray[4];
10202    parray[0] = (GLfloat) param;
10203    parray[1] = parray[2] = parray[3] = 0.0F;
10204    save_MultiTexEnvfvEXT(texunit, target, pname, parray);
10205 }
10206
10207
10208 void GLAPIENTRY
10209 save_MultiTexEnviEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
10210 {
10211    GLfloat p[4];
10212    p[0] = (GLfloat) param;
10213    p[1] = p[2] = p[3] = 0.0F;
10214    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10215 }
10216
10217
10218 void GLAPIENTRY
10219 save_MultiTexEnvivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint * param)
10220 {
10221    GLfloat p[4];
10222    if (pname == GL_TEXTURE_ENV_COLOR) {
10223       p[0] = INT_TO_FLOAT(param[0]);
10224       p[1] = INT_TO_FLOAT(param[1]);
10225       p[2] = INT_TO_FLOAT(param[2]);
10226       p[3] = INT_TO_FLOAT(param[3]);
10227    }
10228    else {
10229       p[0] = (GLfloat) param[0];
10230       p[1] = p[2] = p[3] = 0.0F;
10231    }
10232    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10233 }
10234
10235
10236 void GLAPIENTRY
10237 save_CompressedTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
10238                                  GLenum internalFormat, GLsizei width,
10239                                  GLint border, GLsizei imageSize,
10240                                  const GLvoid * data)
10241 {
10242    GET_CURRENT_CONTEXT(ctx);
10243    if (target == GL_PROXY_TEXTURE_1D) {
10244       /* don't compile, execute immediately */
10245       CALL_CompressedTextureImage1DEXT(ctx->Exec, (texture, target, level,
10246                                                    internalFormat, width,
10247                                                    border, imageSize,
10248                                                    data));
10249    }
10250    else {
10251       Node *n;
10252       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10253
10254       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
10255                             7 + POINTER_DWORDS);
10256       if (n) {
10257          n[1].ui = texture;
10258          n[2].e = target;
10259          n[3].i = level;
10260          n[4].e = internalFormat;
10261          n[5].i = (GLint) width;
10262          n[6].i = border;
10263          n[7].i = imageSize;
10264          save_pointer(&n[8],
10265                       copy_data(data, imageSize, "glCompressedTextureImage1DEXT"));
10266       }
10267       if (ctx->ExecuteFlag) {
10268          CALL_CompressedTextureImage1DEXT(ctx->Exec,
10269                                           (texture, target, level, internalFormat,
10270                                            width, border, imageSize, data));
10271       }
10272    }
10273 }
10274
10275
10276 void GLAPIENTRY
10277 save_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
10278                                  GLenum internalFormat, GLsizei width,
10279                                  GLsizei height, GLint border, GLsizei imageSize,
10280                                  const GLvoid * data)
10281 {
10282    GET_CURRENT_CONTEXT(ctx);
10283    if (target == GL_PROXY_TEXTURE_2D) {
10284       /* don't compile, execute immediately */
10285       CALL_CompressedTextureImage2DEXT(ctx->Exec, (texture, target, level,
10286                                                    internalFormat, width, height,
10287                                                    border, imageSize, data));
10288    }
10289    else {
10290       Node *n;
10291       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10292
10293       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
10294                             8 + POINTER_DWORDS);
10295       if (n) {
10296          n[1].ui = texture;
10297          n[2].e = target;
10298          n[3].i = level;
10299          n[4].e = internalFormat;
10300          n[5].i = (GLint) width;
10301          n[6].i = (GLint) height;
10302          n[7].i = border;
10303          n[8].i = imageSize;
10304          save_pointer(&n[9],
10305                       copy_data(data, imageSize, "glCompressedTextureImage2DEXT"));
10306       }
10307       if (ctx->ExecuteFlag) {
10308          CALL_CompressedTextureImage2DEXT(ctx->Exec,
10309                                           (texture, target, level, internalFormat,
10310                                            width, height, border, imageSize, data));
10311       }
10312    }
10313 }
10314
10315
10316 void GLAPIENTRY
10317 save_CompressedTextureImage3DEXT(GLuint texture, GLenum target, GLint level,
10318                                  GLenum internalFormat, GLsizei width,
10319                                  GLsizei height, GLsizei depth, GLint border,
10320                                  GLsizei imageSize, const GLvoid * data)
10321 {
10322    GET_CURRENT_CONTEXT(ctx);
10323    if (target == GL_PROXY_TEXTURE_3D) {
10324       /* don't compile, execute immediately */
10325       CALL_CompressedTextureImage3DEXT(ctx->Exec, (texture, target, level,
10326                                                    internalFormat, width,
10327                                                    height, depth, border,
10328                                                    imageSize, data));
10329    }
10330    else {
10331       Node *n;
10332       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10333
10334       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
10335                             9 + POINTER_DWORDS);
10336       if (n) {
10337          n[1].ui = texture;
10338          n[2].e = target;
10339          n[3].i = level;
10340          n[4].e = internalFormat;
10341          n[5].i = (GLint) width;
10342          n[6].i = (GLint) height;
10343          n[7].i = (GLint) depth;
10344          n[8].i = border;
10345          n[9].i = imageSize;
10346          save_pointer(&n[10],
10347                       copy_data(data, imageSize, "glCompressedTextureImage3DEXT"));
10348       }
10349       if (ctx->ExecuteFlag) {
10350          CALL_CompressedTextureImage3DEXT(ctx->Exec,
10351                                           (texture, target, level, internalFormat,
10352                                            width, height, depth, border, imageSize,
10353                                            data));
10354       }
10355    }
10356 }
10357
10358
10359 void GLAPIENTRY
10360 save_CompressedTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10361                                     GLsizei width, GLenum format,
10362                                     GLsizei imageSize, const GLvoid * data)
10363 {
10364    Node *n;
10365    GET_CURRENT_CONTEXT(ctx);
10366    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10367
10368    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
10369                          7 + POINTER_DWORDS);
10370    if (n) {
10371       n[1].ui = texture;
10372       n[2].e = target;
10373       n[3].i = level;
10374       n[4].i = xoffset;
10375       n[5].i = (GLint) width;
10376       n[6].e = format;
10377       n[7].i = imageSize;
10378       save_pointer(&n[8],
10379                    copy_data(data, imageSize, "glCompressedTextureSubImage1DEXT"));
10380    }
10381    if (ctx->ExecuteFlag) {
10382       CALL_CompressedTextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset,
10383                                                       width, format, imageSize, data));
10384    }
10385 }
10386
10387
10388 void GLAPIENTRY
10389 save_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10390                                     GLint yoffset, GLsizei width, GLsizei height,
10391                                     GLenum format, GLsizei imageSize,
10392                                     const GLvoid * data)
10393 {
10394    Node *n;
10395    GET_CURRENT_CONTEXT(ctx);
10396    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10397
10398    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
10399                          9 + POINTER_DWORDS);
10400    if (n) {
10401       n[1].ui = texture;
10402       n[2].e = target;
10403       n[3].i = level;
10404       n[4].i = xoffset;
10405       n[5].i = yoffset;
10406       n[6].i = (GLint) width;
10407       n[7].i = (GLint) height;
10408       n[8].e = format;
10409       n[9].i = imageSize;
10410       save_pointer(&n[10],
10411                    copy_data(data, imageSize, "glCompressedTextureSubImage2DEXT"));
10412    }
10413    if (ctx->ExecuteFlag) {
10414       CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
10415                                           (texture, target, level, xoffset, yoffset,
10416                                            width, height, format, imageSize, data));
10417    }
10418 }
10419
10420
10421 void GLAPIENTRY
10422 save_CompressedTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10423                                     GLint yoffset, GLint zoffset, GLsizei width,
10424                                     GLsizei height, GLsizei depth, GLenum format,
10425                                     GLsizei imageSize, const GLvoid * data)
10426 {
10427    Node *n;
10428    GET_CURRENT_CONTEXT(ctx);
10429    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10430
10431    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
10432                          11 + POINTER_DWORDS);
10433    if (n) {
10434       n[1].ui = texture;
10435       n[2].e = target;
10436       n[3].i = level;
10437       n[4].i = xoffset;
10438       n[5].i = yoffset;
10439       n[6].i = zoffset;
10440       n[7].i = (GLint) width;
10441       n[8].i = (GLint) height;
10442       n[9].i = (GLint) depth;
10443       n[10].e = format;
10444       n[11].i = imageSize;
10445       save_pointer(&n[12],
10446                    copy_data(data, imageSize, "glCompressedTextureSubImage3DEXT"));
10447    }
10448    if (ctx->ExecuteFlag) {
10449       CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
10450                                           (texture, target, level, xoffset, yoffset,
10451                                            zoffset, width, height, depth, format,
10452                                            imageSize, data));
10453    }
10454 }
10455
10456
10457 void GLAPIENTRY
10458 save_CompressedMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
10459                                   GLenum internalFormat, GLsizei width,
10460                                   GLint border, GLsizei imageSize,
10461                                   const GLvoid * data)
10462 {
10463    GET_CURRENT_CONTEXT(ctx);
10464    if (target == GL_PROXY_TEXTURE_1D) {
10465       /* don't compile, execute immediately */
10466       CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
10467                                                    internalFormat, width,
10468                                                    border, imageSize,
10469                                                    data));
10470    }
10471    else {
10472       Node *n;
10473       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10474
10475       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
10476                             7 + POINTER_DWORDS);
10477       if (n) {
10478          n[1].e = texunit;
10479          n[2].e = target;
10480          n[3].i = level;
10481          n[4].e = internalFormat;
10482          n[5].i = (GLint) width;
10483          n[6].i = border;
10484          n[7].i = imageSize;
10485          save_pointer(&n[8],
10486                       copy_data(data, imageSize, "glCompressedMultiTexImage1DEXT"));
10487       }
10488       if (ctx->ExecuteFlag) {
10489          CALL_CompressedMultiTexImage1DEXT(ctx->Exec,
10490                                            (texunit, target, level, internalFormat,
10491                                             width, border, imageSize, data));
10492       }
10493    }
10494 }
10495
10496
10497 void GLAPIENTRY
10498 save_CompressedMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
10499                                   GLenum internalFormat, GLsizei width,
10500                                   GLsizei height, GLint border, GLsizei imageSize,
10501                                   const GLvoid * data)
10502 {
10503    GET_CURRENT_CONTEXT(ctx);
10504    if (target == GL_PROXY_TEXTURE_2D) {
10505       /* don't compile, execute immediately */
10506       CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
10507                                                    internalFormat, width, height,
10508                                                    border, imageSize, data));
10509    }
10510    else {
10511       Node *n;
10512       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10513
10514       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
10515                             8 + POINTER_DWORDS);
10516       if (n) {
10517          n[1].e = texunit;
10518          n[2].e = target;
10519          n[3].i = level;
10520          n[4].e = internalFormat;
10521          n[5].i = (GLint) width;
10522          n[6].i = (GLint) height;
10523          n[7].i = border;
10524          n[8].i = imageSize;
10525          save_pointer(&n[9],
10526                       copy_data(data, imageSize, "glCompressedMultiTexImage2DEXT"));
10527       }
10528       if (ctx->ExecuteFlag) {
10529          CALL_CompressedMultiTexImage2DEXT(ctx->Exec,
10530                                            (texunit, target, level, internalFormat,
10531                                             width, height, border, imageSize, data));
10532       }
10533    }
10534 }
10535
10536
10537 void GLAPIENTRY
10538 save_CompressedMultiTexImage3DEXT(GLenum texunit, GLenum target, GLint level,
10539                                   GLenum internalFormat, GLsizei width,
10540                                   GLsizei height, GLsizei depth, GLint border,
10541                                   GLsizei imageSize, const GLvoid * data)
10542 {
10543    GET_CURRENT_CONTEXT(ctx);
10544    if (target == GL_PROXY_TEXTURE_3D) {
10545       /* don't compile, execute immediately */
10546       CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (texunit, target, level,
10547                                                    internalFormat, width,
10548                                                    height, depth, border,
10549                                                    imageSize, data));
10550    }
10551    else {
10552       Node *n;
10553       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10554
10555       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
10556                             9 + POINTER_DWORDS);
10557       if (n) {
10558          n[1].e = texunit;
10559          n[2].e = target;
10560          n[3].i = level;
10561          n[4].e = internalFormat;
10562          n[5].i = (GLint) width;
10563          n[6].i = (GLint) height;
10564          n[7].i = (GLint) depth;
10565          n[8].i = border;
10566          n[9].i = imageSize;
10567          save_pointer(&n[10],
10568                       copy_data(data, imageSize, "glCompressedMultiTexImage3DEXT"));
10569       }
10570       if (ctx->ExecuteFlag) {
10571          CALL_CompressedMultiTexImage3DEXT(ctx->Exec,
10572                                            (texunit, target, level, internalFormat,
10573                                             width, height, depth, border, imageSize,
10574                                             data));
10575       }
10576    }
10577 }
10578
10579
10580 void GLAPIENTRY
10581 save_CompressedMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10582                                      GLsizei width, GLenum format,
10583                                      GLsizei imageSize, const GLvoid * data)
10584 {
10585    Node *n;
10586    GET_CURRENT_CONTEXT(ctx);
10587    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10588
10589    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
10590                          7 + POINTER_DWORDS);
10591    if (n) {
10592       n[1].e = texunit;
10593       n[2].e = target;
10594       n[3].i = level;
10595       n[4].i = xoffset;
10596       n[5].i = (GLint) width;
10597       n[6].e = format;
10598       n[7].i = imageSize;
10599       save_pointer(&n[8],
10600                    copy_data(data, imageSize, "glCompressedMultiTexSubImage1DEXT"));
10601    }
10602    if (ctx->ExecuteFlag) {
10603       CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset,
10604                                                        width, format, imageSize, data));
10605    }
10606 }
10607
10608
10609 void GLAPIENTRY
10610 save_CompressedMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10611                                      GLint yoffset, GLsizei width, GLsizei height,
10612                                      GLenum format, GLsizei imageSize,
10613                                      const GLvoid * data)
10614 {
10615    Node *n;
10616    GET_CURRENT_CONTEXT(ctx);
10617    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10618
10619    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
10620                          9 + POINTER_DWORDS);
10621    if (n) {
10622       n[1].e = texunit;
10623       n[2].e = target;
10624       n[3].i = level;
10625       n[4].i = xoffset;
10626       n[5].i = yoffset;
10627       n[6].i = (GLint) width;
10628       n[7].i = (GLint) height;
10629       n[8].e = format;
10630       n[9].i = imageSize;
10631       save_pointer(&n[10],
10632                    copy_data(data, imageSize, "glCompressedMultiTexSubImage2DEXT"));
10633    }
10634    if (ctx->ExecuteFlag) {
10635       CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
10636                                            (texunit, target, level, xoffset, yoffset,
10637                                             width, height, format, imageSize, data));
10638    }
10639 }
10640
10641
10642 void GLAPIENTRY
10643 save_CompressedMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10644                                      GLint yoffset, GLint zoffset, GLsizei width,
10645                                      GLsizei height, GLsizei depth, GLenum format,
10646                                      GLsizei imageSize, const GLvoid * data)
10647 {
10648    Node *n;
10649    GET_CURRENT_CONTEXT(ctx);
10650    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10651
10652    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
10653                          11 + POINTER_DWORDS);
10654    if (n) {
10655       n[1].e = texunit;
10656       n[2].e = target;
10657       n[3].i = level;
10658       n[4].i = xoffset;
10659       n[5].i = yoffset;
10660       n[6].i = zoffset;
10661       n[7].i = (GLint) width;
10662       n[8].i = (GLint) height;
10663       n[9].i = (GLint) depth;
10664       n[10].e = format;
10665       n[11].i = imageSize;
10666       save_pointer(&n[12],
10667                    copy_data(data, imageSize, "glCompressedMultiTexSubImage3DEXT"));
10668    }
10669    if (ctx->ExecuteFlag) {
10670       CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
10671                                            (texunit, target, level, xoffset, yoffset,
10672                                             zoffset, width, height, depth, format,
10673                                             imageSize, data));
10674    }
10675 }
10676
10677
10678 void GLAPIENTRY
10679 save_NamedProgramStringEXT(GLuint program, GLenum target, GLenum format, GLsizei len,
10680                            const GLvoid * string)
10681 {
10682    GET_CURRENT_CONTEXT(ctx);
10683    Node *n;
10684
10685    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10686
10687    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_STRING, 4 + POINTER_DWORDS);
10688    if (n) {
10689       GLubyte *programCopy = malloc(len);
10690       if (!programCopy) {
10691          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNamedProgramStringEXT");
10692          return;
10693       }
10694       memcpy(programCopy, string, len);
10695       n[1].ui = program;
10696       n[2].e = target;
10697       n[3].e = format;
10698       n[4].i = len;
10699       save_pointer(&n[5], programCopy);
10700    }
10701    if (ctx->ExecuteFlag) {
10702       CALL_NamedProgramStringEXT(ctx->Exec, (program, target, format, len, string));
10703    }
10704 }
10705
10706
10707 void GLAPIENTRY
10708 save_NamedProgramLocalParameter4fEXT(GLuint program, GLenum target, GLuint index,
10709                                      GLfloat x, GLfloat y, GLfloat z, GLfloat w)
10710 {
10711    GET_CURRENT_CONTEXT(ctx);
10712    Node *n;
10713    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10714    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER, 7);
10715    if (n) {
10716       n[1].ui = program;
10717       n[2].e = target;
10718       n[3].ui = index;
10719       n[4].f = x;
10720       n[5].f = y;
10721       n[6].f = z;
10722       n[7].f = w;
10723    }
10724    if (ctx->ExecuteFlag) {
10725       CALL_NamedProgramLocalParameter4fEXT(ctx->Exec, (program, target, index, x, y, z, w));
10726    }
10727 }
10728
10729
10730 void GLAPIENTRY
10731 save_NamedProgramLocalParameter4fvEXT(GLuint program, GLenum target, GLuint index,
10732                                       const GLfloat *params)
10733 {
10734    save_NamedProgramLocalParameter4fEXT(program, target, index, params[0],
10735                                         params[1], params[2], params[3]);
10736 }
10737
10738
10739 void GLAPIENTRY
10740 save_NamedProgramLocalParameter4dEXT(GLuint program, GLenum target, GLuint index,
10741                                     GLdouble x, GLdouble y,
10742                                     GLdouble z, GLdouble w)
10743 {
10744       save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) x,
10745                                            (GLfloat) y, (GLfloat) z, (GLfloat) w);
10746 }
10747
10748
10749 void GLAPIENTRY
10750 save_NamedProgramLocalParameter4dvEXT(GLuint program, GLenum target, GLuint index,
10751                                       const GLdouble *params)
10752 {
10753    save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) params[0],
10754                                         (GLfloat) params[1], (GLfloat) params[2],
10755                                         (GLfloat) params[3]);
10756 }
10757
10758 void GLAPIENTRY
10759 save_PrimitiveBoundingBox(float minX, float minY, float minZ, float minW,
10760                           float maxX, float maxY, float maxZ, float maxW)
10761 {
10762    GET_CURRENT_CONTEXT(ctx);
10763    Node *n;
10764    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10765    n = alloc_instruction(ctx, OPCODE_PRIMITIVE_BOUNDING_BOX, 8);
10766    if (n) {
10767       n[1].f = minX;
10768       n[2].f = minY;
10769       n[3].f = minZ;
10770       n[4].f = minW;
10771       n[5].f = maxX;
10772       n[6].f = maxY;
10773       n[7].f = maxZ;
10774       n[8].f = maxW;
10775    }
10776    if (ctx->ExecuteFlag) {
10777       CALL_PrimitiveBoundingBox(ctx->Exec, (minX, minY, minZ, minW,
10778                                             maxX, maxY, maxZ, maxW));
10779    }
10780 }
10781
10782 /**
10783  * Save an error-generating command into display list.
10784  *
10785  * KW: Will appear in the list before the vertex buffer containing the
10786  * command that provoked the error.  I don't see this as a problem.
10787  */
10788 static void
10789 save_error(struct gl_context *ctx, GLenum error, const char *s)
10790 {
10791    Node *n;
10792    n = alloc_instruction(ctx, OPCODE_ERROR, 1 + POINTER_DWORDS);
10793    if (n) {
10794       n[1].e = error;
10795       save_pointer(&n[2], (void *) s);
10796       /* note: the data/string here doesn't have to be freed in
10797        * _mesa_delete_list() since the string is never dynamically
10798        * allocated.
10799        */
10800    }
10801 }
10802
10803
10804 /**
10805  * Compile an error into current display list.
10806  */
10807 void
10808 _mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s)
10809 {
10810    if (ctx->CompileFlag)
10811       save_error(ctx, error, s);
10812    if (ctx->ExecuteFlag)
10813       _mesa_error(ctx, error, "%s", s);
10814 }
10815
10816
10817 /**
10818  * Test if ID names a display list.
10819  */
10820 bool
10821 _mesa_get_list(struct gl_context *ctx, GLuint list,
10822                struct gl_display_list **dlist,
10823                bool locked)
10824 {
10825    struct gl_display_list * dl =
10826       list > 0 ? _mesa_lookup_list(ctx, list, locked) : NULL;
10827
10828    if (dlist)
10829       *dlist = dl;
10830
10831    return dl != NULL;
10832 }
10833
10834
10835
10836 /**********************************************************************/
10837 /*                     Display list execution                         */
10838 /**********************************************************************/
10839
10840
10841 /*
10842  * Execute a display list.  Note that the ListBase offset must have already
10843  * been added before calling this function.  I.e. the list argument is
10844  * the absolute list number, not relative to ListBase.
10845  * Must be called with ctx->Shared->DisplayList locked.
10846  * \param list - display list number
10847  */
10848 static void
10849 execute_list(struct gl_context *ctx, GLuint list)
10850 {
10851    struct gl_display_list *dlist;
10852    Node *n;
10853
10854    if (list == 0 || !_mesa_get_list(ctx, list, &dlist, true))
10855       return;
10856
10857    n = get_list_head(ctx, dlist);
10858
10859    while (1) {
10860       const OpCode opcode = n[0].opcode;
10861
10862       switch (opcode) {
10863          case OPCODE_ERROR:
10864             _mesa_error(ctx, n[1].e, "%s", (const char *) get_pointer(&n[2]));
10865             break;
10866          case OPCODE_ACCUM:
10867             CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
10868             break;
10869          case OPCODE_ALPHA_FUNC:
10870             CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
10871             break;
10872          case OPCODE_BIND_TEXTURE:
10873             CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
10874             break;
10875          case OPCODE_BITMAP:
10876             if (_mesa_inside_begin_end(ctx)) {
10877                _mesa_error(ctx, GL_INVALID_OPERATION,
10878                            "glCallList -> glBitmap inside Begin/End");
10879             } else {
10880                _mesa_bitmap(ctx, n[1].i, n[2].i, n[3].f, n[4].f, n[5].f,
10881                             n[6].f, NULL, get_pointer(&n[7]));
10882             }
10883             break;
10884          case OPCODE_BLEND_COLOR:
10885             CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
10886             break;
10887          case OPCODE_BLEND_EQUATION:
10888             CALL_BlendEquation(ctx->Exec, (n[1].e));
10889             break;
10890          case OPCODE_BLEND_EQUATION_SEPARATE:
10891             CALL_BlendEquationSeparate(ctx->Exec, (n[1].e, n[2].e));
10892             break;
10893          case OPCODE_BLEND_FUNC_SEPARATE:
10894             CALL_BlendFuncSeparate(ctx->Exec,
10895                                       (n[1].e, n[2].e, n[3].e, n[4].e));
10896             break;
10897
10898          case OPCODE_BLEND_FUNC_I:
10899             /* GL_ARB_draw_buffers_blend */
10900             CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e));
10901             break;
10902          case OPCODE_BLEND_FUNC_SEPARATE_I:
10903             /* GL_ARB_draw_buffers_blend */
10904             CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e,
10905                                                    n[4].e, n[5].e));
10906             break;
10907          case OPCODE_BLEND_EQUATION_I:
10908             /* GL_ARB_draw_buffers_blend */
10909             CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e));
10910             break;
10911          case OPCODE_BLEND_EQUATION_SEPARATE_I:
10912             /* GL_ARB_draw_buffers_blend */
10913             CALL_BlendEquationSeparateiARB(ctx->Exec,
10914                                            (n[1].ui, n[2].e, n[3].e));
10915             break;
10916
10917          case OPCODE_CALL_LIST:
10918             /* Generated by glCallList(), don't add ListBase */
10919             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
10920                ctx->ListState.CallDepth++;
10921                execute_list(ctx, n[1].ui);
10922                ctx->ListState.CallDepth--;
10923             }
10924             break;
10925          case OPCODE_CALL_LISTS:
10926             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
10927                ctx->ListState.CallDepth++;
10928                _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
10929                CALL_CallLists(ctx->Exec, (n[1].i, n[2].e, get_pointer(&n[3])));
10930                _mesa_HashLockMutex(ctx->Shared->DisplayList);
10931                ctx->ListState.CallDepth--;
10932             }
10933             break;
10934          case OPCODE_CLEAR:
10935             CALL_Clear(ctx->Exec, (n[1].bf));
10936             break;
10937          case OPCODE_CLEAR_BUFFER_IV:
10938             {
10939                GLint value[4];
10940                value[0] = n[3].i;
10941                value[1] = n[4].i;
10942                value[2] = n[5].i;
10943                value[3] = n[6].i;
10944                CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));
10945             }
10946             break;
10947          case OPCODE_CLEAR_BUFFER_UIV:
10948             {
10949                GLuint value[4];
10950                value[0] = n[3].ui;
10951                value[1] = n[4].ui;
10952                value[2] = n[5].ui;
10953                value[3] = n[6].ui;
10954                CALL_ClearBufferuiv(ctx->Exec, (n[1].e, n[2].i, value));
10955             }
10956             break;
10957          case OPCODE_CLEAR_BUFFER_FV:
10958             {
10959                GLfloat value[4];
10960                value[0] = n[3].f;
10961                value[1] = n[4].f;
10962                value[2] = n[5].f;
10963                value[3] = n[6].f;
10964                CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));
10965             }
10966             break;
10967          case OPCODE_CLEAR_BUFFER_FI:
10968             CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));
10969             break;
10970          case OPCODE_CLEAR_COLOR:
10971             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
10972             break;
10973          case OPCODE_CLEAR_ACCUM:
10974             CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
10975             break;
10976          case OPCODE_CLEAR_DEPTH:
10977             CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
10978             break;
10979          case OPCODE_CLEAR_INDEX:
10980             CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
10981             break;
10982          case OPCODE_CLEAR_STENCIL:
10983             CALL_ClearStencil(ctx->Exec, (n[1].i));
10984             break;
10985          case OPCODE_CLIP_PLANE:
10986             {
10987                GLdouble eq[4];
10988                eq[0] = n[2].f;
10989                eq[1] = n[3].f;
10990                eq[2] = n[4].f;
10991                eq[3] = n[5].f;
10992                CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
10993             }
10994             break;
10995          case OPCODE_COLOR_MASK:
10996             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
10997             break;
10998          case OPCODE_COLOR_MASK_INDEXED:
10999             CALL_ColorMaski(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
11000                                                  n[4].b, n[5].b));
11001             break;
11002          case OPCODE_COLOR_MATERIAL:
11003             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
11004             break;
11005          case OPCODE_COPY_PIXELS:
11006             CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
11007                                         (GLsizei) n[3].i, (GLsizei) n[4].i,
11008                                         n[5].e));
11009             break;
11010          case OPCODE_COPY_TEX_IMAGE1D:
11011             CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11012                                             n[5].i, n[6].i, n[7].i));
11013             break;
11014          case OPCODE_COPY_TEX_IMAGE2D:
11015             CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11016                                             n[5].i, n[6].i, n[7].i, n[8].i));
11017             break;
11018          case OPCODE_COPY_TEX_SUB_IMAGE1D:
11019             CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11020                                                n[4].i, n[5].i, n[6].i));
11021             break;
11022          case OPCODE_COPY_TEX_SUB_IMAGE2D:
11023             CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11024                                                n[4].i, n[5].i, n[6].i, n[7].i,
11025                                                n[8].i));
11026             break;
11027          case OPCODE_COPY_TEX_SUB_IMAGE3D:
11028             CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11029                                                n[4].i, n[5].i, n[6].i, n[7].i,
11030                                                n[8].i, n[9].i));
11031             break;
11032          case OPCODE_CULL_FACE:
11033             CALL_CullFace(ctx->Exec, (n[1].e));
11034             break;
11035          case OPCODE_DEPTH_FUNC:
11036             CALL_DepthFunc(ctx->Exec, (n[1].e));
11037             break;
11038          case OPCODE_DEPTH_MASK:
11039             CALL_DepthMask(ctx->Exec, (n[1].b));
11040             break;
11041          case OPCODE_DEPTH_RANGE:
11042             CALL_DepthRange(ctx->Exec,
11043                             ((GLclampd) n[1].f, (GLclampd) n[2].f));
11044             break;
11045          case OPCODE_DISABLE:
11046             CALL_Disable(ctx->Exec, (n[1].e));
11047             break;
11048          case OPCODE_DISABLE_INDEXED:
11049             CALL_Disablei(ctx->Exec, (n[1].ui, n[2].e));
11050             break;
11051          case OPCODE_DRAW_BUFFER:
11052             CALL_DrawBuffer(ctx->Exec, (n[1].e));
11053             break;
11054          case OPCODE_DRAW_PIXELS:
11055             {
11056                const struct gl_pixelstore_attrib save = ctx->Unpack;
11057                ctx->Unpack = ctx->DefaultPacking;
11058                CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
11059                                            get_pointer(&n[5])));
11060                ctx->Unpack = save;      /* restore */
11061             }
11062             break;
11063          case OPCODE_ENABLE:
11064             CALL_Enable(ctx->Exec, (n[1].e));
11065             break;
11066          case OPCODE_ENABLE_INDEXED:
11067             CALL_Enablei(ctx->Exec, (n[1].ui, n[2].e));
11068             break;
11069          case OPCODE_EVALMESH1:
11070             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
11071             break;
11072          case OPCODE_EVALMESH2:
11073             CALL_EvalMesh2(ctx->Exec,
11074                            (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
11075             break;
11076          case OPCODE_FOG:
11077             {
11078                GLfloat p[4];
11079                p[0] = n[2].f;
11080                p[1] = n[3].f;
11081                p[2] = n[4].f;
11082                p[3] = n[5].f;
11083                CALL_Fogfv(ctx->Exec, (n[1].e, p));
11084             }
11085             break;
11086          case OPCODE_FRONT_FACE:
11087             CALL_FrontFace(ctx->Exec, (n[1].e));
11088             break;
11089          case OPCODE_FRUSTUM:
11090             CALL_Frustum(ctx->Exec,
11091                          (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11092             break;
11093          case OPCODE_HINT:
11094             CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
11095             break;
11096          case OPCODE_INDEX_MASK:
11097             CALL_IndexMask(ctx->Exec, (n[1].ui));
11098             break;
11099          case OPCODE_INIT_NAMES:
11100             CALL_InitNames(ctx->Exec, ());
11101             break;
11102          case OPCODE_LIGHT:
11103             {
11104                GLfloat p[4];
11105                p[0] = n[3].f;
11106                p[1] = n[4].f;
11107                p[2] = n[5].f;
11108                p[3] = n[6].f;
11109                CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
11110             }
11111             break;
11112          case OPCODE_LIGHT_MODEL:
11113             {
11114                GLfloat p[4];
11115                p[0] = n[2].f;
11116                p[1] = n[3].f;
11117                p[2] = n[4].f;
11118                p[3] = n[5].f;
11119                CALL_LightModelfv(ctx->Exec, (n[1].e, p));
11120             }
11121             break;
11122          case OPCODE_LINE_STIPPLE:
11123             CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
11124             break;
11125          case OPCODE_LINE_WIDTH:
11126             CALL_LineWidth(ctx->Exec, (n[1].f));
11127             break;
11128          case OPCODE_LIST_BASE:
11129             CALL_ListBase(ctx->Exec, (n[1].ui));
11130             break;
11131          case OPCODE_LOAD_IDENTITY:
11132             CALL_LoadIdentity(ctx->Exec, ());
11133             break;
11134          case OPCODE_LOAD_MATRIX:
11135             STATIC_ASSERT(sizeof(Node) == sizeof(GLfloat));
11136             CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
11137             break;
11138          case OPCODE_LOAD_NAME:
11139             CALL_LoadName(ctx->Exec, (n[1].ui));
11140             break;
11141          case OPCODE_LOGIC_OP:
11142             CALL_LogicOp(ctx->Exec, (n[1].e));
11143             break;
11144          case OPCODE_MAP1:
11145             {
11146                GLenum target = n[1].e;
11147                GLint ustride = _mesa_evaluator_components(target);
11148                GLint uorder = n[5].i;
11149                GLfloat u1 = n[2].f;
11150                GLfloat u2 = n[3].f;
11151                CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
11152                                       (GLfloat *) get_pointer(&n[6])));
11153             }
11154             break;
11155          case OPCODE_MAP2:
11156             {
11157                GLenum target = n[1].e;
11158                GLfloat u1 = n[2].f;
11159                GLfloat u2 = n[3].f;
11160                GLfloat v1 = n[4].f;
11161                GLfloat v2 = n[5].f;
11162                GLint ustride = n[6].i;
11163                GLint vstride = n[7].i;
11164                GLint uorder = n[8].i;
11165                GLint vorder = n[9].i;
11166                CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
11167                                       v1, v2, vstride, vorder,
11168                                       (GLfloat *) get_pointer(&n[10])));
11169             }
11170             break;
11171          case OPCODE_MAPGRID1:
11172             CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
11173             break;
11174          case OPCODE_MAPGRID2:
11175             CALL_MapGrid2f(ctx->Exec,
11176                            (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
11177             break;
11178          case OPCODE_MATRIX_MODE:
11179             CALL_MatrixMode(ctx->Exec, (n[1].e));
11180             break;
11181          case OPCODE_MULT_MATRIX:
11182             CALL_MultMatrixf(ctx->Exec, (&n[1].f));
11183             break;
11184          case OPCODE_ORTHO:
11185             CALL_Ortho(ctx->Exec,
11186                        (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11187             break;
11188          case OPCODE_PASSTHROUGH:
11189             CALL_PassThrough(ctx->Exec, (n[1].f));
11190             break;
11191          case OPCODE_PATCH_PARAMETER_I:
11192             CALL_PatchParameteri(ctx->Exec, (n[1].e, n[2].i));
11193             break;
11194          case OPCODE_PATCH_PARAMETER_FV_INNER:
11195             {
11196                GLfloat params[2];
11197                params[0] = n[2].f;
11198                params[1] = n[3].f;
11199                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11200             }
11201             break;
11202          case OPCODE_PATCH_PARAMETER_FV_OUTER:
11203             {
11204                GLfloat params[4];
11205                params[0] = n[2].f;
11206                params[1] = n[3].f;
11207                params[2] = n[4].f;
11208                params[3] = n[5].f;
11209                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11210             }
11211             break;
11212          case OPCODE_PIXEL_MAP:
11213             CALL_PixelMapfv(ctx->Exec,
11214                             (n[1].e, n[2].i, get_pointer(&n[3])));
11215             break;
11216          case OPCODE_PIXEL_TRANSFER:
11217             CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
11218             break;
11219          case OPCODE_PIXEL_ZOOM:
11220             CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
11221             break;
11222          case OPCODE_POINT_SIZE:
11223             CALL_PointSize(ctx->Exec, (n[1].f));
11224             break;
11225          case OPCODE_POINT_PARAMETERS:
11226             {
11227                GLfloat params[3];
11228                params[0] = n[2].f;
11229                params[1] = n[3].f;
11230                params[2] = n[4].f;
11231                CALL_PointParameterfv(ctx->Exec, (n[1].e, params));
11232             }
11233             break;
11234          case OPCODE_POLYGON_MODE:
11235             CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
11236             break;
11237          case OPCODE_POLYGON_STIPPLE:
11238             {
11239                const struct gl_pixelstore_attrib save = ctx->Unpack;
11240                ctx->Unpack = ctx->DefaultPacking;
11241                CALL_PolygonStipple(ctx->Exec, (get_pointer(&n[1])));
11242                ctx->Unpack = save;      /* restore */
11243             }
11244             break;
11245          case OPCODE_POLYGON_OFFSET:
11246             CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
11247             break;
11248          case OPCODE_POLYGON_OFFSET_CLAMP:
11249             CALL_PolygonOffsetClampEXT(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11250             break;
11251          case OPCODE_POP_ATTRIB:
11252             CALL_PopAttrib(ctx->Exec, ());
11253             break;
11254          case OPCODE_POP_MATRIX:
11255             CALL_PopMatrix(ctx->Exec, ());
11256             break;
11257          case OPCODE_POP_NAME:
11258             CALL_PopName(ctx->Exec, ());
11259             break;
11260          case OPCODE_PRIORITIZE_TEXTURE:
11261             CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
11262             break;
11263          case OPCODE_PUSH_ATTRIB:
11264             CALL_PushAttrib(ctx->Exec, (n[1].bf));
11265             break;
11266          case OPCODE_PUSH_MATRIX:
11267             CALL_PushMatrix(ctx->Exec, ());
11268             break;
11269          case OPCODE_PUSH_NAME:
11270             CALL_PushName(ctx->Exec, (n[1].ui));
11271             break;
11272          case OPCODE_RASTER_POS:
11273             CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11274             break;
11275          case OPCODE_READ_BUFFER:
11276             CALL_ReadBuffer(ctx->Exec, (n[1].e));
11277             break;
11278          case OPCODE_ROTATE:
11279             CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11280             break;
11281          case OPCODE_SCALE:
11282             CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11283             break;
11284          case OPCODE_SCISSOR:
11285             CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
11286             break;
11287          case OPCODE_SHADE_MODEL:
11288             CALL_ShadeModel(ctx->Exec, (n[1].e));
11289             break;
11290          case OPCODE_PROVOKING_VERTEX:
11291             CALL_ProvokingVertex(ctx->Exec, (n[1].e));
11292             break;
11293          case OPCODE_STENCIL_FUNC:
11294             CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
11295             break;
11296          case OPCODE_STENCIL_MASK:
11297             CALL_StencilMask(ctx->Exec, (n[1].ui));
11298             break;
11299          case OPCODE_STENCIL_OP:
11300             CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
11301             break;
11302          case OPCODE_STENCIL_FUNC_SEPARATE:
11303             CALL_StencilFuncSeparate(ctx->Exec,
11304                                      (n[1].e, n[2].e, n[3].i, n[4].ui));
11305             break;
11306          case OPCODE_STENCIL_MASK_SEPARATE:
11307             CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
11308             break;
11309          case OPCODE_STENCIL_OP_SEPARATE:
11310             CALL_StencilOpSeparate(ctx->Exec,
11311                                    (n[1].e, n[2].e, n[3].e, n[4].e));
11312             break;
11313          case OPCODE_TEXENV:
11314             {
11315                GLfloat params[4];
11316                params[0] = n[3].f;
11317                params[1] = n[4].f;
11318                params[2] = n[5].f;
11319                params[3] = n[6].f;
11320                CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
11321             }
11322             break;
11323          case OPCODE_TEXGEN:
11324             {
11325                GLfloat params[4];
11326                params[0] = n[3].f;
11327                params[1] = n[4].f;
11328                params[2] = n[5].f;
11329                params[3] = n[6].f;
11330                CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
11331             }
11332             break;
11333          case OPCODE_TEXPARAMETER:
11334             {
11335                GLfloat params[4];
11336                params[0] = n[3].f;
11337                params[1] = n[4].f;
11338                params[2] = n[5].f;
11339                params[3] = n[6].f;
11340                CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
11341             }
11342             break;
11343          case OPCODE_TEX_IMAGE1D:
11344             {
11345                const struct gl_pixelstore_attrib save = ctx->Unpack;
11346                ctx->Unpack = ctx->DefaultPacking;
11347                CALL_TexImage1D(ctx->Exec, (n[1].e,      /* target */
11348                                            n[2].i,      /* level */
11349                                            n[3].i,      /* components */
11350                                            n[4].i,      /* width */
11351                                            n[5].e,      /* border */
11352                                            n[6].e,      /* format */
11353                                            n[7].e,      /* type */
11354                                            get_pointer(&n[8])));
11355                ctx->Unpack = save;      /* restore */
11356             }
11357             break;
11358          case OPCODE_TEX_IMAGE2D:
11359             {
11360                const struct gl_pixelstore_attrib save = ctx->Unpack;
11361                ctx->Unpack = ctx->DefaultPacking;
11362                CALL_TexImage2D(ctx->Exec, (n[1].e,      /* target */
11363                                            n[2].i,      /* level */
11364                                            n[3].i,      /* components */
11365                                            n[4].i,      /* width */
11366                                            n[5].i,      /* height */
11367                                            n[6].e,      /* border */
11368                                            n[7].e,      /* format */
11369                                            n[8].e,      /* type */
11370                                            get_pointer(&n[9])));
11371                ctx->Unpack = save;      /* restore */
11372             }
11373             break;
11374          case OPCODE_TEX_IMAGE3D:
11375             {
11376                const struct gl_pixelstore_attrib save = ctx->Unpack;
11377                ctx->Unpack = ctx->DefaultPacking;
11378                CALL_TexImage3D(ctx->Exec, (n[1].e,      /* target */
11379                                            n[2].i,      /* level */
11380                                            n[3].i,      /* components */
11381                                            n[4].i,      /* width */
11382                                            n[5].i,      /* height */
11383                                            n[6].i,      /* depth  */
11384                                            n[7].e,      /* border */
11385                                            n[8].e,      /* format */
11386                                            n[9].e,      /* type */
11387                                            get_pointer(&n[10])));
11388                ctx->Unpack = save;      /* restore */
11389             }
11390             break;
11391          case OPCODE_TEX_SUB_IMAGE1D:
11392             {
11393                const struct gl_pixelstore_attrib save = ctx->Unpack;
11394                ctx->Unpack = ctx->DefaultPacking;
11395                CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11396                                               n[4].i, n[5].e,
11397                                               n[6].e, get_pointer(&n[7])));
11398                ctx->Unpack = save;      /* restore */
11399             }
11400             break;
11401          case OPCODE_TEX_SUB_IMAGE2D:
11402             {
11403                const struct gl_pixelstore_attrib save = ctx->Unpack;
11404                ctx->Unpack = ctx->DefaultPacking;
11405                CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11406                                               n[4].i, n[5].e,
11407                                               n[6].i, n[7].e, n[8].e,
11408                                               get_pointer(&n[9])));
11409                ctx->Unpack = save;      /* restore */
11410             }
11411             break;
11412          case OPCODE_TEX_SUB_IMAGE3D:
11413             {
11414                const struct gl_pixelstore_attrib save = ctx->Unpack;
11415                ctx->Unpack = ctx->DefaultPacking;
11416                CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11417                                               n[4].i, n[5].i, n[6].i, n[7].i,
11418                                               n[8].i, n[9].e, n[10].e,
11419                                               get_pointer(&n[11])));
11420                ctx->Unpack = save;      /* restore */
11421             }
11422             break;
11423          case OPCODE_TRANSLATE:
11424             CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11425             break;
11426          case OPCODE_VIEWPORT:
11427             CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
11428                                       (GLsizei) n[3].i, (GLsizei) n[4].i));
11429             break;
11430          case OPCODE_WINDOW_POS:
11431             CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11432             break;
11433          case OPCODE_VIEWPORT_ARRAY_V:
11434             CALL_ViewportArrayv(ctx->Exec, (n[1].ui, n[2].si,
11435                                             get_pointer(&n[3])));
11436             break;
11437          case OPCODE_VIEWPORT_INDEXED_F:
11438             CALL_ViewportIndexedf(ctx->Exec, (n[1].ui, n[2].f, n[3].f, n[4].f,
11439                                               n[5].f));
11440             break;
11441          case OPCODE_VIEWPORT_INDEXED_FV: {
11442             GLfloat v[4];
11443             v[0] = n[2].f;
11444             v[1] = n[3].f;
11445             v[2] = n[4].f;
11446             v[3] = n[5].f;
11447             CALL_ViewportIndexedfv(ctx->Exec, (n[1].ui, v));
11448             break;
11449          }
11450          case OPCODE_SCISSOR_ARRAY_V:
11451             CALL_ScissorArrayv(ctx->Exec, (n[1].ui, n[2].si,
11452                                            get_pointer(&n[3])));
11453             break;
11454          case OPCODE_SCISSOR_INDEXED:
11455             CALL_ScissorIndexed(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].si,
11456                                             n[5].si));
11457             break;
11458          case OPCODE_SCISSOR_INDEXED_V: {
11459             GLint v[4];
11460             v[0] = n[2].i;
11461             v[1] = n[3].i;
11462             v[2] = n[4].si;
11463             v[3] = n[5].si;
11464             CALL_ScissorIndexedv(ctx->Exec, (n[1].ui, v));
11465             break;
11466          }
11467          case OPCODE_DEPTH_ARRAY_V:
11468             CALL_DepthRangeArrayv(ctx->Exec, (n[1].ui, n[2].si,
11469                                               get_pointer(&n[3])));
11470             break;
11471          case OPCODE_DEPTH_INDEXED:
11472             CALL_DepthRangeIndexed(ctx->Exec, (n[1].ui, n[2].f, n[3].f));
11473             break;
11474          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
11475             CALL_ActiveTexture(ctx->Exec, (n[1].e));
11476             break;
11477          case OPCODE_COMPRESSED_TEX_IMAGE_1D:  /* GL_ARB_texture_compression */
11478             CALL_CompressedTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11479                                                   n[4].i, n[5].i, n[6].i,
11480                                                   get_pointer(&n[7])));
11481             break;
11482          case OPCODE_COMPRESSED_TEX_IMAGE_2D:  /* GL_ARB_texture_compression */
11483             CALL_CompressedTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11484                                                   n[4].i, n[5].i, n[6].i,
11485                                                   n[7].i, get_pointer(&n[8])));
11486             break;
11487          case OPCODE_COMPRESSED_TEX_IMAGE_3D:  /* GL_ARB_texture_compression */
11488             CALL_CompressedTexImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11489                                                   n[4].i, n[5].i, n[6].i,
11490                                                   n[7].i, n[8].i,
11491                                                   get_pointer(&n[9])));
11492             break;
11493          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:      /* GL_ARB_texture_compress */
11494             CALL_CompressedTexSubImage1D(ctx->Exec,
11495                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11496                                              n[5].e, n[6].i,
11497                                              get_pointer(&n[7])));
11498             break;
11499          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:      /* GL_ARB_texture_compress */
11500             CALL_CompressedTexSubImage2D(ctx->Exec,
11501                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11502                                              n[5].i, n[6].i, n[7].e, n[8].i,
11503                                              get_pointer(&n[9])));
11504             break;
11505          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:      /* GL_ARB_texture_compress */
11506             CALL_CompressedTexSubImage3D(ctx->Exec,
11507                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11508                                              n[5].i, n[6].i, n[7].i, n[8].i,
11509                                              n[9].e, n[10].i,
11510                                              get_pointer(&n[11])));
11511             break;
11512          case OPCODE_SAMPLE_COVERAGE:  /* GL_ARB_multisample */
11513             CALL_SampleCoverage(ctx->Exec, (n[1].f, n[2].b));
11514             break;
11515          case OPCODE_WINDOW_POS_ARB:   /* GL_ARB_window_pos */
11516             CALL_WindowPos3f(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11517             break;
11518          case OPCODE_BIND_PROGRAM_ARB:  /* GL_ARB_vertex_program */
11519             CALL_BindProgramARB(ctx->Exec, (n[1].e, n[2].ui));
11520             break;
11521          case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
11522             CALL_ProgramLocalParameter4fARB(ctx->Exec,
11523                                             (n[1].e, n[2].ui, n[3].f, n[4].f,
11524                                              n[5].f, n[6].f));
11525             break;
11526          case OPCODE_ACTIVE_STENCIL_FACE_EXT:
11527             CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
11528             break;
11529          case OPCODE_DEPTH_BOUNDS_EXT:
11530             CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
11531             break;
11532          case OPCODE_PROGRAM_STRING_ARB:
11533             CALL_ProgramStringARB(ctx->Exec,
11534                                   (n[1].e, n[2].e, n[3].i,
11535                                    get_pointer(&n[4])));
11536             break;
11537          case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
11538             CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
11539                                                       n[4].f, n[5].f,
11540                                                       n[6].f));
11541             break;
11542          case OPCODE_BEGIN_QUERY_ARB:
11543             CALL_BeginQuery(ctx->Exec, (n[1].e, n[2].ui));
11544             break;
11545          case OPCODE_END_QUERY_ARB:
11546             CALL_EndQuery(ctx->Exec, (n[1].e));
11547             break;
11548          case OPCODE_QUERY_COUNTER:
11549             CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e));
11550             break;
11551          case OPCODE_BEGIN_QUERY_INDEXED:
11552             CALL_BeginQueryIndexed(ctx->Exec, (n[1].e, n[2].ui, n[3].ui));
11553             break;
11554          case OPCODE_END_QUERY_INDEXED:
11555             CALL_EndQueryIndexed(ctx->Exec, (n[1].e, n[2].ui));
11556             break;
11557          case OPCODE_DRAW_BUFFERS_ARB:
11558             {
11559                GLenum buffers[MAX_DRAW_BUFFERS];
11560                GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
11561                for (i = 0; i < count; i++)
11562                   buffers[i] = n[2 + i].e;
11563                CALL_DrawBuffers(ctx->Exec, (n[1].i, buffers));
11564             }
11565             break;
11566          case OPCODE_BLIT_FRAMEBUFFER:
11567             CALL_BlitFramebuffer(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
11568                                                 n[5].i, n[6].i, n[7].i, n[8].i,
11569                                                 n[9].i, n[10].e));
11570             break;
11571          case OPCODE_PRIMITIVE_RESTART_NV:
11572             CALL_PrimitiveRestartNV(ctx->Exec, ());
11573             break;
11574
11575          case OPCODE_USE_PROGRAM:
11576             CALL_UseProgram(ctx->Exec, (n[1].ui));
11577             break;
11578          case OPCODE_UNIFORM_1F:
11579             CALL_Uniform1f(ctx->Exec, (n[1].i, n[2].f));
11580             break;
11581          case OPCODE_UNIFORM_2F:
11582             CALL_Uniform2f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
11583             break;
11584          case OPCODE_UNIFORM_3F:
11585             CALL_Uniform3f(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f));
11586             break;
11587          case OPCODE_UNIFORM_4F:
11588             CALL_Uniform4f(ctx->Exec,
11589                               (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f));
11590             break;
11591          case OPCODE_UNIFORM_1FV:
11592             CALL_Uniform1fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11593             break;
11594          case OPCODE_UNIFORM_2FV:
11595             CALL_Uniform2fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11596             break;
11597          case OPCODE_UNIFORM_3FV:
11598             CALL_Uniform3fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11599             break;
11600          case OPCODE_UNIFORM_4FV:
11601             CALL_Uniform4fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11602             break;
11603          case OPCODE_UNIFORM_1D: {
11604             union float64_pair x;
11605
11606             x.uint32[0] = n[2].ui;
11607             x.uint32[1] = n[3].ui;
11608
11609             CALL_Uniform1d(ctx->Exec, (n[1].i, x.d));
11610             break;
11611          }
11612          case OPCODE_UNIFORM_2D: {
11613             union float64_pair x;
11614             union float64_pair y;
11615
11616             x.uint32[0] = n[2].ui;
11617             x.uint32[1] = n[3].ui;
11618             y.uint32[0] = n[4].ui;
11619             y.uint32[1] = n[5].ui;
11620
11621             CALL_Uniform2d(ctx->Exec, (n[1].i, x.d, y.d));
11622             break;
11623          }
11624          case OPCODE_UNIFORM_3D: {
11625             union float64_pair x;
11626             union float64_pair y;
11627             union float64_pair z;
11628
11629             x.uint32[0] = n[2].ui;
11630             x.uint32[1] = n[3].ui;
11631             y.uint32[0] = n[4].ui;
11632             y.uint32[1] = n[5].ui;
11633             z.uint32[0] = n[6].ui;
11634             z.uint32[1] = n[7].ui;
11635
11636             CALL_Uniform3d(ctx->Exec, (n[1].i, x.d, y.d, z.d));
11637             break;
11638          }
11639          case OPCODE_UNIFORM_4D: {
11640             union float64_pair x;
11641             union float64_pair y;
11642             union float64_pair z;
11643             union float64_pair w;
11644
11645             x.uint32[0] = n[2].ui;
11646             x.uint32[1] = n[3].ui;
11647             y.uint32[0] = n[4].ui;
11648             y.uint32[1] = n[5].ui;
11649             z.uint32[0] = n[6].ui;
11650             z.uint32[1] = n[7].ui;
11651             w.uint32[0] = n[8].ui;
11652             w.uint32[1] = n[9].ui;
11653
11654             CALL_Uniform4d(ctx->Exec, (n[1].i, x.d, y.d, z.d, w.d));
11655             break;
11656          }
11657          case OPCODE_UNIFORM_1DV:
11658             CALL_Uniform1dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11659             break;
11660          case OPCODE_UNIFORM_2DV:
11661             CALL_Uniform2dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11662             break;
11663          case OPCODE_UNIFORM_3DV:
11664             CALL_Uniform3dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11665             break;
11666          case OPCODE_UNIFORM_4DV:
11667             CALL_Uniform4dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11668             break;
11669          case OPCODE_UNIFORM_1I:
11670             CALL_Uniform1i(ctx->Exec, (n[1].i, n[2].i));
11671             break;
11672          case OPCODE_UNIFORM_2I:
11673             CALL_Uniform2i(ctx->Exec, (n[1].i, n[2].i, n[3].i));
11674             break;
11675          case OPCODE_UNIFORM_3I:
11676             CALL_Uniform3i(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
11677             break;
11678          case OPCODE_UNIFORM_4I:
11679             CALL_Uniform4i(ctx->Exec,
11680                               (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
11681             break;
11682          case OPCODE_UNIFORM_1IV:
11683             CALL_Uniform1iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11684             break;
11685          case OPCODE_UNIFORM_2IV:
11686             CALL_Uniform2iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11687             break;
11688          case OPCODE_UNIFORM_3IV:
11689             CALL_Uniform3iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11690             break;
11691          case OPCODE_UNIFORM_4IV:
11692             CALL_Uniform4iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11693             break;
11694          case OPCODE_UNIFORM_1UI:
11695             CALL_Uniform1ui(ctx->Exec, (n[1].i, n[2].i));
11696             break;
11697          case OPCODE_UNIFORM_2UI:
11698             CALL_Uniform2ui(ctx->Exec, (n[1].i, n[2].i, n[3].i));
11699             break;
11700          case OPCODE_UNIFORM_3UI:
11701             CALL_Uniform3ui(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
11702             break;
11703          case OPCODE_UNIFORM_4UI:
11704             CALL_Uniform4ui(ctx->Exec,
11705                             (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
11706             break;
11707          case OPCODE_UNIFORM_1UIV:
11708             CALL_Uniform1uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11709             break;
11710          case OPCODE_UNIFORM_2UIV:
11711             CALL_Uniform2uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11712             break;
11713          case OPCODE_UNIFORM_3UIV:
11714             CALL_Uniform3uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11715             break;
11716          case OPCODE_UNIFORM_4UIV:
11717             CALL_Uniform4uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11718             break;
11719          case OPCODE_UNIFORM_MATRIX22:
11720             CALL_UniformMatrix2fv(ctx->Exec,
11721                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11722             break;
11723          case OPCODE_UNIFORM_MATRIX33:
11724             CALL_UniformMatrix3fv(ctx->Exec,
11725                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11726             break;
11727          case OPCODE_UNIFORM_MATRIX44:
11728             CALL_UniformMatrix4fv(ctx->Exec,
11729                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11730             break;
11731          case OPCODE_UNIFORM_MATRIX23:
11732             CALL_UniformMatrix2x3fv(ctx->Exec,
11733                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11734             break;
11735          case OPCODE_UNIFORM_MATRIX32:
11736             CALL_UniformMatrix3x2fv(ctx->Exec,
11737                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11738             break;
11739          case OPCODE_UNIFORM_MATRIX24:
11740             CALL_UniformMatrix2x4fv(ctx->Exec,
11741                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11742             break;
11743          case OPCODE_UNIFORM_MATRIX42:
11744             CALL_UniformMatrix4x2fv(ctx->Exec,
11745                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11746             break;
11747          case OPCODE_UNIFORM_MATRIX34:
11748             CALL_UniformMatrix3x4fv(ctx->Exec,
11749                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11750             break;
11751          case OPCODE_UNIFORM_MATRIX43:
11752             CALL_UniformMatrix4x3fv(ctx->Exec,
11753                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11754             break;
11755          case OPCODE_UNIFORM_MATRIX22D:
11756             CALL_UniformMatrix2dv(ctx->Exec,
11757                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11758             break;
11759          case OPCODE_UNIFORM_MATRIX33D:
11760             CALL_UniformMatrix3dv(ctx->Exec,
11761                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11762             break;
11763          case OPCODE_UNIFORM_MATRIX44D:
11764             CALL_UniformMatrix4dv(ctx->Exec,
11765                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11766             break;
11767          case OPCODE_UNIFORM_MATRIX23D:
11768             CALL_UniformMatrix2x3dv(ctx->Exec,
11769                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11770             break;
11771          case OPCODE_UNIFORM_MATRIX32D:
11772             CALL_UniformMatrix3x2dv(ctx->Exec,
11773                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11774             break;
11775          case OPCODE_UNIFORM_MATRIX24D:
11776             CALL_UniformMatrix2x4dv(ctx->Exec,
11777                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11778             break;
11779          case OPCODE_UNIFORM_MATRIX42D:
11780             CALL_UniformMatrix4x2dv(ctx->Exec,
11781                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11782             break;
11783          case OPCODE_UNIFORM_MATRIX34D:
11784             CALL_UniformMatrix3x4dv(ctx->Exec,
11785                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11786             break;
11787          case OPCODE_UNIFORM_MATRIX43D:
11788             CALL_UniformMatrix4x3dv(ctx->Exec,
11789                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
11790             break;
11791
11792          case OPCODE_UNIFORM_1I64: {
11793             union int64_pair x;
11794
11795             x.int32[0] = n[2].i;
11796             x.int32[1] = n[3].i;
11797
11798             CALL_Uniform1i64ARB(ctx->Exec, (n[1].i, x.int64));
11799             break;
11800          }
11801          case OPCODE_UNIFORM_2I64: {
11802             union int64_pair x;
11803             union int64_pair y;
11804
11805             x.int32[0] = n[2].i;
11806             x.int32[1] = n[3].i;
11807             y.int32[0] = n[4].i;
11808             y.int32[1] = n[5].i;
11809
11810             CALL_Uniform2i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64));
11811             break;
11812          }
11813          case OPCODE_UNIFORM_3I64: {
11814             union int64_pair x;
11815             union int64_pair y;
11816             union int64_pair z;
11817
11818             x.int32[0] = n[2].i;
11819             x.int32[1] = n[3].i;
11820             y.int32[0] = n[4].i;
11821             y.int32[1] = n[5].i;
11822             z.int32[0] = n[6].i;
11823             z.int32[1] = n[7].i;
11824
11825
11826             CALL_Uniform3i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64));
11827             break;
11828          }
11829          case OPCODE_UNIFORM_4I64: {
11830             union int64_pair x;
11831             union int64_pair y;
11832             union int64_pair z;
11833             union int64_pair w;
11834
11835             x.int32[0] = n[2].i;
11836             x.int32[1] = n[3].i;
11837             y.int32[0] = n[4].i;
11838             y.int32[1] = n[5].i;
11839             z.int32[0] = n[6].i;
11840             z.int32[1] = n[7].i;
11841             w.int32[0] = n[8].i;
11842             w.int32[1] = n[9].i;
11843
11844             CALL_Uniform4i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64, w.int64));
11845             break;
11846          }
11847          case OPCODE_UNIFORM_1I64V:
11848             CALL_Uniform1i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11849             break;
11850          case OPCODE_UNIFORM_2I64V:
11851             CALL_Uniform2i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11852             break;
11853          case OPCODE_UNIFORM_3I64V:
11854             CALL_Uniform3i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11855             break;
11856          case OPCODE_UNIFORM_4I64V:
11857             CALL_Uniform4i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11858             break;
11859          case OPCODE_UNIFORM_1UI64: {
11860             union uint64_pair x;
11861
11862             x.uint32[0] = n[2].ui;
11863             x.uint32[1] = n[3].ui;
11864
11865             CALL_Uniform1ui64ARB(ctx->Exec, (n[1].i, x.uint64));
11866             break;
11867          }
11868          case OPCODE_UNIFORM_2UI64: {
11869             union uint64_pair x;
11870             union uint64_pair y;
11871
11872             x.uint32[0] = n[2].ui;
11873             x.uint32[1] = n[3].ui;
11874             y.uint32[0] = n[4].ui;
11875             y.uint32[1] = n[5].ui;
11876
11877             CALL_Uniform2ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64));
11878             break;
11879          }
11880          case OPCODE_UNIFORM_3UI64: {
11881             union uint64_pair x;
11882             union uint64_pair y;
11883             union uint64_pair z;
11884
11885             x.uint32[0] = n[2].ui;
11886             x.uint32[1] = n[3].ui;
11887             y.uint32[0] = n[4].ui;
11888             y.uint32[1] = n[5].ui;
11889             z.uint32[0] = n[6].ui;
11890             z.uint32[1] = n[7].ui;
11891
11892
11893             CALL_Uniform3ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
11894                                  z.uint64));
11895             break;
11896          }
11897          case OPCODE_UNIFORM_4UI64: {
11898             union uint64_pair x;
11899             union uint64_pair y;
11900             union uint64_pair z;
11901             union uint64_pair w;
11902
11903             x.uint32[0] = n[2].ui;
11904             x.uint32[1] = n[3].ui;
11905             y.uint32[0] = n[4].ui;
11906             y.uint32[1] = n[5].ui;
11907             z.uint32[0] = n[6].ui;
11908             z.uint32[1] = n[7].ui;
11909             w.uint32[0] = n[8].ui;
11910             w.uint32[1] = n[9].ui;
11911
11912             CALL_Uniform4ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
11913                                  z.uint64, w.uint64));
11914             break;
11915          }
11916          case OPCODE_UNIFORM_1UI64V:
11917             CALL_Uniform1ui64vARB(ctx->Exec, (n[1].i, n[2].i,
11918                                   get_pointer(&n[3])));
11919             break;
11920          case OPCODE_UNIFORM_2UI64V:
11921             CALL_Uniform2ui64vARB(ctx->Exec, (n[1].i, n[2].i,
11922                                   get_pointer(&n[3])));
11923             break;
11924          case OPCODE_UNIFORM_3UI64V:
11925             CALL_Uniform3ui64vARB(ctx->Exec, (n[1].i, n[2].i,
11926                                   get_pointer(&n[3])));
11927             break;
11928          case OPCODE_UNIFORM_4UI64V:
11929             CALL_Uniform4ui64vARB(ctx->Exec, (n[1].i, n[2].i,
11930                                   get_pointer(&n[3])));
11931             break;
11932
11933          case OPCODE_PROGRAM_UNIFORM_1I64: {
11934             union int64_pair x;
11935
11936             x.int32[0] = n[3].i;
11937             x.int32[1] = n[4].i;
11938
11939             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64));
11940             break;
11941          }
11942          case OPCODE_PROGRAM_UNIFORM_2I64: {
11943             union int64_pair x;
11944             union int64_pair y;
11945
11946             x.int32[0] = n[3].i;
11947             x.int32[1] = n[4].i;
11948             y.int32[0] = n[5].i;
11949             y.int32[1] = n[6].i;
11950
11951             CALL_ProgramUniform2i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
11952                                        y.int64));
11953             break;
11954          }
11955          case OPCODE_PROGRAM_UNIFORM_3I64: {
11956             union int64_pair x;
11957             union int64_pair y;
11958             union int64_pair z;
11959
11960             x.int32[0] = n[3].i;
11961             x.int32[1] = n[4].i;
11962             y.int32[0] = n[5].i;
11963             y.int32[1] = n[6].i;
11964             z.int32[0] = n[7].i;
11965             z.int32[1] = n[8].i;
11966
11967             CALL_ProgramUniform3i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
11968                                        y.int64, z.int64));
11969             break;
11970          }
11971          case OPCODE_PROGRAM_UNIFORM_4I64: {
11972             union int64_pair x;
11973             union int64_pair y;
11974             union int64_pair z;
11975             union int64_pair w;
11976
11977             x.int32[0] = n[3].i;
11978             x.int32[1] = n[4].i;
11979             y.int32[0] = n[5].i;
11980             y.int32[1] = n[6].i;
11981             z.int32[0] = n[7].i;
11982             z.int32[1] = n[8].i;
11983             w.int32[0] = n[9].i;
11984             w.int32[1] = n[10].i;
11985
11986             CALL_ProgramUniform4i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
11987                                        y.int64, z.int64, w.int64));
11988             break;
11989          }
11990          case OPCODE_PROGRAM_UNIFORM_1I64V:
11991             CALL_ProgramUniform1i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
11992                                         get_pointer(&n[4])));
11993             break;
11994          case OPCODE_PROGRAM_UNIFORM_2I64V:
11995             CALL_ProgramUniform2i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
11996                                         get_pointer(&n[4])));
11997             break;
11998          case OPCODE_PROGRAM_UNIFORM_3I64V:
11999             CALL_ProgramUniform3i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12000                                         get_pointer(&n[4])));
12001             break;
12002          case OPCODE_PROGRAM_UNIFORM_4I64V:
12003             CALL_ProgramUniform4i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12004                                         get_pointer(&n[4])));
12005             break;
12006          case OPCODE_PROGRAM_UNIFORM_1UI64: {
12007             union uint64_pair x;
12008
12009             x.uint32[0] = n[3].ui;
12010             x.uint32[1] = n[4].ui;
12011
12012             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64));
12013             break;
12014          }
12015          case OPCODE_PROGRAM_UNIFORM_2UI64: {
12016             union uint64_pair x;
12017             union uint64_pair y;
12018
12019             x.uint32[0] = n[3].ui;
12020             x.uint32[1] = n[4].ui;
12021             y.uint32[0] = n[5].ui;
12022             y.uint32[1] = n[6].ui;
12023
12024             CALL_ProgramUniform2ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12025                                         y.uint64));
12026             break;
12027          }
12028          case OPCODE_PROGRAM_UNIFORM_3UI64: {
12029             union uint64_pair x;
12030             union uint64_pair y;
12031             union uint64_pair z;
12032
12033             x.uint32[0] = n[3].ui;
12034             x.uint32[1] = n[4].ui;
12035             y.uint32[0] = n[5].ui;
12036             y.uint32[1] = n[6].ui;
12037             z.uint32[0] = n[7].ui;
12038             z.uint32[1] = n[8].ui;
12039
12040             CALL_ProgramUniform3ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12041                                         y.uint64, z.uint64));
12042             break;
12043          }
12044          case OPCODE_PROGRAM_UNIFORM_4UI64: {
12045             union uint64_pair x;
12046             union uint64_pair y;
12047             union uint64_pair z;
12048             union uint64_pair w;
12049
12050             x.uint32[0] = n[3].ui;
12051             x.uint32[1] = n[4].ui;
12052             y.uint32[0] = n[5].ui;
12053             y.uint32[1] = n[6].ui;
12054             z.uint32[0] = n[7].ui;
12055             z.uint32[1] = n[8].ui;
12056             w.uint32[0] = n[9].ui;
12057             w.uint32[1] = n[10].ui;
12058
12059             CALL_ProgramUniform4ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12060                                         y.uint64, z.uint64, w.uint64));
12061             break;
12062          }
12063          case OPCODE_PROGRAM_UNIFORM_1UI64V:
12064             CALL_ProgramUniform1ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12065                                          get_pointer(&n[4])));
12066             break;
12067          case OPCODE_PROGRAM_UNIFORM_2UI64V:
12068             CALL_ProgramUniform2ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12069                                          get_pointer(&n[4])));
12070             break;
12071          case OPCODE_PROGRAM_UNIFORM_3UI64V:
12072             CALL_ProgramUniform3ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12073                                          get_pointer(&n[4])));
12074             break;
12075          case OPCODE_PROGRAM_UNIFORM_4UI64V:
12076             CALL_ProgramUniform4ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12077                                          get_pointer(&n[4])));
12078             break;
12079
12080          case OPCODE_USE_PROGRAM_STAGES:
12081             CALL_UseProgramStages(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12082             break;
12083          case OPCODE_PROGRAM_UNIFORM_1F:
12084             CALL_ProgramUniform1f(ctx->Exec, (n[1].ui, n[2].i, n[3].f));
12085             break;
12086          case OPCODE_PROGRAM_UNIFORM_2F:
12087             CALL_ProgramUniform2f(ctx->Exec, (n[1].ui, n[2].i, n[3].f, n[4].f));
12088             break;
12089          case OPCODE_PROGRAM_UNIFORM_3F:
12090             CALL_ProgramUniform3f(ctx->Exec, (n[1].ui, n[2].i,
12091                                               n[3].f, n[4].f, n[5].f));
12092             break;
12093          case OPCODE_PROGRAM_UNIFORM_4F:
12094             CALL_ProgramUniform4f(ctx->Exec, (n[1].ui, n[2].i,
12095                                               n[3].f, n[4].f, n[5].f, n[6].f));
12096             break;
12097          case OPCODE_PROGRAM_UNIFORM_1FV:
12098             CALL_ProgramUniform1fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12099                                                get_pointer(&n[4])));
12100             break;
12101          case OPCODE_PROGRAM_UNIFORM_2FV:
12102             CALL_ProgramUniform2fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12103                                                get_pointer(&n[4])));
12104             break;
12105          case OPCODE_PROGRAM_UNIFORM_3FV:
12106             CALL_ProgramUniform3fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12107                                                get_pointer(&n[4])));
12108             break;
12109          case OPCODE_PROGRAM_UNIFORM_4FV:
12110             CALL_ProgramUniform4fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12111                                                get_pointer(&n[4])));
12112             break;
12113          case OPCODE_PROGRAM_UNIFORM_1D: {
12114             union float64_pair x;
12115
12116             x.uint32[0] = n[3].ui;
12117             x.uint32[1] = n[4].ui;
12118
12119             CALL_ProgramUniform1d(ctx->Exec, (n[1].ui, n[2].i, x.d));
12120             break;
12121          }
12122          case OPCODE_PROGRAM_UNIFORM_2D: {
12123             union float64_pair x;
12124             union float64_pair y;
12125
12126             x.uint32[0] = n[3].ui;
12127             x.uint32[1] = n[4].ui;
12128             y.uint32[0] = n[5].ui;
12129             y.uint32[1] = n[6].ui;
12130
12131             CALL_ProgramUniform2d(ctx->Exec, (n[1].ui, n[2].i, x.d, y.d));
12132             break;
12133          }
12134          case OPCODE_PROGRAM_UNIFORM_3D: {
12135             union float64_pair x;
12136             union float64_pair y;
12137             union float64_pair z;
12138
12139             x.uint32[0] = n[3].ui;
12140             x.uint32[1] = n[4].ui;
12141             y.uint32[0] = n[5].ui;
12142             y.uint32[1] = n[6].ui;
12143             z.uint32[0] = n[7].ui;
12144             z.uint32[1] = n[8].ui;
12145
12146             CALL_ProgramUniform3d(ctx->Exec, (n[1].ui, n[2].i,
12147                                               x.d, y.d, z.d));
12148             break;
12149          }
12150          case OPCODE_PROGRAM_UNIFORM_4D: {
12151             union float64_pair x;
12152             union float64_pair y;
12153             union float64_pair z;
12154             union float64_pair w;
12155
12156             x.uint32[0] = n[3].ui;
12157             x.uint32[1] = n[4].ui;
12158             y.uint32[0] = n[5].ui;
12159             y.uint32[1] = n[6].ui;
12160             z.uint32[0] = n[7].ui;
12161             z.uint32[1] = n[8].ui;
12162             w.uint32[0] = n[9].ui;
12163             w.uint32[1] = n[10].ui;
12164
12165             CALL_ProgramUniform4d(ctx->Exec, (n[1].ui, n[2].i,
12166                                               x.d, y.d, z.d, w.d));
12167             break;
12168          }
12169          case OPCODE_PROGRAM_UNIFORM_1DV:
12170             CALL_ProgramUniform1dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12171                                                get_pointer(&n[4])));
12172             break;
12173          case OPCODE_PROGRAM_UNIFORM_2DV:
12174             CALL_ProgramUniform2dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12175                                                get_pointer(&n[4])));
12176             break;
12177          case OPCODE_PROGRAM_UNIFORM_3DV:
12178             CALL_ProgramUniform3dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12179                                                get_pointer(&n[4])));
12180             break;
12181          case OPCODE_PROGRAM_UNIFORM_4DV:
12182             CALL_ProgramUniform4dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12183                                                get_pointer(&n[4])));
12184             break;
12185          case OPCODE_PROGRAM_UNIFORM_1I:
12186             CALL_ProgramUniform1i(ctx->Exec, (n[1].ui, n[2].i, n[3].i));
12187             break;
12188          case OPCODE_PROGRAM_UNIFORM_2I:
12189             CALL_ProgramUniform2i(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].i));
12190             break;
12191          case OPCODE_PROGRAM_UNIFORM_3I:
12192             CALL_ProgramUniform3i(ctx->Exec, (n[1].ui, n[2].i,
12193                                               n[3].i, n[4].i, n[5].i));
12194             break;
12195          case OPCODE_PROGRAM_UNIFORM_4I:
12196             CALL_ProgramUniform4i(ctx->Exec, (n[1].ui, n[2].i,
12197                                               n[3].i, n[4].i, n[5].i, n[6].i));
12198             break;
12199          case OPCODE_PROGRAM_UNIFORM_1IV:
12200             CALL_ProgramUniform1iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12201                                                get_pointer(&n[4])));
12202             break;
12203          case OPCODE_PROGRAM_UNIFORM_2IV:
12204             CALL_ProgramUniform2iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12205                                                get_pointer(&n[4])));
12206             break;
12207          case OPCODE_PROGRAM_UNIFORM_3IV:
12208             CALL_ProgramUniform3iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12209                                                get_pointer(&n[4])));
12210             break;
12211          case OPCODE_PROGRAM_UNIFORM_4IV:
12212             CALL_ProgramUniform4iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12213                                                get_pointer(&n[4])));
12214             break;
12215          case OPCODE_PROGRAM_UNIFORM_1UI:
12216             CALL_ProgramUniform1ui(ctx->Exec, (n[1].ui, n[2].i, n[3].ui));
12217             break;
12218          case OPCODE_PROGRAM_UNIFORM_2UI:
12219             CALL_ProgramUniform2ui(ctx->Exec, (n[1].ui, n[2].i,
12220                                                n[3].ui, n[4].ui));
12221             break;
12222          case OPCODE_PROGRAM_UNIFORM_3UI:
12223             CALL_ProgramUniform3ui(ctx->Exec, (n[1].ui, n[2].i,
12224                                                n[3].ui, n[4].ui, n[5].ui));
12225             break;
12226          case OPCODE_PROGRAM_UNIFORM_4UI:
12227             CALL_ProgramUniform4ui(ctx->Exec, (n[1].ui, n[2].i,
12228                                                n[3].ui,
12229                                                n[4].ui, n[5].ui, n[6].ui));
12230             break;
12231          case OPCODE_PROGRAM_UNIFORM_1UIV:
12232             CALL_ProgramUniform1uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12233                                                 get_pointer(&n[4])));
12234             break;
12235          case OPCODE_PROGRAM_UNIFORM_2UIV:
12236             CALL_ProgramUniform2uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12237                                                 get_pointer(&n[4])));
12238             break;
12239          case OPCODE_PROGRAM_UNIFORM_3UIV:
12240             CALL_ProgramUniform3uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12241                                                 get_pointer(&n[4])));
12242             break;
12243          case OPCODE_PROGRAM_UNIFORM_4UIV:
12244             CALL_ProgramUniform4uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12245                                                 get_pointer(&n[4])));
12246             break;
12247          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
12248             CALL_ProgramUniformMatrix2fv(ctx->Exec,
12249                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12250                                           get_pointer(&n[5])));
12251             break;
12252          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
12253             CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
12254                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12255                                             get_pointer(&n[5])));
12256             break;
12257          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
12258             CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
12259                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12260                                             get_pointer(&n[5])));
12261             break;
12262          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
12263             CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
12264                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12265                                             get_pointer(&n[5])));
12266             break;
12267          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
12268             CALL_ProgramUniformMatrix3fv(ctx->Exec,
12269                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12270                                           get_pointer(&n[5])));
12271             break;
12272          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
12273             CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
12274                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12275                                             get_pointer(&n[5])));
12276             break;
12277          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
12278             CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
12279                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12280                                             get_pointer(&n[5])));
12281             break;
12282          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
12283             CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
12284                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12285                                             get_pointer(&n[5])));
12286             break;
12287          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
12288             CALL_ProgramUniformMatrix4fv(ctx->Exec,
12289                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12290                                           get_pointer(&n[5])));
12291             break;
12292          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
12293             CALL_ProgramUniformMatrix2dv(ctx->Exec,
12294                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12295                                           get_pointer(&n[5])));
12296             break;
12297          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
12298             CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
12299                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12300                                             get_pointer(&n[5])));
12301             break;
12302          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
12303             CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
12304                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12305                                             get_pointer(&n[5])));
12306             break;
12307          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
12308             CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
12309                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12310                                             get_pointer(&n[5])));
12311             break;
12312          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
12313             CALL_ProgramUniformMatrix3dv(ctx->Exec,
12314                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12315                                           get_pointer(&n[5])));
12316             break;
12317          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
12318             CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
12319                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12320                                             get_pointer(&n[5])));
12321             break;
12322          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
12323             CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
12324                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12325                                             get_pointer(&n[5])));
12326             break;
12327          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
12328             CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
12329                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12330                                             get_pointer(&n[5])));
12331             break;
12332          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
12333             CALL_ProgramUniformMatrix4dv(ctx->Exec,
12334                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12335                                           get_pointer(&n[5])));
12336             break;
12337
12338          case OPCODE_CLIP_CONTROL:
12339             CALL_ClipControl(ctx->Exec, (n[1].e, n[2].e));
12340             break;
12341
12342          case OPCODE_CLAMP_COLOR:
12343             CALL_ClampColor(ctx->Exec, (n[1].e, n[2].e));
12344             break;
12345
12346          case OPCODE_BIND_FRAGMENT_SHADER_ATI:
12347             CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
12348             break;
12349          case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
12350             CALL_SetFragmentShaderConstantATI(ctx->Exec, (n[1].ui, &n[2].f));
12351             break;
12352          case OPCODE_ATTR_1F_NV:
12353             CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
12354             break;
12355          case OPCODE_ATTR_2F_NV:
12356             CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
12357             break;
12358          case OPCODE_ATTR_3F_NV:
12359             CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
12360             break;
12361          case OPCODE_ATTR_4F_NV:
12362             CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
12363             break;
12364          case OPCODE_ATTR_1F_ARB:
12365             CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
12366             break;
12367          case OPCODE_ATTR_2F_ARB:
12368             CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
12369             break;
12370          case OPCODE_ATTR_3F_ARB:
12371             CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
12372             break;
12373          case OPCODE_ATTR_4F_ARB:
12374             CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
12375             break;
12376          case OPCODE_ATTR_1I:
12377             CALL_VertexAttribI1iEXT(ctx->Exec, (n[1].e, n[2].i));
12378             break;
12379          case OPCODE_ATTR_2I:
12380             CALL_VertexAttribI2ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12381             break;
12382          case OPCODE_ATTR_3I:
12383             CALL_VertexAttribI3ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12384             break;
12385          case OPCODE_ATTR_4I:
12386             CALL_VertexAttribI4ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12387             break;
12388          case OPCODE_ATTR_1D: {
12389             GLdouble *d = (GLdouble *) &n[2];
12390             CALL_VertexAttribL1d(ctx->Exec, (n[1].ui, *d));
12391             break;
12392          }
12393          case OPCODE_ATTR_2D: {
12394             GLdouble *d = (GLdouble *) &n[2];
12395             CALL_VertexAttribL2dv(ctx->Exec, (n[1].ui, d));
12396             break;
12397          }
12398          case OPCODE_ATTR_3D: {
12399             GLdouble *d = (GLdouble *) &n[2];
12400             CALL_VertexAttribL3dv(ctx->Exec, (n[1].ui, d));
12401             break;
12402          }
12403          case OPCODE_ATTR_4D: {
12404             GLdouble *d = (GLdouble *) &n[2];
12405             CALL_VertexAttribL4dv(ctx->Exec, (n[1].ui, d));
12406             break;
12407          }
12408          case OPCODE_ATTR_1UI64: {
12409             uint64_t *ui64 = (uint64_t *) &n[2];
12410             CALL_VertexAttribL1ui64ARB(ctx->Exec, (n[1].ui, *ui64));
12411             break;
12412          }
12413          case OPCODE_MATERIAL:
12414             CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
12415             break;
12416          case OPCODE_BEGIN:
12417             CALL_Begin(ctx->Exec, (n[1].e));
12418             break;
12419          case OPCODE_END:
12420             CALL_End(ctx->Exec, ());
12421             break;
12422          case OPCODE_EVAL_C1:
12423             CALL_EvalCoord1f(ctx->Exec, (n[1].f));
12424             break;
12425          case OPCODE_EVAL_C2:
12426             CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
12427             break;
12428          case OPCODE_EVAL_P1:
12429             CALL_EvalPoint1(ctx->Exec, (n[1].i));
12430             break;
12431          case OPCODE_EVAL_P2:
12432             CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
12433             break;
12434
12435          /* GL_EXT_texture_integer */
12436          case OPCODE_CLEARCOLOR_I:
12437             CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12438             break;
12439          case OPCODE_CLEARCOLOR_UI:
12440             CALL_ClearColorIuiEXT(ctx->Exec,
12441                                   (n[1].ui, n[2].ui, n[3].ui, n[4].ui));
12442             break;
12443          case OPCODE_TEXPARAMETER_I:
12444             {
12445                GLint params[4];
12446                params[0] = n[3].i;
12447                params[1] = n[4].i;
12448                params[2] = n[5].i;
12449                params[3] = n[6].i;
12450                CALL_TexParameterIiv(ctx->Exec, (n[1].e, n[2].e, params));
12451             }
12452             break;
12453          case OPCODE_TEXPARAMETER_UI:
12454             {
12455                GLuint params[4];
12456                params[0] = n[3].ui;
12457                params[1] = n[4].ui;
12458                params[2] = n[5].ui;
12459                params[3] = n[6].ui;
12460                CALL_TexParameterIuiv(ctx->Exec, (n[1].e, n[2].e, params));
12461             }
12462             break;
12463
12464          case OPCODE_VERTEX_ATTRIB_DIVISOR:
12465             /* GL_ARB_instanced_arrays */
12466             CALL_VertexAttribDivisor(ctx->Exec, (n[1].ui, n[2].ui));
12467             break;
12468
12469          case OPCODE_TEXTURE_BARRIER_NV:
12470             CALL_TextureBarrierNV(ctx->Exec, ());
12471             break;
12472
12473          /* GL_EXT/ARB_transform_feedback */
12474          case OPCODE_BEGIN_TRANSFORM_FEEDBACK:
12475             CALL_BeginTransformFeedback(ctx->Exec, (n[1].e));
12476             break;
12477          case OPCODE_END_TRANSFORM_FEEDBACK:
12478             CALL_EndTransformFeedback(ctx->Exec, ());
12479             break;
12480          case OPCODE_BIND_TRANSFORM_FEEDBACK:
12481             CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
12482             break;
12483          case OPCODE_PAUSE_TRANSFORM_FEEDBACK:
12484             CALL_PauseTransformFeedback(ctx->Exec, ());
12485             break;
12486          case OPCODE_RESUME_TRANSFORM_FEEDBACK:
12487             CALL_ResumeTransformFeedback(ctx->Exec, ());
12488             break;
12489          case OPCODE_DRAW_TRANSFORM_FEEDBACK:
12490             CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
12491             break;
12492          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM:
12493             CALL_DrawTransformFeedbackStream(ctx->Exec,
12494                                              (n[1].e, n[2].ui, n[3].ui));
12495             break;
12496          case OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED:
12497             CALL_DrawTransformFeedbackInstanced(ctx->Exec,
12498                                                 (n[1].e, n[2].ui, n[3].si));
12499             break;
12500          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED:
12501             CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec,
12502                                        (n[1].e, n[2].ui, n[3].ui, n[4].si));
12503             break;
12504
12505
12506          case OPCODE_BIND_SAMPLER:
12507             CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui));
12508             break;
12509          case OPCODE_SAMPLER_PARAMETERIV:
12510             {
12511                GLint params[4];
12512                params[0] = n[3].i;
12513                params[1] = n[4].i;
12514                params[2] = n[5].i;
12515                params[3] = n[6].i;
12516                CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params));
12517             }
12518             break;
12519          case OPCODE_SAMPLER_PARAMETERFV:
12520             {
12521                GLfloat params[4];
12522                params[0] = n[3].f;
12523                params[1] = n[4].f;
12524                params[2] = n[5].f;
12525                params[3] = n[6].f;
12526                CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params));
12527             }
12528             break;
12529          case OPCODE_SAMPLER_PARAMETERIIV:
12530             {
12531                GLint params[4];
12532                params[0] = n[3].i;
12533                params[1] = n[4].i;
12534                params[2] = n[5].i;
12535                params[3] = n[6].i;
12536                CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params));
12537             }
12538             break;
12539          case OPCODE_SAMPLER_PARAMETERUIV:
12540             {
12541                GLuint params[4];
12542                params[0] = n[3].ui;
12543                params[1] = n[4].ui;
12544                params[2] = n[5].ui;
12545                params[3] = n[6].ui;
12546                CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params));
12547             }
12548             break;
12549
12550          /* ARB_compute_shader */
12551          case OPCODE_DISPATCH_COMPUTE:
12552             CALL_DispatchCompute(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12553             break;
12554
12555          /* GL_ARB_sync */
12556          case OPCODE_WAIT_SYNC:
12557             {
12558                union uint64_pair p;
12559                p.uint32[0] = n[2].ui;
12560                p.uint32[1] = n[3].ui;
12561                CALL_WaitSync(ctx->Exec,
12562                              (get_pointer(&n[4]), n[1].bf, p.uint64));
12563             }
12564             break;
12565
12566          /* GL_NV_conditional_render */
12567          case OPCODE_BEGIN_CONDITIONAL_RENDER:
12568             CALL_BeginConditionalRender(ctx->Exec, (n[1].i, n[2].e));
12569             break;
12570          case OPCODE_END_CONDITIONAL_RENDER:
12571             CALL_EndConditionalRender(ctx->Exec, ());
12572             break;
12573
12574          case OPCODE_UNIFORM_BLOCK_BINDING:
12575             CALL_UniformBlockBinding(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12576             break;
12577
12578          case OPCODE_UNIFORM_SUBROUTINES:
12579             CALL_UniformSubroutinesuiv(ctx->Exec, (n[1].e, n[2].si,
12580                                                    get_pointer(&n[3])));
12581             break;
12582
12583          /* GL_EXT_window_rectangles */
12584          case OPCODE_WINDOW_RECTANGLES:
12585             CALL_WindowRectanglesEXT(
12586                   ctx->Exec, (n[1].e, n[2].si, get_pointer(&n[3])));
12587             break;
12588
12589          /* GL_NV_conservative_raster */
12590          case OPCODE_SUBPIXEL_PRECISION_BIAS:
12591             CALL_SubpixelPrecisionBiasNV(ctx->Exec, (n[1].ui, n[2].ui));
12592             break;
12593
12594          /* GL_NV_conservative_raster_dilate */
12595          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_F:
12596             CALL_ConservativeRasterParameterfNV(ctx->Exec, (n[1].e, n[2].f));
12597             break;
12598
12599          /* GL_NV_conservative_raster_pre_snap_triangles */
12600          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_I:
12601             CALL_ConservativeRasterParameteriNV(ctx->Exec, (n[1].e, n[2].i));
12602             break;
12603
12604          /* GL_EXT_direct_state_access */
12605          case OPCODE_MATRIX_LOAD:
12606             CALL_MatrixLoadfEXT(ctx->Exec, (n[1].e, &n[2].f));
12607             break;
12608          case OPCODE_MATRIX_MULT:
12609             CALL_MatrixMultfEXT(ctx->Exec, (n[1].e, &n[2].f));
12610             break;
12611          case OPCODE_MATRIX_ROTATE:
12612             CALL_MatrixRotatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f, n[5].f));
12613             break;
12614          case OPCODE_MATRIX_SCALE:
12615             CALL_MatrixScalefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
12616             break;
12617          case OPCODE_MATRIX_TRANSLATE:
12618             CALL_MatrixTranslatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
12619             break;
12620          case OPCODE_MATRIX_LOAD_IDENTITY:
12621             CALL_MatrixLoadIdentityEXT(ctx->Exec, (n[1].e));
12622             break;
12623          case OPCODE_MATRIX_ORTHO:
12624             CALL_MatrixOrthoEXT(ctx->Exec, (n[1].e,
12625                                             n[2].f, n[3].f, n[4].f,
12626                                             n[5].f, n[6].f, n[7].f));
12627             break;
12628          case OPCODE_MATRIX_FRUSTUM:
12629             CALL_MatrixFrustumEXT(ctx->Exec, (n[1].e,
12630                                               n[2].f, n[3].f, n[4].f,
12631                                               n[5].f, n[6].f, n[7].f));
12632             break;
12633          case OPCODE_MATRIX_PUSH:
12634             CALL_MatrixPushEXT(ctx->Exec, (n[1].e));
12635             break;
12636          case OPCODE_MATRIX_POP:
12637             CALL_MatrixPopEXT(ctx->Exec, (n[1].e));
12638             break;
12639          case OPCODE_TEXTUREPARAMETER_F:
12640             {
12641                GLfloat params[4];
12642                params[0] = n[4].f;
12643                params[1] = n[5].f;
12644                params[2] = n[6].f;
12645                params[3] = n[7].f;
12646                CALL_TextureParameterfvEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
12647             }
12648             break;
12649          case OPCODE_TEXTUREPARAMETER_I:
12650             {
12651                GLint params[4];
12652                params[0] = n[4].i;
12653                params[1] = n[5].i;
12654                params[2] = n[6].i;
12655                params[3] = n[7].i;
12656                CALL_TextureParameterivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
12657             }
12658             break;
12659          case OPCODE_TEXTUREPARAMETER_II:
12660             {
12661                GLint params[4];
12662                params[0] = n[4].i;
12663                params[1] = n[5].i;
12664                params[2] = n[6].i;
12665                params[3] = n[7].i;
12666                CALL_TextureParameterIivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
12667             }
12668             break;
12669          case OPCODE_TEXTUREPARAMETER_IUI:
12670             {
12671                GLuint params[4];
12672                params[0] = n[4].ui;
12673                params[1] = n[5].ui;
12674                params[2] = n[6].ui;
12675                params[3] = n[7].ui;
12676                CALL_TextureParameterIuivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
12677             }
12678             break;
12679          case OPCODE_TEXTURE_IMAGE1D:
12680             {
12681                const struct gl_pixelstore_attrib save = ctx->Unpack;
12682                ctx->Unpack = ctx->DefaultPacking;
12683                CALL_TextureImage1DEXT(ctx->Exec, (n[1].ui, /* texture */
12684                                                   n[2].e,  /* target */
12685                                                   n[3].i,  /* level */
12686                                                   n[4].i,  /* components */
12687                                                   n[5].i,  /* width */
12688                                                   n[6].e,  /* border */
12689                                                   n[7].e,  /* format */
12690                                                   n[8].e,  /* type */
12691                                                   get_pointer(&n[9])));
12692                ctx->Unpack = save;      /* restore */
12693             }
12694             break;
12695          case OPCODE_TEXTURE_IMAGE2D:
12696             {
12697                const struct gl_pixelstore_attrib save = ctx->Unpack;
12698                ctx->Unpack = ctx->DefaultPacking;
12699                CALL_TextureImage2DEXT(ctx->Exec, (n[1].ui, /* texture */
12700                                                   n[2].e,  /* target */
12701                                                   n[3].i,  /* level */
12702                                                   n[4].i,  /* components */
12703                                                   n[5].i,  /* width */
12704                                                   n[6].i,  /* height */
12705                                                   n[7].e,  /* border */
12706                                                   n[8].e,  /* format */
12707                                                   n[9].e,  /* type */
12708                                                   get_pointer(&n[10])));
12709                ctx->Unpack = save;      /* restore */
12710             }
12711             break;
12712          case OPCODE_TEXTURE_IMAGE3D:
12713             {
12714                const struct gl_pixelstore_attrib save = ctx->Unpack;
12715                ctx->Unpack = ctx->DefaultPacking;
12716                CALL_TextureImage3DEXT(ctx->Exec, (n[1].ui, /* texture */
12717                                                   n[2].e,  /* target */
12718                                                   n[3].i,  /* level */
12719                                                   n[4].i,  /* components */
12720                                                   n[5].i,  /* width */
12721                                                   n[6].i,  /* height */
12722                                                   n[7].i,  /* depth  */
12723                                                   n[8].e,  /* border */
12724                                                   n[9].e,  /* format */
12725                                                   n[10].e, /* type */
12726                                                   get_pointer(&n[11])));
12727                ctx->Unpack = save;      /* restore */
12728             }
12729             break;
12730          case OPCODE_TEXTURE_SUB_IMAGE1D:
12731             {
12732                const struct gl_pixelstore_attrib save = ctx->Unpack;
12733                ctx->Unpack = ctx->DefaultPacking;
12734                CALL_TextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12735                                                      n[4].i, n[5].i, n[6].e,
12736                                                      n[7].e, get_pointer(&n[8])));
12737                ctx->Unpack = save;      /* restore */
12738             }
12739             break;
12740          case OPCODE_TEXTURE_SUB_IMAGE2D:
12741             {
12742                const struct gl_pixelstore_attrib save = ctx->Unpack;
12743                ctx->Unpack = ctx->DefaultPacking;
12744                CALL_TextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12745                                                      n[4].i, n[5].i, n[6].e,
12746                                                      n[7].i, n[8].e, n[9].e,
12747                                                      get_pointer(&n[10])));
12748                ctx->Unpack = save;
12749             }
12750             break;
12751          case OPCODE_TEXTURE_SUB_IMAGE3D:
12752             {
12753                const struct gl_pixelstore_attrib save = ctx->Unpack;
12754                ctx->Unpack = ctx->DefaultPacking;
12755                CALL_TextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12756                                                      n[4].i, n[5].i, n[6].i,
12757                                                      n[7].i, n[8].i, n[9].i,
12758                                                      n[10].e, n[11].e,
12759                                                      get_pointer(&n[12])));
12760                ctx->Unpack = save;      /* restore */
12761             }
12762             break;
12763          case OPCODE_COPY_TEXTURE_IMAGE1D:
12764             CALL_CopyTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12765                                                    n[4].e, n[5].i, n[6].i,
12766                                                    n[7].i, n[8].i));
12767             break;
12768          case OPCODE_COPY_TEXTURE_IMAGE2D:
12769             CALL_CopyTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12770                                                    n[4].e, n[5].i, n[6].i,
12771                                                    n[7].i, n[8].i, n[9].i));
12772             break;
12773          case OPCODE_COPY_TEXTURE_SUB_IMAGE1D:
12774             CALL_CopyTextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12775                                                       n[4].i, n[5].i, n[6].i,
12776                                                       n[7].i));
12777             break;
12778          case OPCODE_COPY_TEXTURE_SUB_IMAGE2D:
12779             CALL_CopyTextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12780                                                       n[4].i, n[5].i, n[6].i,
12781                                                       n[7].i, n[8].i, n[9].i));
12782             break;
12783          case OPCODE_COPY_TEXTURE_SUB_IMAGE3D:
12784             CALL_CopyTextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12785                                                       n[4].i, n[5].i, n[6].i,
12786                                                       n[7].i, n[8].i, n[9].i,
12787                                                       n[10].i));
12788             break;
12789          case OPCODE_BIND_MULTITEXTURE:
12790             CALL_BindMultiTextureEXT(ctx->Exec, (n[1].e, n[2].e, n[3].ui));
12791             break;
12792          case OPCODE_MULTITEXPARAMETER_F:
12793             {
12794                GLfloat params[4];
12795                params[0] = n[4].f;
12796                params[1] = n[5].f;
12797                params[2] = n[6].f;
12798                params[3] = n[7].f;
12799                CALL_MultiTexParameterfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
12800             }
12801             break;
12802          case OPCODE_MULTITEXPARAMETER_I:
12803             {
12804                GLint params[4];
12805                params[0] = n[4].i;
12806                params[1] = n[5].i;
12807                params[2] = n[6].i;
12808                params[3] = n[7].i;
12809                CALL_MultiTexParameterivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
12810             }
12811             break;
12812          case OPCODE_MULTITEXPARAMETER_II:
12813             {
12814                GLint params[4];
12815                params[0] = n[4].i;
12816                params[1] = n[5].i;
12817                params[2] = n[6].i;
12818                params[3] = n[7].i;
12819                CALL_MultiTexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
12820             }
12821             break;
12822          case OPCODE_MULTITEXPARAMETER_IUI:
12823             {
12824                GLuint params[4];
12825                params[0] = n[4].ui;
12826                params[1] = n[5].ui;
12827                params[2] = n[6].ui;
12828                params[3] = n[7].ui;
12829                CALL_MultiTexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
12830             }
12831             break;
12832          case OPCODE_MULTITEX_IMAGE1D:
12833             {
12834                const struct gl_pixelstore_attrib save = ctx->Unpack;
12835                ctx->Unpack = ctx->DefaultPacking;
12836                CALL_MultiTexImage1DEXT(ctx->Exec, (n[1].e, /* texture */
12837                                                   n[2].e,  /* target */
12838                                                   n[3].i,  /* level */
12839                                                   n[4].i,  /* components */
12840                                                   n[5].i,  /* width */
12841                                                   n[6].e,  /* border */
12842                                                   n[7].e,  /* format */
12843                                                   n[8].e,  /* type */
12844                                                   get_pointer(&n[9])));
12845                ctx->Unpack = save;      /* restore */
12846             }
12847             break;
12848          case OPCODE_MULTITEX_IMAGE2D:
12849             {
12850                const struct gl_pixelstore_attrib save = ctx->Unpack;
12851                ctx->Unpack = ctx->DefaultPacking;
12852                CALL_MultiTexImage2DEXT(ctx->Exec, (n[1].e, /* texture */
12853                                                   n[2].e,  /* target */
12854                                                   n[3].i,  /* level */
12855                                                   n[4].i,  /* components */
12856                                                   n[5].i,  /* width */
12857                                                   n[6].i,  /* height */
12858                                                   n[7].e,  /* border */
12859                                                   n[8].e,  /* format */
12860                                                   n[9].e,  /* type */
12861                                                   get_pointer(&n[10])));
12862                ctx->Unpack = save;      /* restore */
12863             }
12864             break;
12865          case OPCODE_MULTITEX_IMAGE3D:
12866             {
12867                const struct gl_pixelstore_attrib save = ctx->Unpack;
12868                ctx->Unpack = ctx->DefaultPacking;
12869                CALL_MultiTexImage3DEXT(ctx->Exec, (n[1].e, /* texture */
12870                                                   n[2].e,  /* target */
12871                                                   n[3].i,  /* level */
12872                                                   n[4].i,  /* components */
12873                                                   n[5].i,  /* width */
12874                                                   n[6].i,  /* height */
12875                                                   n[7].i,  /* depth  */
12876                                                   n[8].e,  /* border */
12877                                                   n[9].e,  /* format */
12878                                                   n[10].e, /* type */
12879                                                   get_pointer(&n[11])));
12880                ctx->Unpack = save;      /* restore */
12881             }
12882             break;
12883          case OPCODE_MULTITEX_SUB_IMAGE1D:
12884             {
12885                const struct gl_pixelstore_attrib save = ctx->Unpack;
12886                ctx->Unpack = ctx->DefaultPacking;
12887                CALL_MultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12888                                                      n[4].i, n[5].i, n[6].e,
12889                                                      n[7].e, get_pointer(&n[8])));
12890                ctx->Unpack = save;      /* restore */
12891             }
12892             break;
12893          case OPCODE_MULTITEX_SUB_IMAGE2D:
12894             {
12895                const struct gl_pixelstore_attrib save = ctx->Unpack;
12896                ctx->Unpack = ctx->DefaultPacking;
12897                CALL_MultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12898                                                      n[4].i, n[5].i, n[6].e,
12899                                                      n[7].i, n[8].e, n[9].e,
12900                                                      get_pointer(&n[10])));
12901                ctx->Unpack = save;      /* restore */
12902             }
12903             break;
12904          case OPCODE_MULTITEX_SUB_IMAGE3D:
12905             {
12906                const struct gl_pixelstore_attrib save = ctx->Unpack;
12907                ctx->Unpack = ctx->DefaultPacking;
12908                CALL_MultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12909                                                      n[4].i, n[5].i, n[6].i,
12910                                                      n[7].i, n[8].i, n[9].i,
12911                                                      n[10].e, n[11].e,
12912                                                      get_pointer(&n[12])));
12913                ctx->Unpack = save;      /* restore */
12914             }
12915             break;
12916          case OPCODE_COPY_MULTITEX_IMAGE1D:
12917             CALL_CopyMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12918                                                    n[4].e, n[5].i, n[6].i,
12919                                                    n[7].i, n[8].i));
12920             break;
12921          case OPCODE_COPY_MULTITEX_IMAGE2D:
12922             CALL_CopyMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12923                                                    n[4].e, n[5].i, n[6].i,
12924                                                    n[7].i, n[8].i, n[9].i));
12925             break;
12926          case OPCODE_COPY_MULTITEX_SUB_IMAGE1D:
12927             CALL_CopyMultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12928                                                       n[4].i, n[5].i, n[6].i,
12929                                                       n[7].i));
12930             break;
12931          case OPCODE_COPY_MULTITEX_SUB_IMAGE2D:
12932             CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12933                                                       n[4].i, n[5].i, n[6].i,
12934                                                       n[7].i, n[8].i, n[9].i));
12935             break;
12936          case OPCODE_COPY_MULTITEX_SUB_IMAGE3D:
12937             CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12938                                                       n[4].i, n[5].i, n[6].i,
12939                                                       n[7].i, n[8].i, n[9].i,
12940                                                       n[10].i));
12941             break;
12942          case OPCODE_MULTITEXENV:
12943             {
12944                GLfloat params[4];
12945                params[0] = n[4].f;
12946                params[1] = n[5].f;
12947                params[2] = n[6].f;
12948                params[3] = n[7].f;
12949                CALL_MultiTexEnvfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
12950             }
12951             break;
12952          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
12953             CALL_CompressedTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12954                                                          n[4].e, n[5].i, n[6].i,
12955                                                          n[7].i, get_pointer(&n[8])));
12956             break;
12957          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
12958             CALL_CompressedTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12959                                                          n[4].e, n[5].i, n[6].i,
12960                                                          n[7].i, n[8].i,
12961                                                          get_pointer(&n[9])));
12962             break;
12963          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
12964             CALL_CompressedTextureImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
12965                                                          n[4].e, n[5].i, n[6].i,
12966                                                          n[7].i, n[8].i, n[9].i,
12967                                                          get_pointer(&n[10])));
12968             break;
12969          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
12970             CALL_CompressedTextureSubImage1DEXT(ctx->Exec,
12971                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
12972                                                  n[5].i, n[6].e, n[7].i,
12973                                                  get_pointer(&n[8])));
12974             break;
12975          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
12976             CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
12977                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
12978                                                  n[5].i, n[6].i, n[7].i, n[8].e,
12979                                                  n[9].i, get_pointer(&n[10])));
12980             break;
12981          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
12982             CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
12983                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
12984                                                  n[5].i, n[6].i, n[7].i, n[8].i,
12985                                                  n[9].i, n[10].e, n[11].i,
12986                                                  get_pointer(&n[12])));
12987             break;
12988          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
12989             CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12990                                                          n[4].e, n[5].i, n[6].i,
12991                                                          n[7].i, get_pointer(&n[8])));
12992             break;
12993          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
12994             CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
12995                                                          n[4].e, n[5].i, n[6].i,
12996                                                          n[7].i, n[8].i,
12997                                                          get_pointer(&n[9])));
12998             break;
12999          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
13000             CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13001                                                          n[4].e, n[5].i, n[6].i,
13002                                                          n[7].i, n[8].i, n[9].i,
13003                                                          get_pointer(&n[10])));
13004             break;
13005          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
13006             CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec,
13007                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13008                                                  n[5].i, n[6].e, n[7].i,
13009                                                  get_pointer(&n[8])));
13010             break;
13011          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
13012             CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
13013                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13014                                                  n[5].i, n[6].i, n[7].i, n[8].e,
13015                                                  n[9].i, get_pointer(&n[10])));
13016             break;
13017          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
13018             CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
13019                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13020                                                  n[5].i, n[6].i, n[7].i, n[8].i,
13021                                                  n[9].i, n[10].e, n[11].i,
13022                                                  get_pointer(&n[12])));
13023             break;
13024          case OPCODE_NAMED_PROGRAM_STRING:
13025             CALL_NamedProgramStringEXT(ctx->Exec,
13026                                   (n[1].ui, n[2].e, n[3].e, n[4].i,
13027                                    get_pointer(&n[5])));
13028             break;
13029          case OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER:
13030             CALL_NamedProgramLocalParameter4fEXT(ctx->Exec,
13031                                             (n[1].ui, n[2].e, n[3].ui, n[4].f,
13032                                              n[5].f, n[6].f, n[7].f));
13033             break;
13034
13035          case OPCODE_PRIMITIVE_BOUNDING_BOX:
13036             CALL_PrimitiveBoundingBox(ctx->Exec,
13037                                       (n[1].f, n[2].f, n[3].f, n[4].f,
13038                                        n[5].f, n[6].f, n[7].f, n[8].f));
13039             break;
13040          case OPCODE_VERTEX_LIST:
13041             vbo_save_playback_vertex_list(ctx, &n[0], false);
13042             break;
13043
13044          case OPCODE_VERTEX_LIST_COPY_CURRENT:
13045             vbo_save_playback_vertex_list(ctx, &n[0], true);
13046             break;
13047
13048          case OPCODE_VERTEX_LIST_LOOPBACK:
13049             vbo_save_playback_vertex_list_loopback(ctx, &n[0]);
13050             break;
13051
13052          case OPCODE_CONTINUE:
13053             n = (Node *) get_pointer(&n[1]);
13054             continue;
13055          default:
13056             {
13057                char msg[1000];
13058                snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d",
13059                              (int) opcode);
13060                _mesa_problem(ctx, "%s", msg);
13061             }
13062             FALLTHROUGH;
13063          case OPCODE_END_OF_LIST:
13064             return;
13065       }
13066
13067       /* increment n to point to next compiled command */
13068       assert(n[0].InstSize > 0);
13069       n += n[0].InstSize;
13070    }
13071 }
13072
13073
13074
13075 /**********************************************************************/
13076 /*                           GL functions                             */
13077 /**********************************************************************/
13078
13079 /**
13080  * Test if a display list number is valid.
13081  */
13082 GLboolean GLAPIENTRY
13083 _mesa_IsList(GLuint list)
13084 {
13085    GET_CURRENT_CONTEXT(ctx);
13086    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13087    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
13088    return _mesa_get_list(ctx, list, NULL, false);
13089 }
13090
13091
13092 /**
13093  * Delete a sequence of consecutive display lists.
13094  */
13095 void GLAPIENTRY
13096 _mesa_DeleteLists(GLuint list, GLsizei range)
13097 {
13098    GET_CURRENT_CONTEXT(ctx);
13099    GLuint i;
13100    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13101    ASSERT_OUTSIDE_BEGIN_END(ctx);
13102
13103    if (range < 0) {
13104       _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
13105       return;
13106    }
13107
13108    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13109    for (i = list; i < list + range; i++) {
13110       destroy_list(ctx, i);
13111    }
13112    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13113 }
13114
13115
13116 /**
13117  * Return a display list number, n, such that lists n through n+range-1
13118  * are free.
13119  */
13120 GLuint GLAPIENTRY
13121 _mesa_GenLists(GLsizei range)
13122 {
13123    GET_CURRENT_CONTEXT(ctx);
13124    GLuint base;
13125    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13126    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
13127
13128    if (range < 0) {
13129       _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
13130       return 0;
13131    }
13132    if (range == 0) {
13133       return 0;
13134    }
13135
13136    /*
13137     * Make this an atomic operation
13138     */
13139    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13140
13141    base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
13142    if (base) {
13143       /* reserve the list IDs by with empty/dummy lists */
13144       GLint i;
13145       for (i = 0; i < range; i++) {
13146          _mesa_HashInsertLocked(ctx->Shared->DisplayList, base + i,
13147                                 make_list(base + i, 1), true);
13148       }
13149    }
13150
13151    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13152
13153    return base;
13154 }
13155
13156
13157 /**
13158  * Begin a new display list.
13159  */
13160 void GLAPIENTRY
13161 _mesa_NewList(GLuint name, GLenum mode)
13162 {
13163    GET_CURRENT_CONTEXT(ctx);
13164
13165    FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
13166    ASSERT_OUTSIDE_BEGIN_END(ctx);
13167
13168    if (MESA_VERBOSE & VERBOSE_API)
13169       _mesa_debug(ctx, "glNewList %u %s\n", name,
13170                   _mesa_enum_to_string(mode));
13171
13172    if (name == 0) {
13173       _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
13174       return;
13175    }
13176
13177    if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
13178       _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
13179       return;
13180    }
13181
13182    if (ctx->ListState.CurrentList) {
13183       /* already compiling a display list */
13184       _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
13185       return;
13186    }
13187
13188    ctx->CompileFlag = GL_TRUE;
13189    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
13190
13191    /* Reset accumulated list state */
13192    invalidate_saved_current_state( ctx );
13193
13194    /* Allocate new display list */
13195    ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
13196    ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
13197    ctx->ListState.CurrentPos = 0;
13198    ctx->ListState.LastInstSize = 0;
13199    ctx->ListState.Current.UseLoopback = false;
13200
13201    vbo_save_NewList(ctx, name, mode);
13202
13203    ctx->CurrentServerDispatch = ctx->Save;
13204    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13205    if (!ctx->GLThread.enabled) {
13206       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13207    }
13208 }
13209
13210
13211 /**
13212  * Walk all the opcode from a given list, recursively if OPCODE_CALL_LIST(S) is used,
13213  * and replace OPCODE_VERTEX_LIST[_COPY_CURRENT] occurences by OPCODE_VERTEX_LIST_LOOPBACK.
13214  */
13215 static void
13216 replace_op_vertex_list_recursively(struct gl_context *ctx, struct gl_display_list *dlist)
13217 {
13218    Node *n = get_list_head(ctx, dlist);
13219    while (true) {
13220       const OpCode opcode = n[0].opcode;
13221       switch (opcode) {
13222          case OPCODE_VERTEX_LIST:
13223          case OPCODE_VERTEX_LIST_COPY_CURRENT:
13224             n[0].opcode = OPCODE_VERTEX_LIST_LOOPBACK;
13225             break;
13226          case OPCODE_CONTINUE:
13227             n = (Node *)get_pointer(&n[1]);
13228             continue;
13229          case OPCODE_CALL_LIST:
13230             replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)n[1].ui, true));
13231             break;
13232          case OPCODE_CALL_LISTS: {
13233             GLbyte *bptr;
13234             GLubyte *ubptr;
13235             GLshort *sptr;
13236             GLushort *usptr;
13237             GLint *iptr;
13238             GLuint *uiptr;
13239             GLfloat *fptr;
13240             switch(n[2].e) {
13241                case GL_BYTE:
13242                   bptr = (GLbyte *) get_pointer(&n[3]);
13243                   for (unsigned i = 0; i < n[1].i; i++)
13244                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)bptr[i], true));
13245                   break;
13246                case GL_UNSIGNED_BYTE:
13247                   ubptr = (GLubyte *) get_pointer(&n[3]);
13248                   for (unsigned i = 0; i < n[1].i; i++)
13249                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)ubptr[i], true));
13250                   break;
13251                case GL_SHORT:
13252                   sptr = (GLshort *) get_pointer(&n[3]);
13253                   for (unsigned i = 0; i < n[1].i; i++)
13254                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)sptr[i], true));
13255                   break;
13256                case GL_UNSIGNED_SHORT:
13257                   usptr = (GLushort *) get_pointer(&n[3]);
13258                   for (unsigned i = 0; i < n[1].i; i++)
13259                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)usptr[i], true));
13260                   break;
13261                case GL_INT:
13262                   iptr = (GLint *) get_pointer(&n[3]);
13263                   for (unsigned i = 0; i < n[1].i; i++)
13264                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)iptr[i], true));
13265                   break;
13266                case GL_UNSIGNED_INT:
13267                   uiptr = (GLuint *) get_pointer(&n[3]);
13268                   for (unsigned i = 0; i < n[1].i; i++)
13269                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)uiptr[i], true));
13270                   break;
13271                case GL_FLOAT:
13272                   fptr = (GLfloat *) get_pointer(&n[3]);
13273                   for (unsigned i = 0; i < n[1].i; i++)
13274                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)fptr[i], true));
13275                   break;
13276                case GL_2_BYTES:
13277                   ubptr = (GLubyte *) get_pointer(&n[3]);
13278                   for (unsigned i = 0; i < n[1].i; i++) {
13279                      replace_op_vertex_list_recursively(ctx,
13280                                                 _mesa_lookup_list(ctx, (int)ubptr[2 * i] * 256 +
13281                                                                        (int)ubptr[2 * i + 1], true));
13282                   }
13283                   break;
13284                case GL_3_BYTES:
13285                   ubptr = (GLubyte *) get_pointer(&n[3]);
13286                   for (unsigned i = 0; i < n[1].i; i++) {
13287                      replace_op_vertex_list_recursively(ctx,
13288                                                 _mesa_lookup_list(ctx, (int)ubptr[3 * i] * 65536 +
13289                                                                   (int)ubptr[3 * i + 1] * 256 +
13290                                                                   (int)ubptr[3 * i + 2], true));
13291                   }
13292                   break;
13293                case GL_4_BYTES:
13294                   ubptr = (GLubyte *) get_pointer(&n[3]);
13295                   for (unsigned i = 0; i < n[1].i; i++) {
13296                      replace_op_vertex_list_recursively(ctx,
13297                                                 _mesa_lookup_list(ctx, (int)ubptr[4 * i] * 16777216 +
13298                                                                   (int)ubptr[4 * i + 1] * 65536 +
13299                                                                   (int)ubptr[4 * i + 2] * 256 +
13300                                                                   (int)ubptr[4 * i + 3], true));
13301                   }
13302                   break;
13303                }
13304             break;
13305          }
13306          case OPCODE_END_OF_LIST:
13307             return;
13308          default:
13309             break;
13310       }
13311       n += n[0].InstSize;
13312    }
13313 }
13314
13315
13316 /**
13317  * End definition of current display list.
13318  */
13319 void GLAPIENTRY
13320 _mesa_EndList(void)
13321 {
13322    GET_CURRENT_CONTEXT(ctx);
13323    SAVE_FLUSH_VERTICES(ctx);
13324    FLUSH_VERTICES(ctx, 0, 0);
13325
13326    if (MESA_VERBOSE & VERBOSE_API)
13327       _mesa_debug(ctx, "glEndList\n");
13328
13329    if (ctx->ExecuteFlag && _mesa_inside_dlist_begin_end(ctx)) {
13330       _mesa_error(ctx, GL_INVALID_OPERATION,
13331                   "glEndList() called inside glBegin/End");
13332    }
13333
13334    /* Check that a list is under construction */
13335    if (!ctx->ListState.CurrentList) {
13336       _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
13337       return;
13338    }
13339
13340    /* Call before emitting END_OF_LIST, in case the driver wants to
13341     * emit opcodes itself.
13342     */
13343    vbo_save_EndList(ctx);
13344
13345    (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
13346
13347    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13348
13349    if (ctx->ListState.Current.UseLoopback)
13350       replace_op_vertex_list_recursively(ctx, ctx->ListState.CurrentList);
13351
13352    struct gl_dlist_state *list = &ctx->ListState;
13353    list->CurrentList->execute_glthread =
13354       _mesa_glthread_should_execute_list(ctx, list->CurrentList);
13355    ctx->Shared->DisplayListsAffectGLThread |= list->CurrentList->execute_glthread;
13356
13357    if ((list->CurrentList->Head == list->CurrentBlock) &&
13358        (list->CurrentPos < BLOCK_SIZE)) {
13359       /* This list has a low number of commands. Instead of storing them in a malloc-ed block
13360        * of memory (list->CurrentBlock), we store them in ctx->Shared->small_dlist_store.ptr.
13361        * This reduces cache misses in execute_list on successive lists since their commands
13362        * are now stored in the same array instead of being scattered in memory.
13363        */
13364       list->CurrentList->small_list = true;
13365       unsigned start;
13366
13367       if (ctx->Shared->small_dlist_store.size == 0) {
13368          util_idalloc_init(&ctx->Shared->small_dlist_store.free_idx, MAX2(1, list->CurrentPos));
13369       }
13370
13371       start = util_idalloc_alloc_range(&ctx->Shared->small_dlist_store.free_idx, list->CurrentPos);
13372
13373       if ((start + list->CurrentPos) > ctx->Shared->small_dlist_store.size) {
13374          ctx->Shared->small_dlist_store.size =
13375             ctx->Shared->small_dlist_store.free_idx.num_elements * 32;
13376          ctx->Shared->small_dlist_store.ptr = realloc(
13377             ctx->Shared->small_dlist_store.ptr,
13378             ctx->Shared->small_dlist_store.size * sizeof(Node));
13379       }
13380       list->CurrentList->start = start;
13381       list->CurrentList->count = list->CurrentPos;
13382
13383       memcpy(&ctx->Shared->small_dlist_store.ptr[start],
13384              list->CurrentBlock,
13385              list->CurrentList->count * sizeof(Node));
13386
13387       assert (ctx->Shared->small_dlist_store.ptr[start + list->CurrentList->count - 1].opcode == OPCODE_END_OF_LIST);
13388
13389       free(list->CurrentBlock);
13390    } else {
13391       /* Keep the mallocated storage */
13392       list->CurrentList->small_list = false;
13393    }
13394
13395    /* Destroy old list, if any */
13396    destroy_list(ctx, ctx->ListState.CurrentList->Name);
13397
13398    /* Install the new list */
13399    _mesa_HashInsertLocked(ctx->Shared->DisplayList,
13400                           ctx->ListState.CurrentList->Name,
13401                           ctx->ListState.CurrentList, true);
13402
13403    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
13404       mesa_print_display_list(ctx->ListState.CurrentList->Name);
13405
13406    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13407
13408    ctx->ListState.CurrentList = NULL;
13409    ctx->ListState.CurrentBlock = NULL;
13410    ctx->ListState.CurrentPos = 0;
13411    ctx->ListState.LastInstSize = 0;
13412    ctx->ExecuteFlag = GL_TRUE;
13413    ctx->CompileFlag = GL_FALSE;
13414
13415    ctx->CurrentServerDispatch = ctx->Exec;
13416    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13417    if (!ctx->GLThread.enabled) {
13418       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13419    }
13420 }
13421
13422
13423 void GLAPIENTRY
13424 _mesa_CallList(GLuint list)
13425 {
13426    GLboolean save_compile_flag;
13427    GET_CURRENT_CONTEXT(ctx);
13428    FLUSH_CURRENT(ctx, 0);
13429
13430    if (MESA_VERBOSE & VERBOSE_API)
13431       _mesa_debug(ctx, "glCallList %d\n", list);
13432
13433    if (list == 0) {
13434       _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
13435       return;
13436    }
13437
13438    if (0)
13439       mesa_print_display_list( list );
13440
13441    /* Save the CompileFlag status, turn it off, execute the display list,
13442     * and restore the CompileFlag. This is needed for GL_COMPILE_AND_EXECUTE
13443     * because the call is already recorded and we just need to execute it.
13444     */
13445    save_compile_flag = ctx->CompileFlag;
13446    if (save_compile_flag) {
13447       ctx->CompileFlag = GL_FALSE;
13448    }
13449
13450    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13451    execute_list(ctx, list);
13452    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13453    ctx->CompileFlag = save_compile_flag;
13454
13455    /* also restore API function pointers to point to "save" versions */
13456    if (save_compile_flag) {
13457       ctx->CurrentServerDispatch = ctx->Save;
13458       if (!ctx->GLThread.enabled) {
13459          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13460       }
13461    }
13462 }
13463
13464
13465 /**
13466  * Execute glCallLists:  call multiple display lists.
13467  */
13468 void GLAPIENTRY
13469 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
13470 {
13471    GET_CURRENT_CONTEXT(ctx);
13472    GLboolean save_compile_flag;
13473
13474    if (MESA_VERBOSE & VERBOSE_API)
13475       _mesa_debug(ctx, "glCallLists %d\n", n);
13476
13477    if (type < GL_BYTE || type > GL_4_BYTES) {
13478       _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
13479       return;
13480    }
13481
13482    if (n < 0) {
13483       _mesa_error(ctx, GL_INVALID_VALUE, "glCallLists(n < 0)");
13484       return;
13485    } else if (n == 0 || lists == NULL) {
13486       /* nothing to do */
13487       return;
13488    }
13489
13490    /* Save the CompileFlag status, turn it off, execute the display lists,
13491     * and restore the CompileFlag. This is needed for GL_COMPILE_AND_EXECUTE
13492     * because the call is already recorded and we just need to execute it.
13493     */
13494    save_compile_flag = ctx->CompileFlag;
13495    ctx->CompileFlag = GL_FALSE;
13496
13497    GLbyte *bptr;
13498    GLubyte *ubptr;
13499    GLshort *sptr;
13500    GLushort *usptr;
13501    GLint *iptr;
13502    GLuint *uiptr;
13503    GLfloat *fptr;
13504
13505    GLuint base = ctx->List.ListBase;
13506
13507    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13508
13509    /* A loop inside a switch is faster than a switch inside a loop. */
13510    switch (type) {
13511    case GL_BYTE:
13512       bptr = (GLbyte *) lists;
13513       for (unsigned i = 0; i < n; i++)
13514          execute_list(ctx, base + (int)bptr[i]);
13515       break;
13516    case GL_UNSIGNED_BYTE:
13517       ubptr = (GLubyte *) lists;
13518       for (unsigned i = 0; i < n; i++)
13519          execute_list(ctx, base + (int)ubptr[i]);
13520       break;
13521    case GL_SHORT:
13522       sptr = (GLshort *) lists;
13523       for (unsigned i = 0; i < n; i++)
13524          execute_list(ctx, base + (int)sptr[i]);
13525       break;
13526    case GL_UNSIGNED_SHORT:
13527       usptr = (GLushort *) lists;
13528       for (unsigned i = 0; i < n; i++)
13529          execute_list(ctx, base + (int)usptr[i]);
13530       break;
13531    case GL_INT:
13532       iptr = (GLint *) lists;
13533       for (unsigned i = 0; i < n; i++)
13534          execute_list(ctx, base + (int)iptr[i]);
13535       break;
13536    case GL_UNSIGNED_INT:
13537       uiptr = (GLuint *) lists;
13538       for (unsigned i = 0; i < n; i++)
13539          execute_list(ctx, base + (int)uiptr[i]);
13540       break;
13541    case GL_FLOAT:
13542       fptr = (GLfloat *) lists;
13543       for (unsigned i = 0; i < n; i++)
13544          execute_list(ctx, base + (int)fptr[i]);
13545       break;
13546    case GL_2_BYTES:
13547       ubptr = (GLubyte *) lists;
13548       for (unsigned i = 0; i < n; i++) {
13549          execute_list(ctx, base +
13550                       (int)ubptr[2 * i] * 256 +
13551                       (int)ubptr[2 * i + 1]);
13552       }
13553       break;
13554    case GL_3_BYTES:
13555       ubptr = (GLubyte *) lists;
13556       for (unsigned i = 0; i < n; i++) {
13557          execute_list(ctx, base +
13558                       (int)ubptr[3 * i] * 65536 +
13559                       (int)ubptr[3 * i + 1] * 256 +
13560                       (int)ubptr[3 * i + 2]);
13561       }
13562       break;
13563    case GL_4_BYTES:
13564       ubptr = (GLubyte *) lists;
13565       for (unsigned i = 0; i < n; i++) {
13566          execute_list(ctx, base +
13567                       (int)ubptr[4 * i] * 16777216 +
13568                       (int)ubptr[4 * i + 1] * 65536 +
13569                       (int)ubptr[4 * i + 2] * 256 +
13570                       (int)ubptr[4 * i + 3]);
13571       }
13572       break;
13573    }
13574
13575    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13576    ctx->CompileFlag = save_compile_flag;
13577
13578    /* also restore API function pointers to point to "save" versions */
13579    if (save_compile_flag) {
13580       ctx->CurrentServerDispatch = ctx->Save;
13581       if (!ctx->GLThread.enabled) {
13582          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13583       }
13584    }
13585 }
13586
13587
13588 /**
13589  * Set the offset added to list numbers in glCallLists.
13590  */
13591 void GLAPIENTRY
13592 _mesa_ListBase(GLuint base)
13593 {
13594    GET_CURRENT_CONTEXT(ctx);
13595    FLUSH_VERTICES(ctx, 0, GL_LIST_BIT);   /* must be called before assert */
13596    ASSERT_OUTSIDE_BEGIN_END(ctx);
13597    ctx->List.ListBase = base;
13598 }
13599
13600 /**
13601  * Setup the given dispatch table to point to Mesa's display list
13602  * building functions.
13603  *
13604  * This does not include any of the tnl functions - they are
13605  * initialized from _mesa_init_api_defaults and from the active vtxfmt
13606  * struct.
13607  */
13608 void
13609 _mesa_initialize_save_table(const struct gl_context *ctx)
13610 {
13611    struct _glapi_table *table = ctx->Save;
13612    int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size());
13613
13614    /* Initially populate the dispatch table with the contents of the
13615     * normal-execution dispatch table.  This lets us skip populating functions
13616     * that should be called directly instead of compiled into display lists.
13617     */
13618    memcpy(table, ctx->OutsideBeginEnd, numEntries * sizeof(_glapi_proc));
13619
13620 #include "api_save_init.h"
13621 }
13622
13623
13624
13625 static const char *
13626 enum_string(GLenum k)
13627 {
13628    return _mesa_enum_to_string(k);
13629 }
13630
13631
13632 /**
13633  * Print the commands in a display list.  For debugging only.
13634  * TODO: many commands aren't handled yet.
13635  * \param fname  filename to write display list to.  If null, use stdout.
13636  */
13637 static void
13638 print_list(struct gl_context *ctx, GLuint list, const char *fname)
13639 {
13640    struct gl_display_list *dlist;
13641    Node *n;
13642    FILE *f = stdout;
13643
13644    if (fname) {
13645       f = fopen(fname, "w");
13646       if (!f)
13647          return;
13648    }
13649
13650    if (!_mesa_get_list(ctx, list, &dlist, true)) {
13651       fprintf(f, "%u is not a display list ID\n", list);
13652       fflush(f);
13653       if (fname)
13654          fclose(f);
13655       return;
13656    }
13657
13658    n = get_list_head(ctx, dlist);
13659
13660    fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
13661
13662    while (1) {
13663       const OpCode opcode = n[0].opcode;
13664
13665       switch (opcode) {
13666          case OPCODE_ACCUM:
13667             fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f);
13668             break;
13669          case OPCODE_ACTIVE_TEXTURE:
13670             fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e));
13671             break;
13672          case OPCODE_BITMAP:
13673             fprintf(f, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
13674                    n[3].f, n[4].f, n[5].f, n[6].f,
13675                    get_pointer(&n[7]));
13676             break;
13677          case OPCODE_BLEND_COLOR:
13678             fprintf(f, "BlendColor %f, %f, %f, %f\n",
13679                     n[1].f, n[2].f, n[3].f, n[4].f);
13680             break;
13681          case OPCODE_BLEND_EQUATION:
13682             fprintf(f, "BlendEquation %s\n",
13683                     enum_string(n[1].e));
13684             break;
13685          case OPCODE_BLEND_EQUATION_SEPARATE:
13686             fprintf(f, "BlendEquationSeparate %s, %s\n",
13687                     enum_string(n[1].e),
13688                     enum_string(n[2].e));
13689             break;
13690          case OPCODE_BLEND_FUNC_SEPARATE:
13691             fprintf(f, "BlendFuncSeparate %s, %s, %s, %s\n",
13692                     enum_string(n[1].e),
13693                     enum_string(n[2].e),
13694                     enum_string(n[3].e),
13695                     enum_string(n[4].e));
13696             break;
13697          case OPCODE_BLEND_EQUATION_I:
13698             fprintf(f, "BlendEquationi %u, %s\n",
13699                     n[1].ui, enum_string(n[2].e));
13700             break;
13701          case OPCODE_BLEND_EQUATION_SEPARATE_I:
13702             fprintf(f, "BlendEquationSeparatei %u, %s, %s\n",
13703                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
13704             break;
13705          case OPCODE_BLEND_FUNC_I:
13706             fprintf(f, "BlendFunci %u, %s, %s\n",
13707                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
13708             break;
13709          case OPCODE_BLEND_FUNC_SEPARATE_I:
13710             fprintf(f, "BlendFuncSeparatei %u, %s, %s, %s, %s\n",
13711                     n[1].ui,
13712                     enum_string(n[2].e),
13713                     enum_string(n[3].e),
13714                     enum_string(n[4].e),
13715                     enum_string(n[5].e));
13716             break;
13717          case OPCODE_CALL_LIST:
13718             fprintf(f, "CallList %d\n", (int) n[1].ui);
13719             break;
13720          case OPCODE_CALL_LISTS:
13721             fprintf(f, "CallLists %d, %s\n", n[1].i, enum_string(n[1].e));
13722             break;
13723          case OPCODE_DISABLE:
13724             fprintf(f, "Disable %s\n", enum_string(n[1].e));
13725             break;
13726          case OPCODE_ENABLE:
13727             fprintf(f, "Enable %s\n", enum_string(n[1].e));
13728             break;
13729          case OPCODE_FRUSTUM:
13730             fprintf(f, "Frustum %g %g %g %g %g %g\n",
13731                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
13732             break;
13733          case OPCODE_LINE_STIPPLE:
13734             fprintf(f, "LineStipple %d %x\n", n[1].i, (int) n[2].us);
13735             break;
13736          case OPCODE_LINE_WIDTH:
13737             fprintf(f, "LineWidth %f\n", n[1].f);
13738             break;
13739          case OPCODE_LOAD_IDENTITY:
13740             fprintf(f, "LoadIdentity\n");
13741             break;
13742          case OPCODE_LOAD_MATRIX:
13743             fprintf(f, "LoadMatrix\n");
13744             fprintf(f, "  %8f %8f %8f %8f\n",
13745                          n[1].f, n[5].f, n[9].f, n[13].f);
13746             fprintf(f, "  %8f %8f %8f %8f\n",
13747                          n[2].f, n[6].f, n[10].f, n[14].f);
13748             fprintf(f, "  %8f %8f %8f %8f\n",
13749                          n[3].f, n[7].f, n[11].f, n[15].f);
13750             fprintf(f, "  %8f %8f %8f %8f\n",
13751                          n[4].f, n[8].f, n[12].f, n[16].f);
13752             break;
13753          case OPCODE_MULT_MATRIX:
13754             fprintf(f, "MultMatrix (or Rotate)\n");
13755             fprintf(f, "  %8f %8f %8f %8f\n",
13756                          n[1].f, n[5].f, n[9].f, n[13].f);
13757             fprintf(f, "  %8f %8f %8f %8f\n",
13758                          n[2].f, n[6].f, n[10].f, n[14].f);
13759             fprintf(f, "  %8f %8f %8f %8f\n",
13760                          n[3].f, n[7].f, n[11].f, n[15].f);
13761             fprintf(f, "  %8f %8f %8f %8f\n",
13762                          n[4].f, n[8].f, n[12].f, n[16].f);
13763             break;
13764          case OPCODE_ORTHO:
13765             fprintf(f, "Ortho %g %g %g %g %g %g\n",
13766                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
13767             break;
13768          case OPCODE_POINT_SIZE:
13769             fprintf(f, "PointSize %f\n", n[1].f);
13770             break;
13771          case OPCODE_POP_ATTRIB:
13772             fprintf(f, "PopAttrib\n");
13773             break;
13774          case OPCODE_POP_MATRIX:
13775             fprintf(f, "PopMatrix\n");
13776             break;
13777          case OPCODE_POP_NAME:
13778             fprintf(f, "PopName\n");
13779             break;
13780          case OPCODE_PUSH_ATTRIB:
13781             fprintf(f, "PushAttrib %x\n", n[1].bf);
13782             break;
13783          case OPCODE_PUSH_MATRIX:
13784             fprintf(f, "PushMatrix\n");
13785             break;
13786          case OPCODE_PUSH_NAME:
13787             fprintf(f, "PushName %d\n", (int) n[1].ui);
13788             break;
13789          case OPCODE_RASTER_POS:
13790             fprintf(f, "RasterPos %g %g %g %g\n",
13791                          n[1].f, n[2].f, n[3].f, n[4].f);
13792             break;
13793          case OPCODE_ROTATE:
13794             fprintf(f, "Rotate %g %g %g %g\n",
13795                          n[1].f, n[2].f, n[3].f, n[4].f);
13796             break;
13797          case OPCODE_SCALE:
13798             fprintf(f, "Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
13799             break;
13800          case OPCODE_TRANSLATE:
13801             fprintf(f, "Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
13802             break;
13803          case OPCODE_BIND_TEXTURE:
13804             fprintf(f, "BindTexture %s %d\n",
13805                          _mesa_enum_to_string(n[1].ui), n[2].ui);
13806             break;
13807          case OPCODE_SHADE_MODEL:
13808             fprintf(f, "ShadeModel %s\n", _mesa_enum_to_string(n[1].ui));
13809             break;
13810          case OPCODE_MAP1:
13811             fprintf(f, "Map1 %s %.3f %.3f %d %d\n",
13812                          _mesa_enum_to_string(n[1].ui),
13813                          n[2].f, n[3].f, n[4].i, n[5].i);
13814             break;
13815          case OPCODE_MAP2:
13816             fprintf(f, "Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
13817                          _mesa_enum_to_string(n[1].ui),
13818                          n[2].f, n[3].f, n[4].f, n[5].f,
13819                          n[6].i, n[7].i, n[8].i, n[9].i);
13820             break;
13821          case OPCODE_MAPGRID1:
13822             fprintf(f, "MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
13823             break;
13824          case OPCODE_MAPGRID2:
13825             fprintf(f, "MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
13826                          n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
13827             break;
13828          case OPCODE_EVALMESH1:
13829             fprintf(f, "EvalMesh1 %d %d\n", n[1].i, n[2].i);
13830             break;
13831          case OPCODE_EVALMESH2:
13832             fprintf(f, "EvalMesh2 %d %d %d %d\n",
13833                          n[1].i, n[2].i, n[3].i, n[4].i);
13834             break;
13835
13836          case OPCODE_ATTR_1F_NV:
13837             fprintf(f, "ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
13838             break;
13839          case OPCODE_ATTR_2F_NV:
13840             fprintf(f, "ATTR_2F_NV attr %d: %f %f\n",
13841                          n[1].i, n[2].f, n[3].f);
13842             break;
13843          case OPCODE_ATTR_3F_NV:
13844             fprintf(f, "ATTR_3F_NV attr %d: %f %f %f\n",
13845                          n[1].i, n[2].f, n[3].f, n[4].f);
13846             break;
13847          case OPCODE_ATTR_4F_NV:
13848             fprintf(f, "ATTR_4F_NV attr %d: %f %f %f %f\n",
13849                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
13850             break;
13851          case OPCODE_ATTR_1F_ARB:
13852             fprintf(f, "ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
13853             break;
13854          case OPCODE_ATTR_2F_ARB:
13855             fprintf(f, "ATTR_2F_ARB attr %d: %f %f\n",
13856                          n[1].i, n[2].f, n[3].f);
13857             break;
13858          case OPCODE_ATTR_3F_ARB:
13859             fprintf(f, "ATTR_3F_ARB attr %d: %f %f %f\n",
13860                          n[1].i, n[2].f, n[3].f, n[4].f);
13861             break;
13862          case OPCODE_ATTR_4F_ARB:
13863             fprintf(f, "ATTR_4F_ARB attr %d: %f %f %f %f\n",
13864                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
13865             break;
13866
13867          case OPCODE_MATERIAL:
13868             fprintf(f, "MATERIAL %x %x: %f %f %f %f\n",
13869                          n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
13870             break;
13871          case OPCODE_BEGIN:
13872             fprintf(f, "BEGIN %x\n", n[1].i);
13873             break;
13874          case OPCODE_END:
13875             fprintf(f, "END\n");
13876             break;
13877          case OPCODE_EVAL_C1:
13878             fprintf(f, "EVAL_C1 %f\n", n[1].f);
13879             break;
13880          case OPCODE_EVAL_C2:
13881             fprintf(f, "EVAL_C2 %f %f\n", n[1].f, n[2].f);
13882             break;
13883          case OPCODE_EVAL_P1:
13884             fprintf(f, "EVAL_P1 %d\n", n[1].i);
13885             break;
13886          case OPCODE_EVAL_P2:
13887             fprintf(f, "EVAL_P2 %d %d\n", n[1].i, n[2].i);
13888             break;
13889
13890          case OPCODE_PROVOKING_VERTEX:
13891             fprintf(f, "ProvokingVertex %s\n",
13892                          _mesa_enum_to_string(n[1].ui));
13893             break;
13894
13895             /*
13896              * meta opcodes/commands
13897              */
13898          case OPCODE_ERROR:
13899             fprintf(f, "Error: %s %s\n", enum_string(n[1].e),
13900                    (const char *) get_pointer(&n[2]));
13901             break;
13902          case OPCODE_CONTINUE:
13903             fprintf(f, "DISPLAY-LIST-CONTINUE\n");
13904             n = (Node *) get_pointer(&n[1]);
13905             continue;
13906          case OPCODE_VERTEX_LIST:
13907          case OPCODE_VERTEX_LIST_LOOPBACK:
13908          case OPCODE_VERTEX_LIST_COPY_CURRENT:
13909             vbo_print_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[0], opcode, f);
13910             break;
13911          default:
13912             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
13913                printf
13914                   ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
13915                    opcode, (void *) n);
13916             } else {
13917                fprintf(f, "command %d, %u operands\n", opcode,
13918                             n[0].InstSize);
13919                break;
13920             }
13921             FALLTHROUGH;
13922          case OPCODE_END_OF_LIST:
13923             fprintf(f, "END-LIST %u\n", list);
13924             fflush(f);
13925             if (fname)
13926                fclose(f);
13927             return;
13928       }
13929
13930       /* increment n to point to next compiled command */
13931       assert(n[0].InstSize > 0);
13932       n += n[0].InstSize;
13933    }
13934 }
13935
13936
13937 void
13938 _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
13939 {
13940    struct gl_display_list *dlist;
13941
13942    if (list == 0 ||
13943        !_mesa_get_list(ctx, list, &dlist, true) ||
13944        !dlist->execute_glthread)
13945       return;
13946
13947    Node *n = get_list_head(ctx, dlist);
13948
13949    while (1) {
13950       const OpCode opcode = n[0].opcode;
13951
13952       switch (opcode) {
13953          case OPCODE_CALL_LIST:
13954             /* Generated by glCallList(), don't add ListBase */
13955             if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
13956                ctx->GLThread.ListCallDepth++;
13957                _mesa_glthread_execute_list(ctx, n[1].ui);
13958                ctx->GLThread.ListCallDepth--;
13959             }
13960             break;
13961          case OPCODE_CALL_LISTS:
13962             if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
13963                ctx->GLThread.ListCallDepth++;
13964                _mesa_glthread_CallLists(ctx, n[1].i, n[2].e, get_pointer(&n[3]));
13965                ctx->GLThread.ListCallDepth--;
13966             }
13967             break;
13968          case OPCODE_DISABLE:
13969             _mesa_glthread_Disable(ctx, n[1].e);
13970             break;
13971          case OPCODE_ENABLE:
13972             _mesa_glthread_Enable(ctx, n[1].e);
13973             break;
13974          case OPCODE_LIST_BASE:
13975             _mesa_glthread_ListBase(ctx, n[1].ui);
13976             break;
13977          case OPCODE_MATRIX_MODE:
13978             _mesa_glthread_MatrixMode(ctx, n[1].e);
13979             break;
13980          case OPCODE_POP_ATTRIB:
13981             _mesa_glthread_PopAttrib(ctx);
13982             break;
13983          case OPCODE_POP_MATRIX:
13984             _mesa_glthread_PopMatrix(ctx);
13985             break;
13986          case OPCODE_PUSH_ATTRIB:
13987             _mesa_glthread_PushAttrib(ctx, n[1].bf);
13988             break;
13989          case OPCODE_PUSH_MATRIX:
13990             _mesa_glthread_PushMatrix(ctx);
13991             break;
13992          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
13993             _mesa_glthread_ActiveTexture(ctx, n[1].e);
13994             break;
13995          case OPCODE_MATRIX_PUSH:
13996             _mesa_glthread_MatrixPushEXT(ctx, n[1].e);
13997             break;
13998          case OPCODE_MATRIX_POP:
13999             _mesa_glthread_MatrixPopEXT(ctx, n[1].e);
14000             break;
14001          case OPCODE_CONTINUE:
14002             n = (Node *)get_pointer(&n[1]);
14003             continue;
14004          case OPCODE_END_OF_LIST:
14005             ctx->GLThread.ListCallDepth--;
14006             return;
14007          default:
14008             /* ignore */
14009             break;
14010       }
14011
14012       /* increment n to point to next compiled command */
14013       assert(n[0].InstSize > 0);
14014       n += n[0].InstSize;
14015    }
14016 }
14017
14018 static bool
14019 _mesa_glthread_should_execute_list(struct gl_context *ctx,
14020                                    struct gl_display_list *dlist)
14021 {
14022    Node *n = get_list_head(ctx, dlist);
14023
14024    while (1) {
14025       const OpCode opcode = n[0].opcode;
14026
14027       switch (opcode) {
14028       case OPCODE_CALL_LIST:
14029       case OPCODE_CALL_LISTS:
14030       case OPCODE_DISABLE:
14031       case OPCODE_ENABLE:
14032       case OPCODE_LIST_BASE:
14033       case OPCODE_MATRIX_MODE:
14034       case OPCODE_POP_ATTRIB:
14035       case OPCODE_POP_MATRIX:
14036       case OPCODE_PUSH_ATTRIB:
14037       case OPCODE_PUSH_MATRIX:
14038       case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
14039       case OPCODE_MATRIX_PUSH:
14040       case OPCODE_MATRIX_POP:
14041          return true;
14042       case OPCODE_CONTINUE:
14043          n = (Node *)get_pointer(&n[1]);
14044          continue;
14045       case OPCODE_END_OF_LIST:
14046          return false;
14047       default:
14048          /* ignore */
14049          break;
14050       }
14051
14052       /* increment n to point to next compiled command */
14053       assert(n[0].InstSize > 0);
14054       n += n[0].InstSize;
14055    }
14056    return false;
14057 }
14058
14059
14060 /**
14061  * Clients may call this function to help debug display list problems.
14062  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
14063  * changed, or break in the future without notice.
14064  */
14065 void
14066 mesa_print_display_list(GLuint list)
14067 {
14068    GET_CURRENT_CONTEXT(ctx);
14069    print_list(ctx, list, NULL);
14070 }
14071
14072
14073 /**********************************************************************/
14074 /*****                      Initialization                        *****/
14075 /**********************************************************************/
14076
14077 /**
14078  * Initialize display list state for given context.
14079  */
14080 void
14081 _mesa_init_display_list(struct gl_context *ctx)
14082 {
14083    /* Display list */
14084    ctx->ListState.CallDepth = 1;
14085    ctx->ExecuteFlag = GL_TRUE;
14086    ctx->CompileFlag = GL_FALSE;
14087    ctx->ListState.CurrentBlock = NULL;
14088    ctx->ListState.CurrentPos = 0;
14089    ctx->ListState.LastInstSize = 0;
14090
14091    /* Display List group */
14092    ctx->List.ListBase = 0;
14093 }
14094
14095
14096 void
14097 _mesa_install_save_vtxfmt(struct gl_context *ctx)
14098 {
14099    struct _glapi_table *tab = ctx->Save;
14100    assert(ctx->API == API_OPENGL_COMPAT);
14101
14102 #define NAME_AE(x) _mesa_##x
14103 #define NAME_CALLLIST(x) save_##x
14104 #define NAME(x) save_##x
14105 #define NAME_ES(x) save_##x
14106
14107    #include "api_vtxfmt_init.h"
14108 }