• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "c99_math.h"
33 #include "glheader.h"
34 
35 #include "api_arrayelt.h"
36 #include "api_exec.h"
37 #include "draw_validate.h"
38 #include "atifragshader.h"
39 #include "config.h"
40 #include "bufferobj.h"
41 #include "arrayobj.h"
42 #include "context.h"
43 #include "dlist.h"
44 #include "enums.h"
45 #include "eval.h"
46 #include "fbobject.h"
47 #include "framebuffer.h"
48 #include "glapi/glapi.h"
49 #include "glformats.h"
50 #include "hash.h"
51 #include "image.h"
52 #include "light.h"
53 #include "macros.h"
54 #include "pack.h"
55 #include "pbo.h"
56 #include "queryobj.h"
57 #include "samplerobj.h"
58 #include "shaderapi.h"
59 #include "syncobj.h"
60 #include "teximage.h"
61 #include "texstorage.h"
62 #include "mtypes.h"
63 #include "varray.h"
64 #include "arbprogram.h"
65 #include "transformfeedback.h"
66 
67 #include "math/m_matrix.h"
68 
69 #include "main/dispatch.h"
70 
71 #include "vbo/vbo.h"
72 #include "vbo/vbo_util.h"
73 #include "util/format_r11g11b10f.h"
74 
75 #include "util/u_memory.h"
76 
77 #define USE_BITMAP_ATLAS 1
78 
79 
80 
81 /**
82  * Other parts of Mesa (such as the VBO module) can plug into the display
83  * list system.  This structure describes new display list instructions.
84  */
85 struct gl_list_instruction
86 {
87    GLuint Size;
88    void (*Execute)( struct gl_context *ctx, void *data );
89    void (*Destroy)( struct gl_context *ctx, void *data );
90    void (*Print)( struct gl_context *ctx, void *data, FILE *f );
91 };
92 
93 
94 #define MAX_DLIST_EXT_OPCODES 16
95 
96 /**
97  * Used by device drivers to hook new commands into display lists.
98  */
99 struct gl_list_extensions
100 {
101    struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
102    GLuint NumOpcodes;
103 };
104 
105 
106 
107 /**
108  * Flush vertices.
109  *
110  * \param ctx GL context.
111  *
112  * Checks if dd_function_table::SaveNeedFlush is marked to flush
113  * stored (save) vertices, and calls vbo_save_SaveFlushVertices if so.
114  */
115 #define SAVE_FLUSH_VERTICES(ctx)                     \
116    do {                                              \
117       if (ctx->Driver.SaveNeedFlush)                 \
118          vbo_save_SaveFlushVertices(ctx);            \
119    } while (0)
120 
121 
122 /**
123  * Macro to assert that the API call was made outside the
124  * glBegin()/glEnd() pair, with return value.
125  *
126  * \param ctx GL context.
127  * \param retval value to return value in case the assertion fails.
128  */
129 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)          \
130    do {                                                                 \
131       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
132          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
133          return retval;                                                 \
134       }                                                                 \
135    } while (0)
136 
137 /**
138  * Macro to assert that the API call was made outside the
139  * glBegin()/glEnd() pair.
140  *
141  * \param ctx GL context.
142  */
143 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)                              \
144    do {                                                                 \
145       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
146          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
147          return;                                                        \
148       }                                                                 \
149    } while (0)
150 
151 /**
152  * Macro to assert that the API call was made outside the
153  * glBegin()/glEnd() pair and flush the vertices.
154  *
155  * \param ctx GL context.
156  */
157 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                    \
158    do {                                                                 \
159       ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                               \
160       SAVE_FLUSH_VERTICES(ctx);                                         \
161    } while (0)
162 
163 /**
164  * Macro to assert that the API call was made outside the
165  * glBegin()/glEnd() pair and flush the vertices, with return value.
166  *
167  * \param ctx GL context.
168  * \param retval value to return value in case the assertion fails.
169  */
170 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
171    do {                                                                 \
172       ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);           \
173       SAVE_FLUSH_VERTICES(ctx);                                         \
174    } while (0)
175 
176 
177 /**
178  * Display list opcodes.
179  *
180  * The fact that these identifiers are assigned consecutive
181  * integer values starting at 0 is very important, see InstSize array usage)
182  */
183 typedef enum
184 {
185    OPCODE_INVALID = -1,         /* Force signed enum */
186    OPCODE_ACCUM,
187    OPCODE_ALPHA_FUNC,
188    OPCODE_BIND_TEXTURE,
189    OPCODE_BITMAP,
190    OPCODE_BLEND_COLOR,
191    OPCODE_BLEND_EQUATION,
192    OPCODE_BLEND_EQUATION_SEPARATE,
193    OPCODE_BLEND_FUNC_SEPARATE,
194 
195    OPCODE_BLEND_EQUATION_I,
196    OPCODE_BLEND_EQUATION_SEPARATE_I,
197    OPCODE_BLEND_FUNC_I,
198    OPCODE_BLEND_FUNC_SEPARATE_I,
199 
200    OPCODE_CALL_LIST,
201    OPCODE_CALL_LISTS,
202    OPCODE_CLEAR,
203    OPCODE_CLEAR_ACCUM,
204    OPCODE_CLEAR_COLOR,
205    OPCODE_CLEAR_DEPTH,
206    OPCODE_CLEAR_INDEX,
207    OPCODE_CLEAR_STENCIL,
208    OPCODE_CLEAR_BUFFER_IV,
209    OPCODE_CLEAR_BUFFER_UIV,
210    OPCODE_CLEAR_BUFFER_FV,
211    OPCODE_CLEAR_BUFFER_FI,
212    OPCODE_CLIP_PLANE,
213    OPCODE_COLOR_MASK,
214    OPCODE_COLOR_MASK_INDEXED,
215    OPCODE_COLOR_MATERIAL,
216    OPCODE_COPY_PIXELS,
217    OPCODE_COPY_TEX_IMAGE1D,
218    OPCODE_COPY_TEX_IMAGE2D,
219    OPCODE_COPY_TEX_SUB_IMAGE1D,
220    OPCODE_COPY_TEX_SUB_IMAGE2D,
221    OPCODE_COPY_TEX_SUB_IMAGE3D,
222    OPCODE_CULL_FACE,
223    OPCODE_DEPTH_FUNC,
224    OPCODE_DEPTH_MASK,
225    OPCODE_DEPTH_RANGE,
226    OPCODE_DISABLE,
227    OPCODE_DISABLE_INDEXED,
228    OPCODE_DRAW_BUFFER,
229    OPCODE_DRAW_PIXELS,
230    OPCODE_ENABLE,
231    OPCODE_ENABLE_INDEXED,
232    OPCODE_EVALMESH1,
233    OPCODE_EVALMESH2,
234    OPCODE_FOG,
235    OPCODE_FRONT_FACE,
236    OPCODE_FRUSTUM,
237    OPCODE_HINT,
238    OPCODE_INDEX_MASK,
239    OPCODE_INIT_NAMES,
240    OPCODE_LIGHT,
241    OPCODE_LIGHT_MODEL,
242    OPCODE_LINE_STIPPLE,
243    OPCODE_LINE_WIDTH,
244    OPCODE_LIST_BASE,
245    OPCODE_LOAD_IDENTITY,
246    OPCODE_LOAD_MATRIX,
247    OPCODE_LOAD_NAME,
248    OPCODE_LOGIC_OP,
249    OPCODE_MAP1,
250    OPCODE_MAP2,
251    OPCODE_MAPGRID1,
252    OPCODE_MAPGRID2,
253    OPCODE_MATRIX_MODE,
254    OPCODE_MULT_MATRIX,
255    OPCODE_ORTHO,
256    OPCODE_PASSTHROUGH,
257    OPCODE_PIXEL_MAP,
258    OPCODE_PIXEL_TRANSFER,
259    OPCODE_PIXEL_ZOOM,
260    OPCODE_POINT_SIZE,
261    OPCODE_POINT_PARAMETERS,
262    OPCODE_POLYGON_MODE,
263    OPCODE_POLYGON_STIPPLE,
264    OPCODE_POLYGON_OFFSET,
265    OPCODE_POP_ATTRIB,
266    OPCODE_POP_MATRIX,
267    OPCODE_POP_NAME,
268    OPCODE_PRIORITIZE_TEXTURE,
269    OPCODE_PUSH_ATTRIB,
270    OPCODE_PUSH_MATRIX,
271    OPCODE_PUSH_NAME,
272    OPCODE_RASTER_POS,
273    OPCODE_READ_BUFFER,
274    OPCODE_ROTATE,
275    OPCODE_SCALE,
276    OPCODE_SCISSOR,
277    OPCODE_SELECT_TEXTURE_SGIS,
278    OPCODE_SELECT_TEXTURE_COORD_SET,
279    OPCODE_SHADE_MODEL,
280    OPCODE_STENCIL_FUNC,
281    OPCODE_STENCIL_MASK,
282    OPCODE_STENCIL_OP,
283    OPCODE_TEXENV,
284    OPCODE_TEXGEN,
285    OPCODE_TEXPARAMETER,
286    OPCODE_TEX_IMAGE1D,
287    OPCODE_TEX_IMAGE2D,
288    OPCODE_TEX_IMAGE3D,
289    OPCODE_TEX_SUB_IMAGE1D,
290    OPCODE_TEX_SUB_IMAGE2D,
291    OPCODE_TEX_SUB_IMAGE3D,
292    OPCODE_TRANSLATE,
293    OPCODE_VIEWPORT,
294    OPCODE_WINDOW_POS,
295    /* ARB_viewport_array */
296    OPCODE_VIEWPORT_ARRAY_V,
297    OPCODE_VIEWPORT_INDEXED_F,
298    OPCODE_VIEWPORT_INDEXED_FV,
299    OPCODE_SCISSOR_ARRAY_V,
300    OPCODE_SCISSOR_INDEXED,
301    OPCODE_SCISSOR_INDEXED_V,
302    OPCODE_DEPTH_ARRAY_V,
303    OPCODE_DEPTH_INDEXED,
304    /* GL_ARB_multitexture */
305    OPCODE_ACTIVE_TEXTURE,
306    /* GL_ARB_texture_compression */
307    OPCODE_COMPRESSED_TEX_IMAGE_1D,
308    OPCODE_COMPRESSED_TEX_IMAGE_2D,
309    OPCODE_COMPRESSED_TEX_IMAGE_3D,
310    OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
311    OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
312    OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
313    /* GL_ARB_multisample */
314    OPCODE_SAMPLE_COVERAGE,
315    /* GL_ARB_window_pos */
316    OPCODE_WINDOW_POS_ARB,
317    /* GL_ARB_vertex_program */
318    OPCODE_BIND_PROGRAM_ARB,
319    OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
320    /* GL_EXT_stencil_two_side */
321    OPCODE_ACTIVE_STENCIL_FACE_EXT,
322    /* GL_EXT_depth_bounds_test */
323    OPCODE_DEPTH_BOUNDS_EXT,
324    /* GL_ARB_vertex/fragment_program */
325    OPCODE_PROGRAM_STRING_ARB,
326    OPCODE_PROGRAM_ENV_PARAMETER_ARB,
327    /* GL_ARB_occlusion_query */
328    OPCODE_BEGIN_QUERY_ARB,
329    OPCODE_END_QUERY_ARB,
330    /* GL_ARB_draw_buffers */
331    OPCODE_DRAW_BUFFERS_ARB,
332    /* GL_ATI_fragment_shader */
333    OPCODE_BIND_FRAGMENT_SHADER_ATI,
334    OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
335    /* OpenGL 2.0 */
336    OPCODE_STENCIL_FUNC_SEPARATE,
337    OPCODE_STENCIL_OP_SEPARATE,
338    OPCODE_STENCIL_MASK_SEPARATE,
339    /* GL_NV_primitive_restart */
340    OPCODE_PRIMITIVE_RESTART_NV,
341    /* GL_ARB_shader_objects */
342    OPCODE_USE_PROGRAM,
343    OPCODE_UNIFORM_1F,
344    OPCODE_UNIFORM_2F,
345    OPCODE_UNIFORM_3F,
346    OPCODE_UNIFORM_4F,
347    OPCODE_UNIFORM_1FV,
348    OPCODE_UNIFORM_2FV,
349    OPCODE_UNIFORM_3FV,
350    OPCODE_UNIFORM_4FV,
351    OPCODE_UNIFORM_1I,
352    OPCODE_UNIFORM_2I,
353    OPCODE_UNIFORM_3I,
354    OPCODE_UNIFORM_4I,
355    OPCODE_UNIFORM_1IV,
356    OPCODE_UNIFORM_2IV,
357    OPCODE_UNIFORM_3IV,
358    OPCODE_UNIFORM_4IV,
359    OPCODE_UNIFORM_MATRIX22,
360    OPCODE_UNIFORM_MATRIX33,
361    OPCODE_UNIFORM_MATRIX44,
362    OPCODE_UNIFORM_MATRIX23,
363    OPCODE_UNIFORM_MATRIX32,
364    OPCODE_UNIFORM_MATRIX24,
365    OPCODE_UNIFORM_MATRIX42,
366    OPCODE_UNIFORM_MATRIX34,
367    OPCODE_UNIFORM_MATRIX43,
368 
369    /* OpenGL 3.0 */
370    OPCODE_UNIFORM_1UI,
371    OPCODE_UNIFORM_2UI,
372    OPCODE_UNIFORM_3UI,
373    OPCODE_UNIFORM_4UI,
374    OPCODE_UNIFORM_1UIV,
375    OPCODE_UNIFORM_2UIV,
376    OPCODE_UNIFORM_3UIV,
377    OPCODE_UNIFORM_4UIV,
378 
379    /* GL_ARB_gpu_shader_fp64 */
380    OPCODE_UNIFORM_1D,
381    OPCODE_UNIFORM_2D,
382    OPCODE_UNIFORM_3D,
383    OPCODE_UNIFORM_4D,
384    OPCODE_UNIFORM_1DV,
385    OPCODE_UNIFORM_2DV,
386    OPCODE_UNIFORM_3DV,
387    OPCODE_UNIFORM_4DV,
388    OPCODE_UNIFORM_MATRIX22D,
389    OPCODE_UNIFORM_MATRIX33D,
390    OPCODE_UNIFORM_MATRIX44D,
391    OPCODE_UNIFORM_MATRIX23D,
392    OPCODE_UNIFORM_MATRIX32D,
393    OPCODE_UNIFORM_MATRIX24D,
394    OPCODE_UNIFORM_MATRIX42D,
395    OPCODE_UNIFORM_MATRIX34D,
396    OPCODE_UNIFORM_MATRIX43D,
397 
398    /* GL_ARB_gpu_shader_int64 */
399    OPCODE_UNIFORM_1I64,
400    OPCODE_UNIFORM_2I64,
401    OPCODE_UNIFORM_3I64,
402    OPCODE_UNIFORM_4I64,
403    OPCODE_UNIFORM_1I64V,
404    OPCODE_UNIFORM_2I64V,
405    OPCODE_UNIFORM_3I64V,
406    OPCODE_UNIFORM_4I64V,
407    OPCODE_UNIFORM_1UI64,
408    OPCODE_UNIFORM_2UI64,
409    OPCODE_UNIFORM_3UI64,
410    OPCODE_UNIFORM_4UI64,
411    OPCODE_UNIFORM_1UI64V,
412    OPCODE_UNIFORM_2UI64V,
413    OPCODE_UNIFORM_3UI64V,
414    OPCODE_UNIFORM_4UI64V,
415    OPCODE_PROGRAM_UNIFORM_1I64,
416    OPCODE_PROGRAM_UNIFORM_2I64,
417    OPCODE_PROGRAM_UNIFORM_3I64,
418    OPCODE_PROGRAM_UNIFORM_4I64,
419    OPCODE_PROGRAM_UNIFORM_1I64V,
420    OPCODE_PROGRAM_UNIFORM_2I64V,
421    OPCODE_PROGRAM_UNIFORM_3I64V,
422    OPCODE_PROGRAM_UNIFORM_4I64V,
423    OPCODE_PROGRAM_UNIFORM_1UI64,
424    OPCODE_PROGRAM_UNIFORM_2UI64,
425    OPCODE_PROGRAM_UNIFORM_3UI64,
426    OPCODE_PROGRAM_UNIFORM_4UI64,
427    OPCODE_PROGRAM_UNIFORM_1UI64V,
428    OPCODE_PROGRAM_UNIFORM_2UI64V,
429    OPCODE_PROGRAM_UNIFORM_3UI64V,
430    OPCODE_PROGRAM_UNIFORM_4UI64V,
431 
432    /* OpenGL 4.0 / GL_ARB_tessellation_shader */
433    OPCODE_PATCH_PARAMETER_I,
434    OPCODE_PATCH_PARAMETER_FV_INNER,
435    OPCODE_PATCH_PARAMETER_FV_OUTER,
436 
437    /* OpenGL 4.2 / GL_ARB_separate_shader_objects */
438    OPCODE_USE_PROGRAM_STAGES,
439    OPCODE_PROGRAM_UNIFORM_1F,
440    OPCODE_PROGRAM_UNIFORM_2F,
441    OPCODE_PROGRAM_UNIFORM_3F,
442    OPCODE_PROGRAM_UNIFORM_4F,
443    OPCODE_PROGRAM_UNIFORM_1FV,
444    OPCODE_PROGRAM_UNIFORM_2FV,
445    OPCODE_PROGRAM_UNIFORM_3FV,
446    OPCODE_PROGRAM_UNIFORM_4FV,
447    OPCODE_PROGRAM_UNIFORM_1D,
448    OPCODE_PROGRAM_UNIFORM_2D,
449    OPCODE_PROGRAM_UNIFORM_3D,
450    OPCODE_PROGRAM_UNIFORM_4D,
451    OPCODE_PROGRAM_UNIFORM_1DV,
452    OPCODE_PROGRAM_UNIFORM_2DV,
453    OPCODE_PROGRAM_UNIFORM_3DV,
454    OPCODE_PROGRAM_UNIFORM_4DV,
455    OPCODE_PROGRAM_UNIFORM_1I,
456    OPCODE_PROGRAM_UNIFORM_2I,
457    OPCODE_PROGRAM_UNIFORM_3I,
458    OPCODE_PROGRAM_UNIFORM_4I,
459    OPCODE_PROGRAM_UNIFORM_1IV,
460    OPCODE_PROGRAM_UNIFORM_2IV,
461    OPCODE_PROGRAM_UNIFORM_3IV,
462    OPCODE_PROGRAM_UNIFORM_4IV,
463    OPCODE_PROGRAM_UNIFORM_1UI,
464    OPCODE_PROGRAM_UNIFORM_2UI,
465    OPCODE_PROGRAM_UNIFORM_3UI,
466    OPCODE_PROGRAM_UNIFORM_4UI,
467    OPCODE_PROGRAM_UNIFORM_1UIV,
468    OPCODE_PROGRAM_UNIFORM_2UIV,
469    OPCODE_PROGRAM_UNIFORM_3UIV,
470    OPCODE_PROGRAM_UNIFORM_4UIV,
471    OPCODE_PROGRAM_UNIFORM_MATRIX22F,
472    OPCODE_PROGRAM_UNIFORM_MATRIX33F,
473    OPCODE_PROGRAM_UNIFORM_MATRIX44F,
474    OPCODE_PROGRAM_UNIFORM_MATRIX23F,
475    OPCODE_PROGRAM_UNIFORM_MATRIX32F,
476    OPCODE_PROGRAM_UNIFORM_MATRIX24F,
477    OPCODE_PROGRAM_UNIFORM_MATRIX42F,
478    OPCODE_PROGRAM_UNIFORM_MATRIX34F,
479    OPCODE_PROGRAM_UNIFORM_MATRIX43F,
480    OPCODE_PROGRAM_UNIFORM_MATRIX22D,
481    OPCODE_PROGRAM_UNIFORM_MATRIX33D,
482    OPCODE_PROGRAM_UNIFORM_MATRIX44D,
483    OPCODE_PROGRAM_UNIFORM_MATRIX23D,
484    OPCODE_PROGRAM_UNIFORM_MATRIX32D,
485    OPCODE_PROGRAM_UNIFORM_MATRIX24D,
486    OPCODE_PROGRAM_UNIFORM_MATRIX42D,
487    OPCODE_PROGRAM_UNIFORM_MATRIX34D,
488    OPCODE_PROGRAM_UNIFORM_MATRIX43D,
489 
490    /* GL_ARB_clip_control */
491    OPCODE_CLIP_CONTROL,
492 
493    /* GL_ARB_color_buffer_float */
494    OPCODE_CLAMP_COLOR,
495 
496    /* GL_EXT_framebuffer_blit */
497    OPCODE_BLIT_FRAMEBUFFER,
498 
499    /* Vertex attributes -- fallback for when optimized display
500     * list build isn't active.
501     */
502    OPCODE_ATTR_1F_NV,
503    OPCODE_ATTR_2F_NV,
504    OPCODE_ATTR_3F_NV,
505    OPCODE_ATTR_4F_NV,
506    OPCODE_ATTR_1F_ARB,
507    OPCODE_ATTR_2F_ARB,
508    OPCODE_ATTR_3F_ARB,
509    OPCODE_ATTR_4F_ARB,
510    OPCODE_ATTR_1I,
511    OPCODE_ATTR_2I,
512    OPCODE_ATTR_3I,
513    OPCODE_ATTR_4I,
514    OPCODE_ATTR_1D,
515    OPCODE_ATTR_2D,
516    OPCODE_ATTR_3D,
517    OPCODE_ATTR_4D,
518    OPCODE_ATTR_1UI64,
519    OPCODE_MATERIAL,
520    OPCODE_BEGIN,
521    OPCODE_END,
522    OPCODE_RECTF,
523    OPCODE_EVAL_C1,
524    OPCODE_EVAL_C2,
525    OPCODE_EVAL_P1,
526    OPCODE_EVAL_P2,
527 
528    /* GL_EXT_provoking_vertex */
529    OPCODE_PROVOKING_VERTEX,
530 
531    /* GL_EXT_transform_feedback */
532    OPCODE_BEGIN_TRANSFORM_FEEDBACK,
533    OPCODE_END_TRANSFORM_FEEDBACK,
534    OPCODE_BIND_TRANSFORM_FEEDBACK,
535    OPCODE_PAUSE_TRANSFORM_FEEDBACK,
536    OPCODE_RESUME_TRANSFORM_FEEDBACK,
537    OPCODE_DRAW_TRANSFORM_FEEDBACK,
538 
539    /* GL_EXT_texture_integer */
540    OPCODE_CLEARCOLOR_I,
541    OPCODE_CLEARCOLOR_UI,
542    OPCODE_TEXPARAMETER_I,
543    OPCODE_TEXPARAMETER_UI,
544 
545    /* GL_ARB_instanced_arrays */
546    OPCODE_VERTEX_ATTRIB_DIVISOR,
547 
548    /* GL_NV_texture_barrier */
549    OPCODE_TEXTURE_BARRIER_NV,
550 
551    /* GL_ARB_sampler_object */
552    OPCODE_BIND_SAMPLER,
553    OPCODE_SAMPLER_PARAMETERIV,
554    OPCODE_SAMPLER_PARAMETERFV,
555    OPCODE_SAMPLER_PARAMETERIIV,
556    OPCODE_SAMPLER_PARAMETERUIV,
557 
558    /* ARB_compute_shader */
559    OPCODE_DISPATCH_COMPUTE,
560 
561    /* GL_ARB_sync */
562    OPCODE_WAIT_SYNC,
563 
564    /* GL_NV_conditional_render */
565    OPCODE_BEGIN_CONDITIONAL_RENDER,
566    OPCODE_END_CONDITIONAL_RENDER,
567 
568    /* ARB_timer_query */
569    OPCODE_QUERY_COUNTER,
570 
571    /* ARB_transform_feedback3 */
572    OPCODE_BEGIN_QUERY_INDEXED,
573    OPCODE_END_QUERY_INDEXED,
574    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM,
575 
576    /* ARB_transform_feedback_instanced */
577    OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED,
578    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED,
579 
580    /* ARB_uniform_buffer_object */
581    OPCODE_UNIFORM_BLOCK_BINDING,
582 
583    /* ARB_shader_subroutines */
584    OPCODE_UNIFORM_SUBROUTINES,
585 
586    /* EXT_polygon_offset_clamp */
587    OPCODE_POLYGON_OFFSET_CLAMP,
588 
589    /* EXT_window_rectangles */
590    OPCODE_WINDOW_RECTANGLES,
591 
592    /* NV_conservative_raster */
593    OPCODE_SUBPIXEL_PRECISION_BIAS,
594 
595    /* NV_conservative_raster_dilate */
596    OPCODE_CONSERVATIVE_RASTER_PARAMETER_F,
597 
598    /* NV_conservative_raster_pre_snap_triangles */
599    OPCODE_CONSERVATIVE_RASTER_PARAMETER_I,
600 
601    /* EXT_direct_state_access */
602    OPCODE_MATRIX_LOAD,
603    OPCODE_MATRIX_MULT,
604    OPCODE_MATRIX_ROTATE,
605    OPCODE_MATRIX_SCALE,
606    OPCODE_MATRIX_TRANSLATE,
607    OPCODE_MATRIX_LOAD_IDENTITY,
608    OPCODE_MATRIX_ORTHO,
609    OPCODE_MATRIX_FRUSTUM,
610    OPCODE_MATRIX_PUSH,
611    OPCODE_MATRIX_POP,
612    OPCODE_TEXTUREPARAMETER_F,
613    OPCODE_TEXTUREPARAMETER_I,
614    OPCODE_TEXTUREPARAMETER_II,
615    OPCODE_TEXTUREPARAMETER_IUI,
616    OPCODE_TEXTURE_IMAGE1D,
617    OPCODE_TEXTURE_IMAGE2D,
618    OPCODE_TEXTURE_IMAGE3D,
619    OPCODE_TEXTURE_SUB_IMAGE1D,
620    OPCODE_TEXTURE_SUB_IMAGE2D,
621    OPCODE_TEXTURE_SUB_IMAGE3D,
622    OPCODE_COPY_TEXTURE_IMAGE1D,
623    OPCODE_COPY_TEXTURE_IMAGE2D,
624    OPCODE_COPY_TEXTURE_SUB_IMAGE1D,
625    OPCODE_COPY_TEXTURE_SUB_IMAGE2D,
626    OPCODE_COPY_TEXTURE_SUB_IMAGE3D,
627    OPCODE_BIND_MULTITEXTURE,
628    OPCODE_MULTITEXPARAMETER_F,
629    OPCODE_MULTITEXPARAMETER_I,
630    OPCODE_MULTITEXPARAMETER_II,
631    OPCODE_MULTITEXPARAMETER_IUI,
632    OPCODE_MULTITEX_IMAGE1D,
633    OPCODE_MULTITEX_IMAGE2D,
634    OPCODE_MULTITEX_IMAGE3D,
635    OPCODE_MULTITEX_SUB_IMAGE1D,
636    OPCODE_MULTITEX_SUB_IMAGE2D,
637    OPCODE_MULTITEX_SUB_IMAGE3D,
638    OPCODE_COPY_MULTITEX_IMAGE1D,
639    OPCODE_COPY_MULTITEX_IMAGE2D,
640    OPCODE_COPY_MULTITEX_SUB_IMAGE1D,
641    OPCODE_COPY_MULTITEX_SUB_IMAGE2D,
642    OPCODE_COPY_MULTITEX_SUB_IMAGE3D,
643    OPCODE_MULTITEXENV,
644    OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
645    OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
646    OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
647    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
648    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
649    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
650    OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
651    OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
652    OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
653    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
654    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
655    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
656    OPCODE_NAMED_PROGRAM_STRING,
657    OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER,
658 
659    /* The following three are meta instructions */
660    OPCODE_ERROR,                /* raise compiled-in error */
661    OPCODE_CONTINUE,
662    OPCODE_NOP,                  /* No-op (used for 8-byte alignment */
663    OPCODE_END_OF_LIST,
664    OPCODE_EXT_0
665 } OpCode;
666 
667 
668 
669 /**
670  * Display list node.
671  *
672  * Display list instructions are stored as sequences of "nodes".  Nodes
673  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
674  * are linked together with a pointer.
675  *
676  * Each instruction in the display list is stored as a sequence of
677  * contiguous nodes in memory.
678  * Each node is the union of a variety of data types.
679  *
680  * Note, all of these members should be 4 bytes in size or less for the
681  * sake of compact display lists.  We store 8-byte pointers in a pair of
682  * these nodes using the save/get_pointer() functions below.
683  */
684 union gl_dlist_node
685 {
686    OpCode opcode;
687    GLboolean b;
688    GLbitfield bf;
689    GLubyte ub;
690    GLshort s;
691    GLushort us;
692    GLint i;
693    GLuint ui;
694    GLenum e;
695    GLfloat f;
696    GLsizei si;
697 };
698 
699 
700 typedef union gl_dlist_node Node;
701 
702 
703 /** How many 4-byte dwords to store a pointer */
704 #define POINTER_DWORDS (sizeof(void *) / 4)
705 
706 /* We want to keep sizeof(union gl_dlist_node) == 4 to minimize
707  * space for display lists.  The following types and functions are
708  * used to help store 4- and 8-byte pointers in 1 or 2 dlist_nodes.
709  */
710 union pointer
711 {
712    void *ptr;
713    GLuint dwords[POINTER_DWORDS];
714 };
715 
716 
717 /**
718  * Save a 4 or 8-byte pointer at dest (and dest+1).
719  */
720 static inline void
save_pointer(Node * dest,void * src)721 save_pointer(Node *dest, void *src)
722 {
723    union pointer p;
724    unsigned i;
725 
726    STATIC_ASSERT(POINTER_DWORDS == 1 || POINTER_DWORDS == 2);
727    STATIC_ASSERT(sizeof(Node) == 4);
728 
729    p.ptr = src;
730 
731    for (i = 0; i < POINTER_DWORDS; i++)
732       dest[i].ui = p.dwords[i];
733 }
734 
735 
736 /**
737  * Retrieve a 4 or 8-byte pointer from node (node+1).
738  */
739 static inline void *
get_pointer(const Node * node)740 get_pointer(const Node *node)
741 {
742    union pointer p;
743    unsigned i;
744 
745    for (i = 0; i < POINTER_DWORDS; i++)
746       p.dwords[i] = node[i].ui;
747 
748    return p.ptr;
749 }
750 
751 
752 /**
753  * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit
754  * environment.
755  */
756 union uint64_pair
757 {
758    GLuint64 uint64;
759    GLuint uint32[2];
760 };
761 
762 
763 union float64_pair
764 {
765    GLdouble d;
766    GLuint uint32[2];
767 };
768 
769 union int64_pair
770 {
771    GLint64 int64;
772    GLint int32[2];
773 };
774 
775 #define ASSIGN_DOUBLE_TO_NODES(n, idx, value)                              \
776    do {                                                                    \
777       union float64_pair tmp;                                              \
778       tmp.d = value;                                                       \
779       n[idx].ui = tmp.uint32[0];                                           \
780       n[idx+1].ui = tmp.uint32[1];                                         \
781    } while (0)
782 
783 #define ASSIGN_UINT64_TO_NODES(n, idx, value)                              \
784    do {                                                                    \
785       union uint64_pair tmp;                                               \
786       tmp.uint64 = value;                                                  \
787       n[idx].ui = tmp.uint32[0];                                           \
788       n[idx+1].ui = tmp.uint32[1];                                         \
789    } while (0)
790 
791 #define ASSIGN_INT64_TO_NODES(n, idx, value)                               \
792    do {                                                                    \
793       union int64_pair tmp;                                                \
794       tmp.int64 = value;                                                   \
795       n[idx].i = tmp.int32[0];                                             \
796       n[idx+1].i = tmp.int32[1];                                           \
797    } while (0)
798 
799 /**
800  * How many nodes to allocate at a time.  Note that bulk vertex data
801  * from glBegin/glVertex/glEnd primitives will typically wind up in
802  * a VBO, and not directly in the display list itself.
803  */
804 #define BLOCK_SIZE 256
805 
806 
807 
808 /**
809  * Number of nodes of storage needed for each instruction.
810  * Sizes for dynamically allocated opcodes are stored in the context struct.
811  */
812 static GLuint InstSize[OPCODE_END_OF_LIST + 1];
813 
814 
815 void mesa_print_display_list(GLuint list);
816 
817 
818 /**
819  * Does the given display list only contain a single glBitmap call?
820  */
821 static bool
is_bitmap_list(const struct gl_display_list * dlist)822 is_bitmap_list(const struct gl_display_list *dlist)
823 {
824    const Node *n = dlist->Head;
825    if (n[0].opcode == OPCODE_BITMAP) {
826       n += InstSize[OPCODE_BITMAP];
827       if (n[0].opcode == OPCODE_END_OF_LIST)
828          return true;
829    }
830    return false;
831 }
832 
833 
834 /**
835  * Is the given display list an empty list?
836  */
837 static bool
is_empty_list(const struct gl_display_list * dlist)838 is_empty_list(const struct gl_display_list *dlist)
839 {
840    const Node *n = dlist->Head;
841    return n[0].opcode == OPCODE_END_OF_LIST;
842 }
843 
844 
845 /**
846  * Delete/free a gl_bitmap_atlas.  Called during context tear-down.
847  */
848 void
_mesa_delete_bitmap_atlas(struct gl_context * ctx,struct gl_bitmap_atlas * atlas)849 _mesa_delete_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas)
850 {
851    if (atlas->texObj) {
852       ctx->Driver.DeleteTexture(ctx, atlas->texObj);
853    }
854    free(atlas->glyphs);
855    free(atlas);
856 }
857 
858 
859 /**
860  * Lookup a gl_bitmap_atlas by listBase ID.
861  */
862 static struct gl_bitmap_atlas *
lookup_bitmap_atlas(struct gl_context * ctx,GLuint listBase)863 lookup_bitmap_atlas(struct gl_context *ctx, GLuint listBase)
864 {
865    struct gl_bitmap_atlas *atlas;
866 
867    assert(listBase > 0);
868    atlas = _mesa_HashLookup(ctx->Shared->BitmapAtlas, listBase);
869    return atlas;
870 }
871 
872 
873 /**
874  * Create new bitmap atlas and insert into hash table.
875  */
876 static struct gl_bitmap_atlas *
alloc_bitmap_atlas(struct gl_context * ctx,GLuint listBase,bool isGenName)877 alloc_bitmap_atlas(struct gl_context *ctx, GLuint listBase, bool isGenName)
878 {
879    struct gl_bitmap_atlas *atlas;
880 
881    assert(listBase > 0);
882    assert(_mesa_HashLookup(ctx->Shared->BitmapAtlas, listBase) == NULL);
883 
884    atlas = calloc(1, sizeof(*atlas));
885    if (atlas) {
886       _mesa_HashInsert(ctx->Shared->BitmapAtlas, listBase, atlas, isGenName);
887       atlas->Id = listBase;
888    }
889 
890    return atlas;
891 }
892 
893 
894 /**
895  * Try to build a bitmap atlas.  This involves examining a sequence of
896  * display lists which contain glBitmap commands and putting the bitmap
897  * images into a texture map (the atlas).
898  * If we succeed, gl_bitmap_atlas::complete will be set to true.
899  * If we fail, gl_bitmap_atlas::incomplete will be set to true.
900  */
901 static void
build_bitmap_atlas(struct gl_context * ctx,struct gl_bitmap_atlas * atlas,GLuint listBase)902 build_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas,
903                    GLuint listBase)
904 {
905    unsigned i, row_height = 0, xpos = 0, ypos = 0;
906    GLubyte *map;
907    GLint map_stride;
908 
909    assert(atlas);
910    assert(!atlas->complete);
911    assert(atlas->numBitmaps > 0);
912 
913    /* We use a rectangle texture (non-normalized coords) for the atlas */
914    assert(ctx->Extensions.NV_texture_rectangle);
915    assert(ctx->Const.MaxTextureRectSize >= 1024);
916 
917    atlas->texWidth = 1024;
918    atlas->texHeight = 0;  /* determined below */
919 
920    atlas->glyphs = malloc(atlas->numBitmaps * sizeof(atlas->glyphs[0]));
921    if (!atlas->glyphs) {
922       /* give up */
923       atlas->incomplete = true;
924       return;
925    }
926 
927    /* Loop over the display lists.  They should all contain a single glBitmap
928     * call.  If not, bail out.  Also, compute the position and sizes of each
929     * bitmap in the atlas to determine the texture atlas size.
930     */
931    for (i = 0; i < atlas->numBitmaps; i++) {
932       const struct gl_display_list *list = _mesa_lookup_list(ctx, listBase + i);
933       const Node *n;
934       struct gl_bitmap_glyph *g = &atlas->glyphs[i];
935       unsigned bitmap_width, bitmap_height;
936       float bitmap_xmove, bitmap_ymove, bitmap_xorig, bitmap_yorig;
937 
938       if (!list || is_empty_list(list)) {
939          /* stop here */
940          atlas->numBitmaps = i;
941          break;
942       }
943 
944       if (!is_bitmap_list(list)) {
945          /* This list does not contain exactly one glBitmap command. Give up. */
946          atlas->incomplete = true;
947          return;
948       }
949 
950       /* get bitmap info from the display list command */
951       n = list->Head;
952       assert(n[0].opcode == OPCODE_BITMAP);
953       bitmap_width = n[1].i;
954       bitmap_height = n[2].i;
955       bitmap_xorig = n[3].f;
956       bitmap_yorig = n[4].f;
957       bitmap_xmove = n[5].f;
958       bitmap_ymove = n[6].f;
959 
960       if (xpos + bitmap_width > atlas->texWidth) {
961          /* advance to the next row of the texture */
962          xpos = 0;
963          ypos += row_height;
964          row_height = 0;
965       }
966 
967       /* save the bitmap's position in the atlas */
968       g->x = xpos;
969       g->y = ypos;
970       g->w = bitmap_width;
971       g->h = bitmap_height;
972       g->xorig = bitmap_xorig;
973       g->yorig = bitmap_yorig;
974       g->xmove = bitmap_xmove;
975       g->ymove = bitmap_ymove;
976 
977       xpos += bitmap_width;
978 
979       /* keep track of tallest bitmap in the row */
980       row_height = MAX2(row_height, bitmap_height);
981    }
982 
983    /* Now we know the texture height */
984    atlas->texHeight = ypos + row_height;
985 
986    if (atlas->texHeight == 0) {
987       /* no glyphs found, give up */
988       goto fail;
989    }
990    else if (atlas->texHeight > ctx->Const.MaxTextureRectSize) {
991       /* too large, give up */
992       goto fail;
993    }
994 
995    /* Create atlas texture (texture ID is irrelevant) */
996    atlas->texObj = ctx->Driver.NewTextureObject(ctx, 999, GL_TEXTURE_RECTANGLE);
997    if (!atlas->texObj) {
998       goto out_of_memory;
999    }
1000 
1001    atlas->texObj->Sampler.MinFilter = GL_NEAREST;
1002    atlas->texObj->Sampler.MagFilter = GL_NEAREST;
1003    atlas->texObj->MaxLevel = 0;
1004    atlas->texObj->Immutable = GL_TRUE;
1005 
1006    atlas->texImage = _mesa_get_tex_image(ctx, atlas->texObj,
1007                                          GL_TEXTURE_RECTANGLE, 0);
1008    if (!atlas->texImage) {
1009       goto out_of_memory;
1010    }
1011 
1012    if (ctx->Const.BitmapUsesRed)
1013       _mesa_init_teximage_fields(ctx, atlas->texImage,
1014                                  atlas->texWidth, atlas->texHeight, 1, 0,
1015                                  GL_RED, MESA_FORMAT_R_UNORM8);
1016    else
1017       _mesa_init_teximage_fields(ctx, atlas->texImage,
1018                                  atlas->texWidth, atlas->texHeight, 1, 0,
1019                                  GL_ALPHA, MESA_FORMAT_A_UNORM8);
1020 
1021    /* alloc image storage */
1022    if (!ctx->Driver.AllocTextureImageBuffer(ctx, atlas->texImage)) {
1023       goto out_of_memory;
1024    }
1025 
1026    /* map teximage, load with bitmap glyphs */
1027    ctx->Driver.MapTextureImage(ctx, atlas->texImage, 0,
1028                                0, 0, atlas->texWidth, atlas->texHeight,
1029                                GL_MAP_WRITE_BIT, &map, &map_stride);
1030    if (!map) {
1031       goto out_of_memory;
1032    }
1033 
1034    /* Background/clear pixels are 0xff, foreground/set pixels are 0x0 */
1035    memset(map, 0xff, map_stride * atlas->texHeight);
1036 
1037    for (i = 0; i < atlas->numBitmaps; i++) {
1038       const struct gl_display_list *list = _mesa_lookup_list(ctx, listBase + i);
1039       const Node *n = list->Head;
1040 
1041       assert(n[0].opcode == OPCODE_BITMAP ||
1042              n[0].opcode == OPCODE_END_OF_LIST);
1043 
1044       if (n[0].opcode == OPCODE_BITMAP) {
1045          unsigned bitmap_width = n[1].i;
1046          unsigned bitmap_height = n[2].i;
1047          unsigned xpos = atlas->glyphs[i].x;
1048          unsigned ypos = atlas->glyphs[i].y;
1049          const void *bitmap_image = get_pointer(&n[7]);
1050 
1051          assert(atlas->glyphs[i].w == bitmap_width);
1052          assert(atlas->glyphs[i].h == bitmap_height);
1053 
1054          /* put the bitmap image into the texture image */
1055          _mesa_expand_bitmap(bitmap_width, bitmap_height,
1056                              &ctx->DefaultPacking, bitmap_image,
1057                              map + map_stride * ypos + xpos, /* dest addr */
1058                              map_stride, 0x0);
1059       }
1060    }
1061 
1062    ctx->Driver.UnmapTextureImage(ctx, atlas->texImage, 0);
1063 
1064    atlas->complete = true;
1065 
1066    return;
1067 
1068 out_of_memory:
1069    _mesa_error(ctx, GL_OUT_OF_MEMORY, "Display list bitmap atlas");
1070 fail:
1071    if (atlas->texObj) {
1072       ctx->Driver.DeleteTexture(ctx, atlas->texObj);
1073    }
1074    free(atlas->glyphs);
1075    atlas->glyphs = NULL;
1076    atlas->incomplete = true;
1077 }
1078 
1079 
1080 /**
1081  * Allocate a gl_display_list object with an initial block of storage.
1082  * \param count  how many display list nodes/tokens to allocate
1083  */
1084 static struct gl_display_list *
make_list(GLuint name,GLuint count)1085 make_list(GLuint name, GLuint count)
1086 {
1087    struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
1088    dlist->Name = name;
1089    dlist->Head = malloc(sizeof(Node) * count);
1090    dlist->Head[0].opcode = OPCODE_END_OF_LIST;
1091    /* All InstSize[] entries must be non-zero */
1092    InstSize[OPCODE_END_OF_LIST] = 1;
1093    return dlist;
1094 }
1095 
1096 
1097 /**
1098  * Lookup function to just encapsulate casting.
1099  */
1100 struct gl_display_list *
_mesa_lookup_list(struct gl_context * ctx,GLuint list)1101 _mesa_lookup_list(struct gl_context *ctx, GLuint list)
1102 {
1103    return (struct gl_display_list *)
1104       _mesa_HashLookup(ctx->Shared->DisplayList, list);
1105 }
1106 
1107 
1108 /** Is the given opcode an extension code? */
1109 static inline GLboolean
is_ext_opcode(OpCode opcode)1110 is_ext_opcode(OpCode opcode)
1111 {
1112    return (opcode >= OPCODE_EXT_0);
1113 }
1114 
1115 
1116 /** Destroy an extended opcode instruction */
1117 static GLint
ext_opcode_destroy(struct gl_context * ctx,Node * node)1118 ext_opcode_destroy(struct gl_context *ctx, Node *node)
1119 {
1120    const GLint i = node[0].opcode - OPCODE_EXT_0;
1121    GLint step;
1122    ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]);
1123    step = ctx->ListExt->Opcode[i].Size;
1124    return step;
1125 }
1126 
1127 
1128 /** Execute an extended opcode instruction */
1129 static GLint
ext_opcode_execute(struct gl_context * ctx,Node * node)1130 ext_opcode_execute(struct gl_context *ctx, Node *node)
1131 {
1132    const GLint i = node[0].opcode - OPCODE_EXT_0;
1133    GLint step;
1134    ctx->ListExt->Opcode[i].Execute(ctx, &node[1]);
1135    step = ctx->ListExt->Opcode[i].Size;
1136    return step;
1137 }
1138 
1139 
1140 /** Print an extended opcode instruction */
1141 static GLint
ext_opcode_print(struct gl_context * ctx,Node * node,FILE * f)1142 ext_opcode_print(struct gl_context *ctx, Node *node, FILE *f)
1143 {
1144    const GLint i = node[0].opcode - OPCODE_EXT_0;
1145    GLint step;
1146    ctx->ListExt->Opcode[i].Print(ctx, &node[1], f);
1147    step = ctx->ListExt->Opcode[i].Size;
1148    return step;
1149 }
1150 
1151 
1152 /**
1153  * Delete the named display list, but don't remove from hash table.
1154  * \param dlist - display list pointer
1155  */
1156 void
_mesa_delete_list(struct gl_context * ctx,struct gl_display_list * dlist)1157 _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
1158 {
1159    Node *n, *block;
1160    GLboolean done;
1161 
1162    n = block = dlist->Head;
1163 
1164    done = block ? GL_FALSE : GL_TRUE;
1165    while (!done) {
1166       const OpCode opcode = n[0].opcode;
1167 
1168       /* check for extension opcodes first */
1169       if (is_ext_opcode(opcode)) {
1170          n += ext_opcode_destroy(ctx, n);
1171       }
1172       else {
1173          switch (opcode) {
1174             /* for some commands, we need to free malloc'd memory */
1175          case OPCODE_MAP1:
1176             free(get_pointer(&n[6]));
1177             break;
1178          case OPCODE_MAP2:
1179             free(get_pointer(&n[10]));
1180             break;
1181          case OPCODE_CALL_LISTS:
1182             free(get_pointer(&n[3]));
1183             break;
1184          case OPCODE_DRAW_PIXELS:
1185             free(get_pointer(&n[5]));
1186             break;
1187          case OPCODE_BITMAP:
1188             free(get_pointer(&n[7]));
1189             break;
1190          case OPCODE_POLYGON_STIPPLE:
1191             free(get_pointer(&n[1]));
1192             break;
1193          case OPCODE_TEX_IMAGE1D:
1194             free(get_pointer(&n[8]));
1195             break;
1196          case OPCODE_TEX_IMAGE2D:
1197             free(get_pointer(&n[9]));
1198             break;
1199          case OPCODE_TEX_IMAGE3D:
1200             free(get_pointer(&n[10]));
1201             break;
1202          case OPCODE_TEX_SUB_IMAGE1D:
1203             free(get_pointer(&n[7]));
1204             break;
1205          case OPCODE_TEX_SUB_IMAGE2D:
1206             free(get_pointer(&n[9]));
1207             break;
1208          case OPCODE_TEX_SUB_IMAGE3D:
1209             free(get_pointer(&n[11]));
1210             break;
1211          case OPCODE_COMPRESSED_TEX_IMAGE_1D:
1212             free(get_pointer(&n[7]));
1213             break;
1214          case OPCODE_COMPRESSED_TEX_IMAGE_2D:
1215             free(get_pointer(&n[8]));
1216             break;
1217          case OPCODE_COMPRESSED_TEX_IMAGE_3D:
1218             free(get_pointer(&n[9]));
1219             break;
1220          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
1221             free(get_pointer(&n[7]));
1222             break;
1223          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
1224             free(get_pointer(&n[9]));
1225             break;
1226          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
1227             free(get_pointer(&n[11]));
1228             break;
1229          case OPCODE_PROGRAM_STRING_ARB:
1230             free(get_pointer(&n[4]));      /* program string */
1231             break;
1232          case OPCODE_UNIFORM_1FV:
1233          case OPCODE_UNIFORM_2FV:
1234          case OPCODE_UNIFORM_3FV:
1235          case OPCODE_UNIFORM_4FV:
1236          case OPCODE_UNIFORM_1DV:
1237          case OPCODE_UNIFORM_2DV:
1238          case OPCODE_UNIFORM_3DV:
1239          case OPCODE_UNIFORM_4DV:
1240          case OPCODE_UNIFORM_1IV:
1241          case OPCODE_UNIFORM_2IV:
1242          case OPCODE_UNIFORM_3IV:
1243          case OPCODE_UNIFORM_4IV:
1244          case OPCODE_UNIFORM_1UIV:
1245          case OPCODE_UNIFORM_2UIV:
1246          case OPCODE_UNIFORM_3UIV:
1247          case OPCODE_UNIFORM_4UIV:
1248          case OPCODE_UNIFORM_1I64V:
1249          case OPCODE_UNIFORM_2I64V:
1250          case OPCODE_UNIFORM_3I64V:
1251          case OPCODE_UNIFORM_4I64V:
1252          case OPCODE_UNIFORM_1UI64V:
1253          case OPCODE_UNIFORM_2UI64V:
1254          case OPCODE_UNIFORM_3UI64V:
1255          case OPCODE_UNIFORM_4UI64V:
1256             free(get_pointer(&n[3]));
1257             break;
1258          case OPCODE_UNIFORM_MATRIX22:
1259          case OPCODE_UNIFORM_MATRIX33:
1260          case OPCODE_UNIFORM_MATRIX44:
1261          case OPCODE_UNIFORM_MATRIX24:
1262          case OPCODE_UNIFORM_MATRIX42:
1263          case OPCODE_UNIFORM_MATRIX23:
1264          case OPCODE_UNIFORM_MATRIX32:
1265          case OPCODE_UNIFORM_MATRIX34:
1266          case OPCODE_UNIFORM_MATRIX43:
1267          case OPCODE_UNIFORM_MATRIX22D:
1268          case OPCODE_UNIFORM_MATRIX33D:
1269          case OPCODE_UNIFORM_MATRIX44D:
1270          case OPCODE_UNIFORM_MATRIX24D:
1271          case OPCODE_UNIFORM_MATRIX42D:
1272          case OPCODE_UNIFORM_MATRIX23D:
1273          case OPCODE_UNIFORM_MATRIX32D:
1274          case OPCODE_UNIFORM_MATRIX34D:
1275          case OPCODE_UNIFORM_MATRIX43D:
1276             free(get_pointer(&n[4]));
1277             break;
1278          case OPCODE_PROGRAM_UNIFORM_1FV:
1279          case OPCODE_PROGRAM_UNIFORM_2FV:
1280          case OPCODE_PROGRAM_UNIFORM_3FV:
1281          case OPCODE_PROGRAM_UNIFORM_4FV:
1282          case OPCODE_PROGRAM_UNIFORM_1DV:
1283          case OPCODE_PROGRAM_UNIFORM_2DV:
1284          case OPCODE_PROGRAM_UNIFORM_3DV:
1285          case OPCODE_PROGRAM_UNIFORM_4DV:
1286          case OPCODE_PROGRAM_UNIFORM_1IV:
1287          case OPCODE_PROGRAM_UNIFORM_2IV:
1288          case OPCODE_PROGRAM_UNIFORM_3IV:
1289          case OPCODE_PROGRAM_UNIFORM_4IV:
1290          case OPCODE_PROGRAM_UNIFORM_1UIV:
1291          case OPCODE_PROGRAM_UNIFORM_2UIV:
1292          case OPCODE_PROGRAM_UNIFORM_3UIV:
1293          case OPCODE_PROGRAM_UNIFORM_4UIV:
1294          case OPCODE_PROGRAM_UNIFORM_1I64V:
1295          case OPCODE_PROGRAM_UNIFORM_2I64V:
1296          case OPCODE_PROGRAM_UNIFORM_3I64V:
1297          case OPCODE_PROGRAM_UNIFORM_4I64V:
1298          case OPCODE_PROGRAM_UNIFORM_1UI64V:
1299          case OPCODE_PROGRAM_UNIFORM_2UI64V:
1300          case OPCODE_PROGRAM_UNIFORM_3UI64V:
1301          case OPCODE_PROGRAM_UNIFORM_4UI64V:
1302             free(get_pointer(&n[4]));
1303             break;
1304          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
1305          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
1306          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
1307          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
1308          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
1309          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
1310          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
1311          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
1312          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
1313          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
1314          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
1315          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
1316          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
1317          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
1318          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
1319          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
1320          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
1321          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
1322             free(get_pointer(&n[5]));
1323             break;
1324          case OPCODE_PIXEL_MAP:
1325             free(get_pointer(&n[3]));
1326             break;
1327          case OPCODE_VIEWPORT_ARRAY_V:
1328          case OPCODE_SCISSOR_ARRAY_V:
1329          case OPCODE_DEPTH_ARRAY_V:
1330          case OPCODE_UNIFORM_SUBROUTINES:
1331          case OPCODE_WINDOW_RECTANGLES:
1332             free(get_pointer(&n[3]));
1333             break;
1334          case OPCODE_TEXTURE_IMAGE1D:
1335          case OPCODE_MULTITEX_IMAGE1D:
1336             free(get_pointer(&n[9]));
1337             break;
1338          case OPCODE_TEXTURE_IMAGE2D:
1339          case OPCODE_MULTITEX_IMAGE2D:
1340             free(get_pointer(&n[10]));
1341             break;
1342          case OPCODE_TEXTURE_IMAGE3D:
1343          case OPCODE_MULTITEX_IMAGE3D:
1344             free(get_pointer(&n[11]));
1345             break;
1346          case OPCODE_TEXTURE_SUB_IMAGE1D:
1347          case OPCODE_MULTITEX_SUB_IMAGE1D:
1348          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
1349          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
1350             free(get_pointer(&n[8]));
1351             break;
1352          case OPCODE_TEXTURE_SUB_IMAGE2D:
1353          case OPCODE_MULTITEX_SUB_IMAGE2D:
1354          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
1355          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
1356             free(get_pointer(&n[10]));
1357             break;
1358          case OPCODE_TEXTURE_SUB_IMAGE3D:
1359          case OPCODE_MULTITEX_SUB_IMAGE3D:
1360          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
1361          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
1362             free(get_pointer(&n[12]));
1363             break;
1364          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
1365          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
1366             free(get_pointer(&n[8]));
1367             break;
1368          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
1369          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
1370             free(get_pointer(&n[9]));
1371             break;
1372          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
1373          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
1374             free(get_pointer(&n[10]));
1375             break;
1376          case OPCODE_NAMED_PROGRAM_STRING:
1377             free(get_pointer(&n[5]));
1378             break;
1379          case OPCODE_CONTINUE:
1380             n = (Node *) get_pointer(&n[1]);
1381             free(block);
1382             block = n;
1383             break;
1384          case OPCODE_END_OF_LIST:
1385             free(block);
1386             done = GL_TRUE;
1387             break;
1388          default:
1389             /* just increment 'n' pointer, below */
1390             ;
1391          }
1392 
1393          if (opcode != OPCODE_CONTINUE) {
1394             assert(InstSize[opcode] > 0);
1395             n += InstSize[opcode];
1396          }
1397       }
1398    }
1399 
1400    free(dlist->Label);
1401    free(dlist);
1402 }
1403 
1404 
1405 /**
1406  * Called by _mesa_HashWalk() to check if a display list which is being
1407  * deleted belongs to a bitmap texture atlas.
1408  */
1409 static void
check_atlas_for_deleted_list(void * data,void * userData)1410 check_atlas_for_deleted_list(void *data, void *userData)
1411 {
1412    struct gl_bitmap_atlas *atlas = (struct gl_bitmap_atlas *) data;
1413    GLuint list_id = *((GLuint *) userData);  /* the list being deleted */
1414    const GLuint atlas_id = atlas->Id;
1415 
1416    /* See if the list_id falls in the range contained in this texture atlas */
1417    if (atlas->complete &&
1418        list_id >= atlas_id &&
1419        list_id < atlas_id + atlas->numBitmaps) {
1420       /* Mark the atlas as incomplete so it doesn't get used.  But don't
1421        * delete it yet since we don't want to try to recreate it in the next
1422        * glCallLists.
1423        */
1424       atlas->complete = false;
1425       atlas->incomplete = true;
1426    }
1427 }
1428 
1429 
1430 /**
1431  * Destroy a display list and remove from hash table.
1432  * \param list - display list number
1433  */
1434 static void
destroy_list(struct gl_context * ctx,GLuint list)1435 destroy_list(struct gl_context *ctx, GLuint list)
1436 {
1437    struct gl_display_list *dlist;
1438 
1439    if (list == 0)
1440       return;
1441 
1442    dlist = _mesa_lookup_list(ctx, list);
1443    if (!dlist)
1444       return;
1445 
1446    if (is_bitmap_list(dlist)) {
1447       /* If we're destroying a simple glBitmap display list, there's a
1448        * chance that we're destroying a bitmap image that's in a texture
1449        * atlas.  Examine all atlases to see if that's the case.  There's
1450        * usually few (if any) atlases so this isn't expensive.
1451        */
1452       _mesa_HashWalk(ctx->Shared->BitmapAtlas,
1453                      check_atlas_for_deleted_list, &list);
1454    }
1455 
1456    _mesa_delete_list(ctx, dlist);
1457    _mesa_HashRemove(ctx->Shared->DisplayList, list);
1458 }
1459 
1460 
1461 /*
1462  * Translate the nth element of list from <type> to GLint.
1463  */
1464 static GLint
translate_id(GLsizei n,GLenum type,const GLvoid * list)1465 translate_id(GLsizei n, GLenum type, const GLvoid * list)
1466 {
1467    GLbyte *bptr;
1468    GLubyte *ubptr;
1469    GLshort *sptr;
1470    GLushort *usptr;
1471    GLint *iptr;
1472    GLuint *uiptr;
1473    GLfloat *fptr;
1474 
1475    switch (type) {
1476    case GL_BYTE:
1477       bptr = (GLbyte *) list;
1478       return (GLint) bptr[n];
1479    case GL_UNSIGNED_BYTE:
1480       ubptr = (GLubyte *) list;
1481       return (GLint) ubptr[n];
1482    case GL_SHORT:
1483       sptr = (GLshort *) list;
1484       return (GLint) sptr[n];
1485    case GL_UNSIGNED_SHORT:
1486       usptr = (GLushort *) list;
1487       return (GLint) usptr[n];
1488    case GL_INT:
1489       iptr = (GLint *) list;
1490       return iptr[n];
1491    case GL_UNSIGNED_INT:
1492       uiptr = (GLuint *) list;
1493       return (GLint) uiptr[n];
1494    case GL_FLOAT:
1495       fptr = (GLfloat *) list;
1496       return (GLint) floorf(fptr[n]);
1497    case GL_2_BYTES:
1498       ubptr = ((GLubyte *) list) + 2 * n;
1499       return (GLint) ubptr[0] * 256
1500            + (GLint) ubptr[1];
1501    case GL_3_BYTES:
1502       ubptr = ((GLubyte *) list) + 3 * n;
1503       return (GLint) ubptr[0] * 65536
1504            + (GLint) ubptr[1] * 256
1505            + (GLint) ubptr[2];
1506    case GL_4_BYTES:
1507       ubptr = ((GLubyte *) list) + 4 * n;
1508       return (GLint) ubptr[0] * 16777216
1509            + (GLint) ubptr[1] * 65536
1510            + (GLint) ubptr[2] * 256
1511            + (GLint) ubptr[3];
1512    default:
1513       return 0;
1514    }
1515 }
1516 
1517 
1518 /**
1519  * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects.
1520  * If width < 0 or height < 0 or format or type are invalid we'll just
1521  * return NULL.  We will not generate an error since OpenGL command
1522  * arguments aren't error-checked until the command is actually executed
1523  * (not when they're compiled).
1524  * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded.
1525  */
1526 static GLvoid *
unpack_image(struct gl_context * ctx,GLuint dimensions,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * pixels,const struct gl_pixelstore_attrib * unpack)1527 unpack_image(struct gl_context *ctx, GLuint dimensions,
1528              GLsizei width, GLsizei height, GLsizei depth,
1529              GLenum format, GLenum type, const GLvoid * pixels,
1530              const struct gl_pixelstore_attrib *unpack)
1531 {
1532    if (width <= 0 || height <= 0) {
1533       return NULL;
1534    }
1535 
1536    if (_mesa_bytes_per_pixel(format, type) < 0) {
1537       /* bad format and/or type */
1538       return NULL;
1539    }
1540 
1541    if (!unpack->BufferObj) {
1542       /* no PBO */
1543       GLvoid *image;
1544 
1545       image = _mesa_unpack_image(dimensions, width, height, depth,
1546                                  format, type, pixels, unpack);
1547       if (pixels && !image) {
1548          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1549       }
1550       return image;
1551    }
1552    else if (_mesa_validate_pbo_access(dimensions, unpack, width, height,
1553                                       depth, format, type, INT_MAX, pixels)) {
1554       const GLubyte *map, *src;
1555       GLvoid *image;
1556 
1557       map = (GLubyte *)
1558          ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
1559                                     GL_MAP_READ_BIT, unpack->BufferObj,
1560                                     MAP_INTERNAL);
1561       if (!map) {
1562          /* unable to map src buffer! */
1563          _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
1564          return NULL;
1565       }
1566 
1567       src = ADD_POINTERS(map, pixels);
1568       image = _mesa_unpack_image(dimensions, width, height, depth,
1569                                  format, type, src, unpack);
1570 
1571       ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
1572 
1573       if (!image) {
1574          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1575       }
1576       return image;
1577    }
1578 
1579    /* bad access! */
1580    _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access");
1581    return NULL;
1582 }
1583 
1584 
1585 /** Return copy of memory */
1586 static void *
memdup(const void * src,GLsizei bytes)1587 memdup(const void *src, GLsizei bytes)
1588 {
1589    void *b = bytes >= 0 ? malloc(bytes) : NULL;
1590    if (b)
1591       memcpy(b, src, bytes);
1592    return b;
1593 }
1594 
1595 
1596 /**
1597  * Allocate space for a display list instruction (opcode + payload space).
1598  * \param opcode  the instruction opcode (OPCODE_* value)
1599  * \param bytes   instruction payload size (not counting opcode)
1600  * \param align8  does the payload need to be 8-byte aligned?
1601  *                This is only relevant in 64-bit environments.
1602  * \return pointer to allocated memory (the payload will be at pointer+1)
1603  */
1604 static Node *
dlist_alloc(struct gl_context * ctx,OpCode opcode,GLuint bytes,bool align8)1605 dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8)
1606 {
1607    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
1608    const GLuint contNodes = 1 + POINTER_DWORDS;  /* size of continue info */
1609    GLuint nopNode;
1610    Node *n;
1611 
1612    assert(bytes <= BLOCK_SIZE * sizeof(Node));
1613 
1614    if (opcode < OPCODE_EXT_0) {
1615       if (InstSize[opcode] == 0) {
1616          /* save instruction size now */
1617          InstSize[opcode] = numNodes;
1618       }
1619       else {
1620          /* make sure instruction size agrees */
1621          assert(numNodes == InstSize[opcode]);
1622       }
1623    }
1624 
1625    if (sizeof(void *) > sizeof(Node) && align8
1626        && ctx->ListState.CurrentPos % 2 == 0) {
1627       /* The opcode would get placed at node[0] and the payload would start
1628        * at node[1].  But the payload needs to be at an even offset (8-byte
1629        * multiple).
1630        */
1631       nopNode = 1;
1632    }
1633    else {
1634       nopNode = 0;
1635    }
1636 
1637    if (ctx->ListState.CurrentPos + nopNode + numNodes + contNodes
1638        > BLOCK_SIZE) {
1639       /* This block is full.  Allocate a new block and chain to it */
1640       Node *newblock;
1641       n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1642       n[0].opcode = OPCODE_CONTINUE;
1643       newblock = malloc(sizeof(Node) * BLOCK_SIZE);
1644       if (!newblock) {
1645          _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
1646          return NULL;
1647       }
1648 
1649       /* a fresh block should be 8-byte aligned on 64-bit systems */
1650       assert(((GLintptr) newblock) % sizeof(void *) == 0);
1651 
1652       save_pointer(&n[1], newblock);
1653       ctx->ListState.CurrentBlock = newblock;
1654       ctx->ListState.CurrentPos = 0;
1655 
1656       /* Display list nodes are always 4 bytes.  If we need 8-byte alignment
1657        * we have to insert a NOP so that the payload of the real opcode lands
1658        * on an even location:
1659        *   node[0] = OPCODE_NOP
1660        *   node[1] = OPCODE_x;
1661        *   node[2] = start of payload
1662        */
1663       nopNode = sizeof(void *) > sizeof(Node) && align8;
1664    }
1665 
1666    n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1667    if (nopNode) {
1668       assert(ctx->ListState.CurrentPos % 2 == 0); /* even value */
1669       n[0].opcode = OPCODE_NOP;
1670       n++;
1671       /* The "real" opcode will now be at an odd location and the payload
1672        * will be at an even location.
1673        */
1674    }
1675    ctx->ListState.CurrentPos += nopNode + numNodes;
1676 
1677    n[0].opcode = opcode;
1678 
1679    return n;
1680 }
1681 
1682 
1683 
1684 /**
1685  * Allocate space for a display list instruction.  Used by callers outside
1686  * this file for things like VBO vertex data.
1687  *
1688  * \param opcode  the instruction opcode (OPCODE_* value)
1689  * \param bytes   instruction size in bytes, not counting opcode.
1690  * \return pointer to the usable data area (not including the internal
1691  *         opcode).
1692  */
1693 void *
_mesa_dlist_alloc(struct gl_context * ctx,GLuint opcode,GLuint bytes)1694 _mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes)
1695 {
1696    Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes, false);
1697    if (n)
1698       return n + 1;  /* return pointer to payload area, after opcode */
1699    else
1700       return NULL;
1701 }
1702 
1703 
1704 /**
1705  * Same as _mesa_dlist_alloc(), but return a pointer which is 8-byte
1706  * aligned in 64-bit environments, 4-byte aligned otherwise.
1707  */
1708 void *
_mesa_dlist_alloc_aligned(struct gl_context * ctx,GLuint opcode,GLuint bytes)1709 _mesa_dlist_alloc_aligned(struct gl_context *ctx, GLuint opcode, GLuint bytes)
1710 {
1711    Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes, true);
1712    if (n)
1713       return n + 1;  /* return pointer to payload area, after opcode */
1714    else
1715       return NULL;
1716 }
1717 
1718 
1719 /**
1720  * This function allows modules and drivers to get their own opcodes
1721  * for extending display list functionality.
1722  * \param ctx  the rendering context
1723  * \param size  number of bytes for storing the new display list command
1724  * \param execute  function to execute the new display list command
1725  * \param destroy  function to destroy the new display list command
1726  * \param print  function to print the new display list command
1727  * \return  the new opcode number or -1 if error
1728  */
1729 GLint
_mesa_dlist_alloc_opcode(struct gl_context * ctx,GLuint size,void (* execute)(struct gl_context *,void *),void (* destroy)(struct gl_context *,void *),void (* print)(struct gl_context *,void *,FILE *))1730 _mesa_dlist_alloc_opcode(struct gl_context *ctx,
1731                          GLuint size,
1732                          void (*execute) (struct gl_context *, void *),
1733                          void (*destroy) (struct gl_context *, void *),
1734                          void (*print) (struct gl_context *, void *, FILE *))
1735 {
1736    if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) {
1737       const GLuint i = ctx->ListExt->NumOpcodes++;
1738       ctx->ListExt->Opcode[i].Size =
1739          1 + (size + sizeof(Node) - 1) / sizeof(Node);
1740       ctx->ListExt->Opcode[i].Execute = execute;
1741       ctx->ListExt->Opcode[i].Destroy = destroy;
1742       ctx->ListExt->Opcode[i].Print = print;
1743       return i + OPCODE_EXT_0;
1744    }
1745    return -1;
1746 }
1747 
1748 
1749 /**
1750  * Allocate space for a display list instruction.  The space is basically
1751  * an array of Nodes where node[0] holds the opcode, node[1] is the first
1752  * function parameter, node[2] is the second parameter, etc.
1753  *
1754  * \param opcode  one of OPCODE_x
1755  * \param nparams  number of function parameters
1756  * \return  pointer to start of instruction space
1757  */
1758 static inline Node *
alloc_instruction(struct gl_context * ctx,OpCode opcode,GLuint nparams)1759 alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams)
1760 {
1761    return dlist_alloc(ctx, opcode, nparams * sizeof(Node), false);
1762 }
1763 
1764 
1765 /**
1766  * Called by EndList to try to reduce memory used for the list.
1767  */
1768 static void
trim_list(struct gl_context * ctx)1769 trim_list(struct gl_context *ctx)
1770 {
1771    /* If the list we're ending only has one allocated block of nodes/tokens
1772     * and its size isn't a full block size, realloc the block to use less
1773     * memory.  This is important for apps that create many small display
1774     * lists and apps that use glXUseXFont (many lists each containing one
1775     * glBitmap call).
1776     * Note: we currently only trim display lists that allocated one block
1777     * of tokens.  That hits the short list case which is what we're mainly
1778     * concerned with.  Trimming longer lists would involve traversing the
1779     * linked list of blocks.
1780     */
1781    struct gl_dlist_state *list = &ctx->ListState;
1782 
1783    if ((list->CurrentList->Head == list->CurrentBlock) &&
1784        (list->CurrentPos < BLOCK_SIZE)) {
1785       /* There's only one block and it's not full, so realloc */
1786       GLuint newSize = list->CurrentPos * sizeof(Node);
1787       list->CurrentList->Head =
1788       list->CurrentBlock = realloc(list->CurrentBlock, newSize);
1789       if (!list->CurrentBlock) {
1790          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEndList");
1791       }
1792    }
1793 }
1794 
1795 
1796 
1797 /*
1798  * Display List compilation functions
1799  */
1800 static void GLAPIENTRY
save_Accum(GLenum op,GLfloat value)1801 save_Accum(GLenum op, GLfloat value)
1802 {
1803    GET_CURRENT_CONTEXT(ctx);
1804    Node *n;
1805    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1806    n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
1807    if (n) {
1808       n[1].e = op;
1809       n[2].f = value;
1810    }
1811    if (ctx->ExecuteFlag) {
1812       CALL_Accum(ctx->Exec, (op, value));
1813    }
1814 }
1815 
1816 
1817 static void GLAPIENTRY
save_AlphaFunc(GLenum func,GLclampf ref)1818 save_AlphaFunc(GLenum func, GLclampf ref)
1819 {
1820    GET_CURRENT_CONTEXT(ctx);
1821    Node *n;
1822    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1823    n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
1824    if (n) {
1825       n[1].e = func;
1826       n[2].f = (GLfloat) ref;
1827    }
1828    if (ctx->ExecuteFlag) {
1829       CALL_AlphaFunc(ctx->Exec, (func, ref));
1830    }
1831 }
1832 
1833 
1834 static void GLAPIENTRY
save_BindTexture(GLenum target,GLuint texture)1835 save_BindTexture(GLenum target, GLuint texture)
1836 {
1837    GET_CURRENT_CONTEXT(ctx);
1838    Node *n;
1839    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1840    n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
1841    if (n) {
1842       n[1].e = target;
1843       n[2].ui = texture;
1844    }
1845    if (ctx->ExecuteFlag) {
1846       CALL_BindTexture(ctx->Exec, (target, texture));
1847    }
1848 }
1849 
1850 
1851 static void GLAPIENTRY
save_Bitmap(GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const GLubyte * pixels)1852 save_Bitmap(GLsizei width, GLsizei height,
1853             GLfloat xorig, GLfloat yorig,
1854             GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
1855 {
1856    GET_CURRENT_CONTEXT(ctx);
1857    Node *n;
1858    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1859    n = alloc_instruction(ctx, OPCODE_BITMAP, 6 + POINTER_DWORDS);
1860    if (n) {
1861       n[1].i = (GLint) width;
1862       n[2].i = (GLint) height;
1863       n[3].f = xorig;
1864       n[4].f = yorig;
1865       n[5].f = xmove;
1866       n[6].f = ymove;
1867       save_pointer(&n[7],
1868                    unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX,
1869                                 GL_BITMAP, pixels, &ctx->Unpack));
1870    }
1871    if (ctx->ExecuteFlag) {
1872       CALL_Bitmap(ctx->Exec, (width, height,
1873                               xorig, yorig, xmove, ymove, pixels));
1874    }
1875 }
1876 
1877 
1878 static void GLAPIENTRY
save_BlendEquation(GLenum mode)1879 save_BlendEquation(GLenum mode)
1880 {
1881    GET_CURRENT_CONTEXT(ctx);
1882    Node *n;
1883    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1884    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
1885    if (n) {
1886       n[1].e = mode;
1887    }
1888    if (ctx->ExecuteFlag) {
1889       CALL_BlendEquation(ctx->Exec, (mode));
1890    }
1891 }
1892 
1893 
1894 static void GLAPIENTRY
save_BlendEquationSeparateEXT(GLenum modeRGB,GLenum modeA)1895 save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
1896 {
1897    GET_CURRENT_CONTEXT(ctx);
1898    Node *n;
1899    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1900    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
1901    if (n) {
1902       n[1].e = modeRGB;
1903       n[2].e = modeA;
1904    }
1905    if (ctx->ExecuteFlag) {
1906       CALL_BlendEquationSeparate(ctx->Exec, (modeRGB, modeA));
1907    }
1908 }
1909 
1910 
1911 static void GLAPIENTRY
save_BlendFuncSeparateEXT(GLenum sfactorRGB,GLenum dfactorRGB,GLenum sfactorA,GLenum dfactorA)1912 save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
1913                           GLenum sfactorA, GLenum dfactorA)
1914 {
1915    GET_CURRENT_CONTEXT(ctx);
1916    Node *n;
1917    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1918    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
1919    if (n) {
1920       n[1].e = sfactorRGB;
1921       n[2].e = dfactorRGB;
1922       n[3].e = sfactorA;
1923       n[4].e = dfactorA;
1924    }
1925    if (ctx->ExecuteFlag) {
1926       CALL_BlendFuncSeparate(ctx->Exec,
1927                                 (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
1928    }
1929 }
1930 
1931 
1932 static void GLAPIENTRY
save_BlendFunc(GLenum srcfactor,GLenum dstfactor)1933 save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
1934 {
1935    save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
1936 }
1937 
1938 
1939 static void GLAPIENTRY
save_BlendColor(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)1940 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1941 {
1942    GET_CURRENT_CONTEXT(ctx);
1943    Node *n;
1944    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1945    n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
1946    if (n) {
1947       n[1].f = red;
1948       n[2].f = green;
1949       n[3].f = blue;
1950       n[4].f = alpha;
1951    }
1952    if (ctx->ExecuteFlag) {
1953       CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
1954    }
1955 }
1956 
1957 /* GL_ARB_draw_buffers_blend */
1958 static void GLAPIENTRY
save_BlendFuncSeparatei(GLuint buf,GLenum sfactorRGB,GLenum dfactorRGB,GLenum sfactorA,GLenum dfactorA)1959 save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
1960                         GLenum sfactorA, GLenum dfactorA)
1961 {
1962    GET_CURRENT_CONTEXT(ctx);
1963    Node *n;
1964    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1965    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
1966    if (n) {
1967       n[1].ui = buf;
1968       n[2].e = sfactorRGB;
1969       n[3].e = dfactorRGB;
1970       n[4].e = sfactorA;
1971       n[5].e = dfactorA;
1972    }
1973    if (ctx->ExecuteFlag) {
1974       CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
1975                                              sfactorA, dfactorA));
1976    }
1977 }
1978 
1979 /* GL_ARB_draw_buffers_blend */
1980 static void GLAPIENTRY
save_BlendFunci(GLuint buf,GLenum sfactor,GLenum dfactor)1981 save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
1982 {
1983    GET_CURRENT_CONTEXT(ctx);
1984    Node *n;
1985    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1986    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_I, 3);
1987    if (n) {
1988       n[1].ui = buf;
1989       n[2].e = sfactor;
1990       n[3].e = dfactor;
1991    }
1992    if (ctx->ExecuteFlag) {
1993       CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
1994    }
1995 }
1996 
1997 /* GL_ARB_draw_buffers_blend */
1998 static void GLAPIENTRY
save_BlendEquationi(GLuint buf,GLenum mode)1999 save_BlendEquationi(GLuint buf, GLenum mode)
2000 {
2001    GET_CURRENT_CONTEXT(ctx);
2002    Node *n;
2003    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2004    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
2005    if (n) {
2006       n[1].ui = buf;
2007       n[2].e = mode;
2008    }
2009    if (ctx->ExecuteFlag) {
2010       CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
2011    }
2012 }
2013 
2014 /* GL_ARB_draw_buffers_blend */
2015 static void GLAPIENTRY
save_BlendEquationSeparatei(GLuint buf,GLenum modeRGB,GLenum modeA)2016 save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
2017 {
2018    GET_CURRENT_CONTEXT(ctx);
2019    Node *n;
2020    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2021    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
2022    if (n) {
2023       n[1].ui = buf;
2024       n[2].e = modeRGB;
2025       n[3].e = modeA;
2026    }
2027    if (ctx->ExecuteFlag) {
2028       CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
2029    }
2030 }
2031 
2032 
2033 /* GL_ARB_draw_instanced. */
2034 static void GLAPIENTRY
save_DrawArraysInstancedARB(UNUSED GLenum mode,UNUSED GLint first,UNUSED GLsizei count,UNUSED GLsizei primcount)2035 save_DrawArraysInstancedARB(UNUSED GLenum mode,
2036                             UNUSED GLint first,
2037                             UNUSED GLsizei count,
2038                             UNUSED GLsizei primcount)
2039 {
2040    GET_CURRENT_CONTEXT(ctx);
2041    _mesa_error(ctx, GL_INVALID_OPERATION,
2042                "glDrawArraysInstanced() during display list compile");
2043 }
2044 
2045 static void GLAPIENTRY
save_DrawElementsInstancedARB(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const GLvoid * indices,UNUSED GLsizei primcount)2046 save_DrawElementsInstancedARB(UNUSED GLenum mode,
2047                               UNUSED GLsizei count,
2048                               UNUSED GLenum type,
2049                               UNUSED const GLvoid *indices,
2050                               UNUSED GLsizei primcount)
2051 {
2052    GET_CURRENT_CONTEXT(ctx);
2053    _mesa_error(ctx, GL_INVALID_OPERATION,
2054                "glDrawElementsInstanced() during display list compile");
2055 }
2056 
2057 static void GLAPIENTRY
save_DrawElementsInstancedBaseVertexARB(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const GLvoid * indices,UNUSED GLsizei primcount,UNUSED GLint basevertex)2058 save_DrawElementsInstancedBaseVertexARB(UNUSED GLenum mode,
2059                                         UNUSED GLsizei count,
2060                                         UNUSED GLenum type,
2061                                         UNUSED const GLvoid *indices,
2062                                         UNUSED GLsizei primcount,
2063                                         UNUSED GLint basevertex)
2064 {
2065    GET_CURRENT_CONTEXT(ctx);
2066    _mesa_error(ctx, GL_INVALID_OPERATION,
2067                "glDrawElementsInstancedBaseVertex() during display list compile");
2068 }
2069 
2070 /* GL_ARB_base_instance. */
2071 static void GLAPIENTRY
save_DrawArraysInstancedBaseInstance(UNUSED GLenum mode,UNUSED GLint first,UNUSED GLsizei count,UNUSED GLsizei primcount,UNUSED GLuint baseinstance)2072 save_DrawArraysInstancedBaseInstance(UNUSED GLenum mode,
2073                                      UNUSED GLint first,
2074                                      UNUSED GLsizei count,
2075                                      UNUSED GLsizei primcount,
2076                                      UNUSED GLuint baseinstance)
2077 {
2078    GET_CURRENT_CONTEXT(ctx);
2079    _mesa_error(ctx, GL_INVALID_OPERATION,
2080                "glDrawArraysInstancedBaseInstance() during display list compile");
2081 }
2082 
2083 static void APIENTRY
save_DrawElementsInstancedBaseInstance(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const void * indices,UNUSED GLsizei primcount,UNUSED GLuint baseinstance)2084 save_DrawElementsInstancedBaseInstance(UNUSED GLenum mode,
2085                                        UNUSED GLsizei count,
2086                                        UNUSED GLenum type,
2087                                        UNUSED const void *indices,
2088                                        UNUSED GLsizei primcount,
2089                                        UNUSED GLuint baseinstance)
2090 {
2091    GET_CURRENT_CONTEXT(ctx);
2092    _mesa_error(ctx, GL_INVALID_OPERATION,
2093                "glDrawElementsInstancedBaseInstance() during display list compile");
2094 }
2095 
2096 static void APIENTRY
save_DrawElementsInstancedBaseVertexBaseInstance(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const void * indices,UNUSED GLsizei primcount,UNUSED GLint basevertex,UNUSED GLuint baseinstance)2097 save_DrawElementsInstancedBaseVertexBaseInstance(UNUSED GLenum mode,
2098                                                  UNUSED GLsizei count,
2099                                                  UNUSED GLenum type,
2100                                                  UNUSED const void *indices,
2101                                                  UNUSED GLsizei primcount,
2102                                                  UNUSED GLint basevertex,
2103                                                  UNUSED GLuint baseinstance)
2104 {
2105    GET_CURRENT_CONTEXT(ctx);
2106    _mesa_error(ctx, GL_INVALID_OPERATION,
2107                "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile");
2108 }
2109 
2110 static void APIENTRY
save_DrawArraysIndirect(UNUSED GLenum mode,UNUSED const void * indirect)2111 save_DrawArraysIndirect(UNUSED GLenum mode,
2112                         UNUSED const void *indirect)
2113 {
2114    GET_CURRENT_CONTEXT(ctx);
2115    _mesa_error(ctx, GL_INVALID_OPERATION,
2116                "glDrawArraysIndirect() during display list compile");
2117 }
2118 
2119 static void APIENTRY
save_DrawElementsIndirect(UNUSED GLenum mode,UNUSED GLenum type,UNUSED const void * indirect)2120 save_DrawElementsIndirect(UNUSED GLenum mode,
2121                           UNUSED GLenum type,
2122                           UNUSED const void *indirect)
2123 {
2124    GET_CURRENT_CONTEXT(ctx);
2125    _mesa_error(ctx, GL_INVALID_OPERATION,
2126                "glDrawElementsIndirect() during display list compile");
2127 }
2128 
2129 static void APIENTRY
save_MultiDrawArraysIndirect(UNUSED GLenum mode,UNUSED const void * indirect,UNUSED GLsizei primcount,UNUSED GLsizei stride)2130 save_MultiDrawArraysIndirect(UNUSED GLenum mode,
2131                              UNUSED const void *indirect,
2132                              UNUSED GLsizei primcount,
2133                              UNUSED GLsizei stride)
2134 {
2135    GET_CURRENT_CONTEXT(ctx);
2136    _mesa_error(ctx, GL_INVALID_OPERATION,
2137                "glMultiDrawArraysIndirect() during display list compile");
2138 }
2139 
2140 static void APIENTRY
save_MultiDrawElementsIndirect(UNUSED GLenum mode,UNUSED GLenum type,UNUSED const void * indirect,UNUSED GLsizei primcount,UNUSED GLsizei stride)2141 save_MultiDrawElementsIndirect(UNUSED GLenum mode,
2142                                UNUSED GLenum type,
2143                                UNUSED const void *indirect,
2144                                UNUSED GLsizei primcount,
2145                                UNUSED GLsizei stride)
2146 {
2147    GET_CURRENT_CONTEXT(ctx);
2148    _mesa_error(ctx, GL_INVALID_OPERATION,
2149                "glMultiDrawElementsIndirect() during display list compile");
2150 }
2151 
2152 /**
2153  * While building a display list we cache some OpenGL state.
2154  * Under some circumstances we need to invalidate that state (immediately
2155  * when we start compiling a list, or after glCallList(s)).
2156  */
2157 static void
invalidate_saved_current_state(struct gl_context * ctx)2158 invalidate_saved_current_state(struct gl_context *ctx)
2159 {
2160    GLint i;
2161 
2162    for (i = 0; i < VERT_ATTRIB_MAX; i++)
2163       ctx->ListState.ActiveAttribSize[i] = 0;
2164 
2165    for (i = 0; i < MAT_ATTRIB_MAX; i++)
2166       ctx->ListState.ActiveMaterialSize[i] = 0;
2167 
2168    memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
2169 
2170    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
2171 }
2172 
2173 
2174 static void GLAPIENTRY
save_CallList(GLuint list)2175 save_CallList(GLuint list)
2176 {
2177    GET_CURRENT_CONTEXT(ctx);
2178    Node *n;
2179    SAVE_FLUSH_VERTICES(ctx);
2180 
2181    n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
2182    if (n) {
2183       n[1].ui = list;
2184    }
2185 
2186    /* After this, we don't know what state we're in.  Invalidate all
2187     * cached information previously gathered:
2188     */
2189    invalidate_saved_current_state( ctx );
2190 
2191    if (ctx->ExecuteFlag) {
2192       _mesa_CallList(list);
2193    }
2194 }
2195 
2196 
2197 static void GLAPIENTRY
save_CallLists(GLsizei num,GLenum type,const GLvoid * lists)2198 save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
2199 {
2200    GET_CURRENT_CONTEXT(ctx);
2201    unsigned type_size;
2202    Node *n;
2203    void *lists_copy;
2204 
2205    SAVE_FLUSH_VERTICES(ctx);
2206 
2207    switch (type) {
2208    case GL_BYTE:
2209    case GL_UNSIGNED_BYTE:
2210       type_size = 1;
2211       break;
2212    case GL_SHORT:
2213    case GL_UNSIGNED_SHORT:
2214    case GL_2_BYTES:
2215       type_size = 2;
2216       break;
2217    case GL_3_BYTES:
2218       type_size = 3;
2219       break;
2220    case GL_INT:
2221    case GL_UNSIGNED_INT:
2222    case GL_FLOAT:
2223    case GL_4_BYTES:
2224       type_size = 4;
2225       break;
2226    default:
2227       type_size = 0;
2228    }
2229 
2230    if (num > 0 && type_size > 0) {
2231       /* create a copy of the array of list IDs to save in the display list */
2232       lists_copy = memdup(lists, num * type_size);
2233    } else {
2234       lists_copy = NULL;
2235    }
2236 
2237    n = alloc_instruction(ctx, OPCODE_CALL_LISTS, 2 + POINTER_DWORDS);
2238    if (n) {
2239       n[1].i = num;
2240       n[2].e = type;
2241       save_pointer(&n[3], lists_copy);
2242    }
2243 
2244    /* After this, we don't know what state we're in.  Invalidate all
2245     * cached information previously gathered:
2246     */
2247    invalidate_saved_current_state( ctx );
2248 
2249    if (ctx->ExecuteFlag) {
2250       CALL_CallLists(ctx->Exec, (num, type, lists));
2251    }
2252 }
2253 
2254 
2255 static void GLAPIENTRY
save_Clear(GLbitfield mask)2256 save_Clear(GLbitfield mask)
2257 {
2258    GET_CURRENT_CONTEXT(ctx);
2259    Node *n;
2260    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2261    n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
2262    if (n) {
2263       n[1].bf = mask;
2264    }
2265    if (ctx->ExecuteFlag) {
2266       CALL_Clear(ctx->Exec, (mask));
2267    }
2268 }
2269 
2270 
2271 static void GLAPIENTRY
save_ClearBufferiv(GLenum buffer,GLint drawbuffer,const GLint * value)2272 save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
2273 {
2274    GET_CURRENT_CONTEXT(ctx);
2275    Node *n;
2276    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2277    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
2278    if (n) {
2279       n[1].e = buffer;
2280       n[2].i = drawbuffer;
2281       n[3].i = value[0];
2282       if (buffer == GL_COLOR) {
2283          n[4].i = value[1];
2284          n[5].i = value[2];
2285          n[6].i = value[3];
2286       }
2287       else {
2288          n[4].i = 0;
2289          n[5].i = 0;
2290          n[6].i = 0;
2291       }
2292    }
2293    if (ctx->ExecuteFlag) {
2294       CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));
2295    }
2296 }
2297 
2298 
2299 static void GLAPIENTRY
save_ClearBufferuiv(GLenum buffer,GLint drawbuffer,const GLuint * value)2300 save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
2301 {
2302    GET_CURRENT_CONTEXT(ctx);
2303    Node *n;
2304    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2305    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
2306    if (n) {
2307       n[1].e = buffer;
2308       n[2].i = drawbuffer;
2309       n[3].ui = value[0];
2310       if (buffer == GL_COLOR) {
2311          n[4].ui = value[1];
2312          n[5].ui = value[2];
2313          n[6].ui = value[3];
2314       }
2315       else {
2316          n[4].ui = 0;
2317          n[5].ui = 0;
2318          n[6].ui = 0;
2319       }
2320    }
2321    if (ctx->ExecuteFlag) {
2322       CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));
2323    }
2324 }
2325 
2326 
2327 static void GLAPIENTRY
save_ClearBufferfv(GLenum buffer,GLint drawbuffer,const GLfloat * value)2328 save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
2329 {
2330    GET_CURRENT_CONTEXT(ctx);
2331    Node *n;
2332    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2333    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
2334    if (n) {
2335       n[1].e = buffer;
2336       n[2].i = drawbuffer;
2337       n[3].f = value[0];
2338       if (buffer == GL_COLOR) {
2339          n[4].f = value[1];
2340          n[5].f = value[2];
2341          n[6].f = value[3];
2342       }
2343       else {
2344          n[4].f = 0.0F;
2345          n[5].f = 0.0F;
2346          n[6].f = 0.0F;
2347       }
2348    }
2349    if (ctx->ExecuteFlag) {
2350       CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value));
2351    }
2352 }
2353 
2354 
2355 static void GLAPIENTRY
save_ClearBufferfi(GLenum buffer,GLint drawbuffer,GLfloat depth,GLint stencil)2356 save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
2357                    GLfloat depth, GLint stencil)
2358 {
2359    GET_CURRENT_CONTEXT(ctx);
2360    Node *n;
2361    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2362    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
2363    if (n) {
2364       n[1].e = buffer;
2365       n[2].i = drawbuffer;
2366       n[3].f = depth;
2367       n[4].i = stencil;
2368    }
2369    if (ctx->ExecuteFlag) {
2370       CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));
2371    }
2372 }
2373 
2374 
2375 static void GLAPIENTRY
save_ClearAccum(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)2376 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
2377 {
2378    GET_CURRENT_CONTEXT(ctx);
2379    Node *n;
2380    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2381    n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
2382    if (n) {
2383       n[1].f = red;
2384       n[2].f = green;
2385       n[3].f = blue;
2386       n[4].f = alpha;
2387    }
2388    if (ctx->ExecuteFlag) {
2389       CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
2390    }
2391 }
2392 
2393 
2394 static void GLAPIENTRY
save_ClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)2395 save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2396 {
2397    GET_CURRENT_CONTEXT(ctx);
2398    Node *n;
2399    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2400    n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
2401    if (n) {
2402       n[1].f = red;
2403       n[2].f = green;
2404       n[3].f = blue;
2405       n[4].f = alpha;
2406    }
2407    if (ctx->ExecuteFlag) {
2408       CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
2409    }
2410 }
2411 
2412 
2413 static void GLAPIENTRY
save_ClearDepth(GLclampd depth)2414 save_ClearDepth(GLclampd depth)
2415 {
2416    GET_CURRENT_CONTEXT(ctx);
2417    Node *n;
2418    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2419    n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
2420    if (n) {
2421       n[1].f = (GLfloat) depth;
2422    }
2423    if (ctx->ExecuteFlag) {
2424       CALL_ClearDepth(ctx->Exec, (depth));
2425    }
2426 }
2427 
2428 
2429 static void GLAPIENTRY
save_ClearIndex(GLfloat c)2430 save_ClearIndex(GLfloat c)
2431 {
2432    GET_CURRENT_CONTEXT(ctx);
2433    Node *n;
2434    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2435    n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
2436    if (n) {
2437       n[1].f = c;
2438    }
2439    if (ctx->ExecuteFlag) {
2440       CALL_ClearIndex(ctx->Exec, (c));
2441    }
2442 }
2443 
2444 
2445 static void GLAPIENTRY
save_ClearStencil(GLint s)2446 save_ClearStencil(GLint s)
2447 {
2448    GET_CURRENT_CONTEXT(ctx);
2449    Node *n;
2450    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2451    n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
2452    if (n) {
2453       n[1].i = s;
2454    }
2455    if (ctx->ExecuteFlag) {
2456       CALL_ClearStencil(ctx->Exec, (s));
2457    }
2458 }
2459 
2460 
2461 static void GLAPIENTRY
save_ClipPlane(GLenum plane,const GLdouble * equ)2462 save_ClipPlane(GLenum plane, const GLdouble * equ)
2463 {
2464    GET_CURRENT_CONTEXT(ctx);
2465    Node *n;
2466    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2467    n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
2468    if (n) {
2469       n[1].e = plane;
2470       n[2].f = (GLfloat) equ[0];
2471       n[3].f = (GLfloat) equ[1];
2472       n[4].f = (GLfloat) equ[2];
2473       n[5].f = (GLfloat) equ[3];
2474    }
2475    if (ctx->ExecuteFlag) {
2476       CALL_ClipPlane(ctx->Exec, (plane, equ));
2477    }
2478 }
2479 
2480 
2481 
2482 static void GLAPIENTRY
save_ColorMask(GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)2483 save_ColorMask(GLboolean red, GLboolean green,
2484                GLboolean blue, GLboolean alpha)
2485 {
2486    GET_CURRENT_CONTEXT(ctx);
2487    Node *n;
2488    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2489    n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
2490    if (n) {
2491       n[1].b = red;
2492       n[2].b = green;
2493       n[3].b = blue;
2494       n[4].b = alpha;
2495    }
2496    if (ctx->ExecuteFlag) {
2497       CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
2498    }
2499 }
2500 
2501 
2502 static void GLAPIENTRY
save_ColorMaskIndexed(GLuint buf,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)2503 save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
2504                       GLboolean blue, GLboolean alpha)
2505 {
2506    GET_CURRENT_CONTEXT(ctx);
2507    Node *n;
2508    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2509    n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
2510    if (n) {
2511       n[1].ui = buf;
2512       n[2].b = red;
2513       n[3].b = green;
2514       n[4].b = blue;
2515       n[5].b = alpha;
2516    }
2517    if (ctx->ExecuteFlag) {
2518       /*CALL_ColorMaski(ctx->Exec, (buf, red, green, blue, alpha));*/
2519    }
2520 }
2521 
2522 
2523 static void GLAPIENTRY
save_ColorMaterial(GLenum face,GLenum mode)2524 save_ColorMaterial(GLenum face, GLenum mode)
2525 {
2526    GET_CURRENT_CONTEXT(ctx);
2527    Node *n;
2528    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2529 
2530    n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
2531    if (n) {
2532       n[1].e = face;
2533       n[2].e = mode;
2534    }
2535    if (ctx->ExecuteFlag) {
2536       CALL_ColorMaterial(ctx->Exec, (face, mode));
2537    }
2538 }
2539 
2540 
2541 static void GLAPIENTRY
save_CopyPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum type)2542 save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
2543 {
2544    GET_CURRENT_CONTEXT(ctx);
2545    Node *n;
2546    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2547    n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
2548    if (n) {
2549       n[1].i = x;
2550       n[2].i = y;
2551       n[3].i = (GLint) width;
2552       n[4].i = (GLint) height;
2553       n[5].e = type;
2554    }
2555    if (ctx->ExecuteFlag) {
2556       CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
2557    }
2558 }
2559 
2560 
2561 
2562 static void GLAPIENTRY
save_CopyTexImage1D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)2563 save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
2564                     GLint x, GLint y, GLsizei width, GLint border)
2565 {
2566    GET_CURRENT_CONTEXT(ctx);
2567    Node *n;
2568    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2569    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
2570    if (n) {
2571       n[1].e = target;
2572       n[2].i = level;
2573       n[3].e = internalformat;
2574       n[4].i = x;
2575       n[5].i = y;
2576       n[6].i = width;
2577       n[7].i = border;
2578    }
2579    if (ctx->ExecuteFlag) {
2580       CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
2581                                       x, y, width, border));
2582    }
2583 }
2584 
2585 
2586 static void GLAPIENTRY
save_CopyTexImage2D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)2587 save_CopyTexImage2D(GLenum target, GLint level,
2588                     GLenum internalformat,
2589                     GLint x, GLint y, GLsizei width,
2590                     GLsizei height, GLint border)
2591 {
2592    GET_CURRENT_CONTEXT(ctx);
2593    Node *n;
2594    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2595    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
2596    if (n) {
2597       n[1].e = target;
2598       n[2].i = level;
2599       n[3].e = internalformat;
2600       n[4].i = x;
2601       n[5].i = y;
2602       n[6].i = width;
2603       n[7].i = height;
2604       n[8].i = border;
2605    }
2606    if (ctx->ExecuteFlag) {
2607       CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
2608                                       x, y, width, height, border));
2609    }
2610 }
2611 
2612 
2613 
2614 static void GLAPIENTRY
save_CopyTexSubImage1D(GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)2615 save_CopyTexSubImage1D(GLenum target, GLint level,
2616                        GLint xoffset, GLint x, GLint y, GLsizei width)
2617 {
2618    GET_CURRENT_CONTEXT(ctx);
2619    Node *n;
2620    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2621    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
2622    if (n) {
2623       n[1].e = target;
2624       n[2].i = level;
2625       n[3].i = xoffset;
2626       n[4].i = x;
2627       n[5].i = y;
2628       n[6].i = width;
2629    }
2630    if (ctx->ExecuteFlag) {
2631       CALL_CopyTexSubImage1D(ctx->Exec,
2632                              (target, level, xoffset, x, y, width));
2633    }
2634 }
2635 
2636 
2637 static void GLAPIENTRY
save_CopyTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)2638 save_CopyTexSubImage2D(GLenum target, GLint level,
2639                        GLint xoffset, GLint yoffset,
2640                        GLint x, GLint y, GLsizei width, GLint height)
2641 {
2642    GET_CURRENT_CONTEXT(ctx);
2643    Node *n;
2644    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2645    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
2646    if (n) {
2647       n[1].e = target;
2648       n[2].i = level;
2649       n[3].i = xoffset;
2650       n[4].i = yoffset;
2651       n[5].i = x;
2652       n[6].i = y;
2653       n[7].i = width;
2654       n[8].i = height;
2655    }
2656    if (ctx->ExecuteFlag) {
2657       CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
2658                                          x, y, width, height));
2659    }
2660 }
2661 
2662 
2663 static void GLAPIENTRY
save_CopyTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLint height)2664 save_CopyTexSubImage3D(GLenum target, GLint level,
2665                        GLint xoffset, GLint yoffset, GLint zoffset,
2666                        GLint x, GLint y, GLsizei width, GLint height)
2667 {
2668    GET_CURRENT_CONTEXT(ctx);
2669    Node *n;
2670    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2671    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
2672    if (n) {
2673       n[1].e = target;
2674       n[2].i = level;
2675       n[3].i = xoffset;
2676       n[4].i = yoffset;
2677       n[5].i = zoffset;
2678       n[6].i = x;
2679       n[7].i = y;
2680       n[8].i = width;
2681       n[9].i = height;
2682    }
2683    if (ctx->ExecuteFlag) {
2684       CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
2685                                          xoffset, yoffset, zoffset,
2686                                          x, y, width, height));
2687    }
2688 }
2689 
2690 
2691 static void GLAPIENTRY
save_CullFace(GLenum mode)2692 save_CullFace(GLenum mode)
2693 {
2694    GET_CURRENT_CONTEXT(ctx);
2695    Node *n;
2696    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2697    n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
2698    if (n) {
2699       n[1].e = mode;
2700    }
2701    if (ctx->ExecuteFlag) {
2702       CALL_CullFace(ctx->Exec, (mode));
2703    }
2704 }
2705 
2706 
2707 static void GLAPIENTRY
save_DepthFunc(GLenum func)2708 save_DepthFunc(GLenum func)
2709 {
2710    GET_CURRENT_CONTEXT(ctx);
2711    Node *n;
2712    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2713    n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
2714    if (n) {
2715       n[1].e = func;
2716    }
2717    if (ctx->ExecuteFlag) {
2718       CALL_DepthFunc(ctx->Exec, (func));
2719    }
2720 }
2721 
2722 
2723 static void GLAPIENTRY
save_DepthMask(GLboolean mask)2724 save_DepthMask(GLboolean mask)
2725 {
2726    GET_CURRENT_CONTEXT(ctx);
2727    Node *n;
2728    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2729    n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
2730    if (n) {
2731       n[1].b = mask;
2732    }
2733    if (ctx->ExecuteFlag) {
2734       CALL_DepthMask(ctx->Exec, (mask));
2735    }
2736 }
2737 
2738 
2739 static void GLAPIENTRY
save_DepthRange(GLclampd nearval,GLclampd farval)2740 save_DepthRange(GLclampd nearval, GLclampd farval)
2741 {
2742    GET_CURRENT_CONTEXT(ctx);
2743    Node *n;
2744    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2745    n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
2746    if (n) {
2747       n[1].f = (GLfloat) nearval;
2748       n[2].f = (GLfloat) farval;
2749    }
2750    if (ctx->ExecuteFlag) {
2751       CALL_DepthRange(ctx->Exec, (nearval, farval));
2752    }
2753 }
2754 
2755 
2756 static void GLAPIENTRY
save_Disable(GLenum cap)2757 save_Disable(GLenum cap)
2758 {
2759    GET_CURRENT_CONTEXT(ctx);
2760    Node *n;
2761    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2762    n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
2763    if (n) {
2764       n[1].e = cap;
2765    }
2766    if (ctx->ExecuteFlag) {
2767       CALL_Disable(ctx->Exec, (cap));
2768    }
2769 }
2770 
2771 
2772 static void GLAPIENTRY
save_DisableIndexed(GLuint index,GLenum cap)2773 save_DisableIndexed(GLuint index, GLenum cap)
2774 {
2775    GET_CURRENT_CONTEXT(ctx);
2776    Node *n;
2777    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2778    n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
2779    if (n) {
2780       n[1].ui = index;
2781       n[2].e = cap;
2782    }
2783    if (ctx->ExecuteFlag) {
2784       CALL_Disablei(ctx->Exec, (index, cap));
2785    }
2786 }
2787 
2788 
2789 static void GLAPIENTRY
save_DrawBuffer(GLenum mode)2790 save_DrawBuffer(GLenum mode)
2791 {
2792    GET_CURRENT_CONTEXT(ctx);
2793    Node *n;
2794    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2795    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
2796    if (n) {
2797       n[1].e = mode;
2798    }
2799    if (ctx->ExecuteFlag) {
2800       CALL_DrawBuffer(ctx->Exec, (mode));
2801    }
2802 }
2803 
2804 
2805 static void GLAPIENTRY
save_DrawPixels(GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)2806 save_DrawPixels(GLsizei width, GLsizei height,
2807                 GLenum format, GLenum type, const GLvoid * pixels)
2808 {
2809    GET_CURRENT_CONTEXT(ctx);
2810    Node *n;
2811 
2812    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2813 
2814    n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 4 + POINTER_DWORDS);
2815    if (n) {
2816       n[1].i = width;
2817       n[2].i = height;
2818       n[3].e = format;
2819       n[4].e = type;
2820       save_pointer(&n[5],
2821                    unpack_image(ctx, 2, width, height, 1, format, type,
2822                                 pixels, &ctx->Unpack));
2823    }
2824    if (ctx->ExecuteFlag) {
2825       CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
2826    }
2827 }
2828 
2829 
2830 
2831 static void GLAPIENTRY
save_Enable(GLenum cap)2832 save_Enable(GLenum cap)
2833 {
2834    GET_CURRENT_CONTEXT(ctx);
2835    Node *n;
2836    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2837    n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
2838    if (n) {
2839       n[1].e = cap;
2840    }
2841    if (ctx->ExecuteFlag) {
2842       CALL_Enable(ctx->Exec, (cap));
2843    }
2844 }
2845 
2846 
2847 
2848 static void GLAPIENTRY
save_EnableIndexed(GLuint index,GLenum cap)2849 save_EnableIndexed(GLuint index, GLenum cap)
2850 {
2851    GET_CURRENT_CONTEXT(ctx);
2852    Node *n;
2853    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2854    n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
2855    if (n) {
2856       n[1].ui = index;
2857       n[2].e = cap;
2858    }
2859    if (ctx->ExecuteFlag) {
2860       CALL_Enablei(ctx->Exec, (index, cap));
2861    }
2862 }
2863 
2864 
2865 
2866 static void GLAPIENTRY
save_EvalMesh1(GLenum mode,GLint i1,GLint i2)2867 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
2868 {
2869    GET_CURRENT_CONTEXT(ctx);
2870    Node *n;
2871    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2872    n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
2873    if (n) {
2874       n[1].e = mode;
2875       n[2].i = i1;
2876       n[3].i = i2;
2877    }
2878    if (ctx->ExecuteFlag) {
2879       CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
2880    }
2881 }
2882 
2883 
2884 static void GLAPIENTRY
save_EvalMesh2(GLenum mode,GLint i1,GLint i2,GLint j1,GLint j2)2885 save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
2886 {
2887    GET_CURRENT_CONTEXT(ctx);
2888    Node *n;
2889    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2890    n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
2891    if (n) {
2892       n[1].e = mode;
2893       n[2].i = i1;
2894       n[3].i = i2;
2895       n[4].i = j1;
2896       n[5].i = j2;
2897    }
2898    if (ctx->ExecuteFlag) {
2899       CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
2900    }
2901 }
2902 
2903 
2904 
2905 
2906 static void GLAPIENTRY
save_Fogfv(GLenum pname,const GLfloat * params)2907 save_Fogfv(GLenum pname, const GLfloat *params)
2908 {
2909    GET_CURRENT_CONTEXT(ctx);
2910    Node *n;
2911    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2912    n = alloc_instruction(ctx, OPCODE_FOG, 5);
2913    if (n) {
2914       n[1].e = pname;
2915       n[2].f = params[0];
2916       n[3].f = params[1];
2917       n[4].f = params[2];
2918       n[5].f = params[3];
2919    }
2920    if (ctx->ExecuteFlag) {
2921       CALL_Fogfv(ctx->Exec, (pname, params));
2922    }
2923 }
2924 
2925 
2926 static void GLAPIENTRY
save_Fogf(GLenum pname,GLfloat param)2927 save_Fogf(GLenum pname, GLfloat param)
2928 {
2929    GLfloat parray[4];
2930    parray[0] = param;
2931    parray[1] = parray[2] = parray[3] = 0.0F;
2932    save_Fogfv(pname, parray);
2933 }
2934 
2935 
2936 static void GLAPIENTRY
save_Fogiv(GLenum pname,const GLint * params)2937 save_Fogiv(GLenum pname, const GLint *params)
2938 {
2939    GLfloat p[4];
2940    switch (pname) {
2941    case GL_FOG_MODE:
2942    case GL_FOG_DENSITY:
2943    case GL_FOG_START:
2944    case GL_FOG_END:
2945    case GL_FOG_INDEX:
2946    case GL_FOG_COORDINATE_SOURCE:
2947       p[0] = (GLfloat) *params;
2948       p[1] = 0.0f;
2949       p[2] = 0.0f;
2950       p[3] = 0.0f;
2951       break;
2952    case GL_FOG_COLOR:
2953       p[0] = INT_TO_FLOAT(params[0]);
2954       p[1] = INT_TO_FLOAT(params[1]);
2955       p[2] = INT_TO_FLOAT(params[2]);
2956       p[3] = INT_TO_FLOAT(params[3]);
2957       break;
2958    default:
2959       /* Error will be caught later in gl_Fogfv */
2960       ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
2961    }
2962    save_Fogfv(pname, p);
2963 }
2964 
2965 
2966 static void GLAPIENTRY
save_Fogi(GLenum pname,GLint param)2967 save_Fogi(GLenum pname, GLint param)
2968 {
2969    GLint parray[4];
2970    parray[0] = param;
2971    parray[1] = parray[2] = parray[3] = 0;
2972    save_Fogiv(pname, parray);
2973 }
2974 
2975 
2976 static void GLAPIENTRY
save_FrontFace(GLenum mode)2977 save_FrontFace(GLenum mode)
2978 {
2979    GET_CURRENT_CONTEXT(ctx);
2980    Node *n;
2981    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2982    n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
2983    if (n) {
2984       n[1].e = mode;
2985    }
2986    if (ctx->ExecuteFlag) {
2987       CALL_FrontFace(ctx->Exec, (mode));
2988    }
2989 }
2990 
2991 
2992 static void GLAPIENTRY
save_Frustum(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)2993 save_Frustum(GLdouble left, GLdouble right,
2994              GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2995 {
2996    GET_CURRENT_CONTEXT(ctx);
2997    Node *n;
2998    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2999    n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
3000    if (n) {
3001       n[1].f = (GLfloat) left;
3002       n[2].f = (GLfloat) right;
3003       n[3].f = (GLfloat) bottom;
3004       n[4].f = (GLfloat) top;
3005       n[5].f = (GLfloat) nearval;
3006       n[6].f = (GLfloat) farval;
3007    }
3008    if (ctx->ExecuteFlag) {
3009       CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
3010    }
3011 }
3012 
3013 
3014 static void GLAPIENTRY
save_Hint(GLenum target,GLenum mode)3015 save_Hint(GLenum target, GLenum mode)
3016 {
3017    GET_CURRENT_CONTEXT(ctx);
3018    Node *n;
3019    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3020    n = alloc_instruction(ctx, OPCODE_HINT, 2);
3021    if (n) {
3022       n[1].e = target;
3023       n[2].e = mode;
3024    }
3025    if (ctx->ExecuteFlag) {
3026       CALL_Hint(ctx->Exec, (target, mode));
3027    }
3028 }
3029 
3030 
3031 static void GLAPIENTRY
save_IndexMask(GLuint mask)3032 save_IndexMask(GLuint mask)
3033 {
3034    GET_CURRENT_CONTEXT(ctx);
3035    Node *n;
3036    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3037    n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
3038    if (n) {
3039       n[1].ui = mask;
3040    }
3041    if (ctx->ExecuteFlag) {
3042       CALL_IndexMask(ctx->Exec, (mask));
3043    }
3044 }
3045 
3046 
3047 static void GLAPIENTRY
save_InitNames(void)3048 save_InitNames(void)
3049 {
3050    GET_CURRENT_CONTEXT(ctx);
3051    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3052    (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
3053    if (ctx->ExecuteFlag) {
3054       CALL_InitNames(ctx->Exec, ());
3055    }
3056 }
3057 
3058 
3059 static void GLAPIENTRY
save_Lightfv(GLenum light,GLenum pname,const GLfloat * params)3060 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
3061 {
3062    GET_CURRENT_CONTEXT(ctx);
3063    Node *n;
3064    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3065    n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
3066    if (n) {
3067       GLint i, nParams;
3068       n[1].e = light;
3069       n[2].e = pname;
3070       switch (pname) {
3071       case GL_AMBIENT:
3072          nParams = 4;
3073          break;
3074       case GL_DIFFUSE:
3075          nParams = 4;
3076          break;
3077       case GL_SPECULAR:
3078          nParams = 4;
3079          break;
3080       case GL_POSITION:
3081          nParams = 4;
3082          break;
3083       case GL_SPOT_DIRECTION:
3084          nParams = 3;
3085          break;
3086       case GL_SPOT_EXPONENT:
3087          nParams = 1;
3088          break;
3089       case GL_SPOT_CUTOFF:
3090          nParams = 1;
3091          break;
3092       case GL_CONSTANT_ATTENUATION:
3093          nParams = 1;
3094          break;
3095       case GL_LINEAR_ATTENUATION:
3096          nParams = 1;
3097          break;
3098       case GL_QUADRATIC_ATTENUATION:
3099          nParams = 1;
3100          break;
3101       default:
3102          nParams = 0;
3103       }
3104       for (i = 0; i < nParams; i++) {
3105          n[3 + i].f = params[i];
3106       }
3107    }
3108    if (ctx->ExecuteFlag) {
3109       CALL_Lightfv(ctx->Exec, (light, pname, params));
3110    }
3111 }
3112 
3113 
3114 static void GLAPIENTRY
save_Lightf(GLenum light,GLenum pname,GLfloat param)3115 save_Lightf(GLenum light, GLenum pname, GLfloat param)
3116 {
3117    GLfloat parray[4];
3118    parray[0] = param;
3119    parray[1] = parray[2] = parray[3] = 0.0F;
3120    save_Lightfv(light, pname, parray);
3121 }
3122 
3123 
3124 static void GLAPIENTRY
save_Lightiv(GLenum light,GLenum pname,const GLint * params)3125 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
3126 {
3127    GLfloat fparam[4];
3128    switch (pname) {
3129    case GL_AMBIENT:
3130    case GL_DIFFUSE:
3131    case GL_SPECULAR:
3132       fparam[0] = INT_TO_FLOAT(params[0]);
3133       fparam[1] = INT_TO_FLOAT(params[1]);
3134       fparam[2] = INT_TO_FLOAT(params[2]);
3135       fparam[3] = INT_TO_FLOAT(params[3]);
3136       break;
3137    case GL_POSITION:
3138       fparam[0] = (GLfloat) params[0];
3139       fparam[1] = (GLfloat) params[1];
3140       fparam[2] = (GLfloat) params[2];
3141       fparam[3] = (GLfloat) params[3];
3142       break;
3143    case GL_SPOT_DIRECTION:
3144       fparam[0] = (GLfloat) params[0];
3145       fparam[1] = (GLfloat) params[1];
3146       fparam[2] = (GLfloat) params[2];
3147       break;
3148    case GL_SPOT_EXPONENT:
3149    case GL_SPOT_CUTOFF:
3150    case GL_CONSTANT_ATTENUATION:
3151    case GL_LINEAR_ATTENUATION:
3152    case GL_QUADRATIC_ATTENUATION:
3153       fparam[0] = (GLfloat) params[0];
3154       break;
3155    default:
3156       /* error will be caught later in gl_Lightfv */
3157       ;
3158    }
3159    save_Lightfv(light, pname, fparam);
3160 }
3161 
3162 
3163 static void GLAPIENTRY
save_Lighti(GLenum light,GLenum pname,GLint param)3164 save_Lighti(GLenum light, GLenum pname, GLint param)
3165 {
3166    GLint parray[4];
3167    parray[0] = param;
3168    parray[1] = parray[2] = parray[3] = 0;
3169    save_Lightiv(light, pname, parray);
3170 }
3171 
3172 
3173 static void GLAPIENTRY
save_LightModelfv(GLenum pname,const GLfloat * params)3174 save_LightModelfv(GLenum pname, const GLfloat *params)
3175 {
3176    GET_CURRENT_CONTEXT(ctx);
3177    Node *n;
3178    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3179    n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
3180    if (n) {
3181       n[1].e = pname;
3182       n[2].f = params[0];
3183       n[3].f = params[1];
3184       n[4].f = params[2];
3185       n[5].f = params[3];
3186    }
3187    if (ctx->ExecuteFlag) {
3188       CALL_LightModelfv(ctx->Exec, (pname, params));
3189    }
3190 }
3191 
3192 
3193 static void GLAPIENTRY
save_LightModelf(GLenum pname,GLfloat param)3194 save_LightModelf(GLenum pname, GLfloat param)
3195 {
3196    GLfloat parray[4];
3197    parray[0] = param;
3198    parray[1] = parray[2] = parray[3] = 0.0F;
3199    save_LightModelfv(pname, parray);
3200 }
3201 
3202 
3203 static void GLAPIENTRY
save_LightModeliv(GLenum pname,const GLint * params)3204 save_LightModeliv(GLenum pname, const GLint *params)
3205 {
3206    GLfloat fparam[4];
3207    switch (pname) {
3208    case GL_LIGHT_MODEL_AMBIENT:
3209       fparam[0] = INT_TO_FLOAT(params[0]);
3210       fparam[1] = INT_TO_FLOAT(params[1]);
3211       fparam[2] = INT_TO_FLOAT(params[2]);
3212       fparam[3] = INT_TO_FLOAT(params[3]);
3213       break;
3214    case GL_LIGHT_MODEL_LOCAL_VIEWER:
3215    case GL_LIGHT_MODEL_TWO_SIDE:
3216    case GL_LIGHT_MODEL_COLOR_CONTROL:
3217       fparam[0] = (GLfloat) params[0];
3218       fparam[1] = 0.0F;
3219       fparam[2] = 0.0F;
3220       fparam[3] = 0.0F;
3221       break;
3222    default:
3223       /* Error will be caught later in gl_LightModelfv */
3224       ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
3225    }
3226    save_LightModelfv(pname, fparam);
3227 }
3228 
3229 
3230 static void GLAPIENTRY
save_LightModeli(GLenum pname,GLint param)3231 save_LightModeli(GLenum pname, GLint param)
3232 {
3233    GLint parray[4];
3234    parray[0] = param;
3235    parray[1] = parray[2] = parray[3] = 0;
3236    save_LightModeliv(pname, parray);
3237 }
3238 
3239 
3240 static void GLAPIENTRY
save_LineStipple(GLint factor,GLushort pattern)3241 save_LineStipple(GLint factor, GLushort pattern)
3242 {
3243    GET_CURRENT_CONTEXT(ctx);
3244    Node *n;
3245    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3246    n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
3247    if (n) {
3248       n[1].i = factor;
3249       n[2].us = pattern;
3250    }
3251    if (ctx->ExecuteFlag) {
3252       CALL_LineStipple(ctx->Exec, (factor, pattern));
3253    }
3254 }
3255 
3256 
3257 static void GLAPIENTRY
save_LineWidth(GLfloat width)3258 save_LineWidth(GLfloat width)
3259 {
3260    GET_CURRENT_CONTEXT(ctx);
3261    Node *n;
3262    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3263    n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
3264    if (n) {
3265       n[1].f = width;
3266    }
3267    if (ctx->ExecuteFlag) {
3268       CALL_LineWidth(ctx->Exec, (width));
3269    }
3270 }
3271 
3272 
3273 static void GLAPIENTRY
save_ListBase(GLuint base)3274 save_ListBase(GLuint base)
3275 {
3276    GET_CURRENT_CONTEXT(ctx);
3277    Node *n;
3278    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3279    n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
3280    if (n) {
3281       n[1].ui = base;
3282    }
3283    if (ctx->ExecuteFlag) {
3284       CALL_ListBase(ctx->Exec, (base));
3285    }
3286 }
3287 
3288 
3289 static void GLAPIENTRY
save_LoadIdentity(void)3290 save_LoadIdentity(void)
3291 {
3292    GET_CURRENT_CONTEXT(ctx);
3293    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3294    (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
3295    if (ctx->ExecuteFlag) {
3296       CALL_LoadIdentity(ctx->Exec, ());
3297    }
3298 }
3299 
3300 
3301 static void GLAPIENTRY
save_LoadMatrixf(const GLfloat * m)3302 save_LoadMatrixf(const GLfloat * m)
3303 {
3304    GET_CURRENT_CONTEXT(ctx);
3305    Node *n;
3306    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3307    n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
3308    if (n) {
3309       GLuint i;
3310       for (i = 0; i < 16; i++) {
3311          n[1 + i].f = m[i];
3312       }
3313    }
3314    if (ctx->ExecuteFlag) {
3315       CALL_LoadMatrixf(ctx->Exec, (m));
3316    }
3317 }
3318 
3319 
3320 static void GLAPIENTRY
save_LoadMatrixd(const GLdouble * m)3321 save_LoadMatrixd(const GLdouble * m)
3322 {
3323    GLfloat f[16];
3324    GLint i;
3325    for (i = 0; i < 16; i++) {
3326       f[i] = (GLfloat) m[i];
3327    }
3328    save_LoadMatrixf(f);
3329 }
3330 
3331 
3332 static void GLAPIENTRY
save_LoadName(GLuint name)3333 save_LoadName(GLuint name)
3334 {
3335    GET_CURRENT_CONTEXT(ctx);
3336    Node *n;
3337    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3338    n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
3339    if (n) {
3340       n[1].ui = name;
3341    }
3342    if (ctx->ExecuteFlag) {
3343       CALL_LoadName(ctx->Exec, (name));
3344    }
3345 }
3346 
3347 
3348 static void GLAPIENTRY
save_LogicOp(GLenum opcode)3349 save_LogicOp(GLenum opcode)
3350 {
3351    GET_CURRENT_CONTEXT(ctx);
3352    Node *n;
3353    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3354    n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
3355    if (n) {
3356       n[1].e = opcode;
3357    }
3358    if (ctx->ExecuteFlag) {
3359       CALL_LogicOp(ctx->Exec, (opcode));
3360    }
3361 }
3362 
3363 
3364 static void GLAPIENTRY
save_Map1d(GLenum target,GLdouble u1,GLdouble u2,GLint stride,GLint order,const GLdouble * points)3365 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
3366            GLint order, const GLdouble * points)
3367 {
3368    GET_CURRENT_CONTEXT(ctx);
3369    Node *n;
3370    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3371    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
3372    if (n) {
3373       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
3374       n[1].e = target;
3375       n[2].f = (GLfloat) u1;
3376       n[3].f = (GLfloat) u2;
3377       n[4].i = _mesa_evaluator_components(target);      /* stride */
3378       n[5].i = order;
3379       save_pointer(&n[6], pnts);
3380    }
3381    if (ctx->ExecuteFlag) {
3382       CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
3383    }
3384 }
3385 
3386 static void GLAPIENTRY
save_Map1f(GLenum target,GLfloat u1,GLfloat u2,GLint stride,GLint order,const GLfloat * points)3387 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
3388            GLint order, const GLfloat * points)
3389 {
3390    GET_CURRENT_CONTEXT(ctx);
3391    Node *n;
3392    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3393    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
3394    if (n) {
3395       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
3396       n[1].e = target;
3397       n[2].f = u1;
3398       n[3].f = u2;
3399       n[4].i = _mesa_evaluator_components(target);      /* stride */
3400       n[5].i = order;
3401       save_pointer(&n[6], pnts);
3402    }
3403    if (ctx->ExecuteFlag) {
3404       CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
3405    }
3406 }
3407 
3408 
3409 static void GLAPIENTRY
save_Map2d(GLenum target,GLdouble u1,GLdouble u2,GLint ustride,GLint uorder,GLdouble v1,GLdouble v2,GLint vstride,GLint vorder,const GLdouble * points)3410 save_Map2d(GLenum target,
3411            GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
3412            GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
3413            const GLdouble * points)
3414 {
3415    GET_CURRENT_CONTEXT(ctx);
3416    Node *n;
3417    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3418    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
3419    if (n) {
3420       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
3421                                               vstride, vorder, points);
3422       n[1].e = target;
3423       n[2].f = (GLfloat) u1;
3424       n[3].f = (GLfloat) u2;
3425       n[4].f = (GLfloat) v1;
3426       n[5].f = (GLfloat) v2;
3427       /* XXX verify these strides are correct */
3428       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
3429       n[7].i = _mesa_evaluator_components(target);      /*vstride */
3430       n[8].i = uorder;
3431       n[9].i = vorder;
3432       save_pointer(&n[10], pnts);
3433    }
3434    if (ctx->ExecuteFlag) {
3435       CALL_Map2d(ctx->Exec, (target,
3436                              u1, u2, ustride, uorder,
3437                              v1, v2, vstride, vorder, points));
3438    }
3439 }
3440 
3441 
3442 static void GLAPIENTRY
save_Map2f(GLenum target,GLfloat u1,GLfloat u2,GLint ustride,GLint uorder,GLfloat v1,GLfloat v2,GLint vstride,GLint vorder,const GLfloat * points)3443 save_Map2f(GLenum target,
3444            GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
3445            GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
3446            const GLfloat * points)
3447 {
3448    GET_CURRENT_CONTEXT(ctx);
3449    Node *n;
3450    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3451    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
3452    if (n) {
3453       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
3454                                               vstride, vorder, points);
3455       n[1].e = target;
3456       n[2].f = u1;
3457       n[3].f = u2;
3458       n[4].f = v1;
3459       n[5].f = v2;
3460       /* XXX verify these strides are correct */
3461       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
3462       n[7].i = _mesa_evaluator_components(target);      /*vstride */
3463       n[8].i = uorder;
3464       n[9].i = vorder;
3465       save_pointer(&n[10], pnts);
3466    }
3467    if (ctx->ExecuteFlag) {
3468       CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
3469                              v1, v2, vstride, vorder, points));
3470    }
3471 }
3472 
3473 
3474 static void GLAPIENTRY
save_MapGrid1f(GLint un,GLfloat u1,GLfloat u2)3475 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
3476 {
3477    GET_CURRENT_CONTEXT(ctx);
3478    Node *n;
3479    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3480    n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
3481    if (n) {
3482       n[1].i = un;
3483       n[2].f = u1;
3484       n[3].f = u2;
3485    }
3486    if (ctx->ExecuteFlag) {
3487       CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
3488    }
3489 }
3490 
3491 
3492 static void GLAPIENTRY
save_MapGrid1d(GLint un,GLdouble u1,GLdouble u2)3493 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
3494 {
3495    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
3496 }
3497 
3498 
3499 static void GLAPIENTRY
save_MapGrid2f(GLint un,GLfloat u1,GLfloat u2,GLint vn,GLfloat v1,GLfloat v2)3500 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
3501                GLint vn, GLfloat v1, GLfloat v2)
3502 {
3503    GET_CURRENT_CONTEXT(ctx);
3504    Node *n;
3505    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3506    n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
3507    if (n) {
3508       n[1].i = un;
3509       n[2].f = u1;
3510       n[3].f = u2;
3511       n[4].i = vn;
3512       n[5].f = v1;
3513       n[6].f = v2;
3514    }
3515    if (ctx->ExecuteFlag) {
3516       CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
3517    }
3518 }
3519 
3520 
3521 
3522 static void GLAPIENTRY
save_MapGrid2d(GLint un,GLdouble u1,GLdouble u2,GLint vn,GLdouble v1,GLdouble v2)3523 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
3524                GLint vn, GLdouble v1, GLdouble v2)
3525 {
3526    save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
3527                   vn, (GLfloat) v1, (GLfloat) v2);
3528 }
3529 
3530 
3531 static void GLAPIENTRY
save_MatrixMode(GLenum mode)3532 save_MatrixMode(GLenum mode)
3533 {
3534    GET_CURRENT_CONTEXT(ctx);
3535    Node *n;
3536    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3537    n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
3538    if (n) {
3539       n[1].e = mode;
3540    }
3541    if (ctx->ExecuteFlag) {
3542       CALL_MatrixMode(ctx->Exec, (mode));
3543    }
3544 }
3545 
3546 
3547 static void GLAPIENTRY
save_MultMatrixf(const GLfloat * m)3548 save_MultMatrixf(const GLfloat * m)
3549 {
3550    GET_CURRENT_CONTEXT(ctx);
3551    Node *n;
3552    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3553    n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
3554    if (n) {
3555       GLuint i;
3556       for (i = 0; i < 16; i++) {
3557          n[1 + i].f = m[i];
3558       }
3559    }
3560    if (ctx->ExecuteFlag) {
3561       CALL_MultMatrixf(ctx->Exec, (m));
3562    }
3563 }
3564 
3565 
3566 static void GLAPIENTRY
save_MultMatrixd(const GLdouble * m)3567 save_MultMatrixd(const GLdouble * m)
3568 {
3569    GLfloat f[16];
3570    GLint i;
3571    for (i = 0; i < 16; i++) {
3572       f[i] = (GLfloat) m[i];
3573    }
3574    save_MultMatrixf(f);
3575 }
3576 
3577 
3578 static void GLAPIENTRY
save_NewList(GLuint name,GLenum mode)3579 save_NewList(GLuint name, GLenum mode)
3580 {
3581    GET_CURRENT_CONTEXT(ctx);
3582    /* It's an error to call this function while building a display list */
3583    _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
3584    (void) name;
3585    (void) mode;
3586 }
3587 
3588 
3589 
3590 static void GLAPIENTRY
save_Ortho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)3591 save_Ortho(GLdouble left, GLdouble right,
3592            GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
3593 {
3594    GET_CURRENT_CONTEXT(ctx);
3595    Node *n;
3596    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3597    n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
3598    if (n) {
3599       n[1].f = (GLfloat) left;
3600       n[2].f = (GLfloat) right;
3601       n[3].f = (GLfloat) bottom;
3602       n[4].f = (GLfloat) top;
3603       n[5].f = (GLfloat) nearval;
3604       n[6].f = (GLfloat) farval;
3605    }
3606    if (ctx->ExecuteFlag) {
3607       CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
3608    }
3609 }
3610 
3611 
3612 static void GLAPIENTRY
save_PatchParameteri(GLenum pname,const GLint value)3613 save_PatchParameteri(GLenum pname, const GLint value)
3614 {
3615    GET_CURRENT_CONTEXT(ctx);
3616    Node *n;
3617    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3618    n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_I, 2);
3619    if (n) {
3620       n[1].e = pname;
3621       n[2].i = value;
3622    }
3623    if (ctx->ExecuteFlag) {
3624       CALL_PatchParameteri(ctx->Exec, (pname, value));
3625    }
3626 }
3627 
3628 
3629 static void GLAPIENTRY
save_PatchParameterfv(GLenum pname,const GLfloat * params)3630 save_PatchParameterfv(GLenum pname, const GLfloat *params)
3631 {
3632    GET_CURRENT_CONTEXT(ctx);
3633    Node *n;
3634    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3635 
3636    if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3637       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_OUTER, 5);
3638    } else {
3639       assert(pname == GL_PATCH_DEFAULT_INNER_LEVEL);
3640       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_INNER, 3);
3641    }
3642    if (n) {
3643       n[1].e = pname;
3644       if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3645          n[2].f = params[0];
3646          n[3].f = params[1];
3647          n[4].f = params[2];
3648          n[5].f = params[3];
3649       } else {
3650          n[2].f = params[0];
3651          n[3].f = params[1];
3652       }
3653    }
3654    if (ctx->ExecuteFlag) {
3655       CALL_PatchParameterfv(ctx->Exec, (pname, params));
3656    }
3657 }
3658 
3659 
3660 static void GLAPIENTRY
save_PixelMapfv(GLenum map,GLint mapsize,const GLfloat * values)3661 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
3662 {
3663    GET_CURRENT_CONTEXT(ctx);
3664    Node *n;
3665    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3666    n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 2 + POINTER_DWORDS);
3667    if (n) {
3668       n[1].e = map;
3669       n[2].i = mapsize;
3670       save_pointer(&n[3], memdup(values, mapsize * sizeof(GLfloat)));
3671    }
3672    if (ctx->ExecuteFlag) {
3673       CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
3674    }
3675 }
3676 
3677 
3678 static void GLAPIENTRY
save_PixelMapuiv(GLenum map,GLint mapsize,const GLuint * values)3679 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
3680 {
3681    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3682    GLint i;
3683    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3684       for (i = 0; i < mapsize; i++) {
3685          fvalues[i] = (GLfloat) values[i];
3686       }
3687    }
3688    else {
3689       for (i = 0; i < mapsize; i++) {
3690          fvalues[i] = UINT_TO_FLOAT(values[i]);
3691       }
3692    }
3693    save_PixelMapfv(map, mapsize, fvalues);
3694 }
3695 
3696 
3697 static void GLAPIENTRY
save_PixelMapusv(GLenum map,GLint mapsize,const GLushort * values)3698 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
3699 {
3700    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3701    GLint i;
3702    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3703       for (i = 0; i < mapsize; i++) {
3704          fvalues[i] = (GLfloat) values[i];
3705       }
3706    }
3707    else {
3708       for (i = 0; i < mapsize; i++) {
3709          fvalues[i] = USHORT_TO_FLOAT(values[i]);
3710       }
3711    }
3712    save_PixelMapfv(map, mapsize, fvalues);
3713 }
3714 
3715 
3716 static void GLAPIENTRY
save_PixelTransferf(GLenum pname,GLfloat param)3717 save_PixelTransferf(GLenum pname, GLfloat param)
3718 {
3719    GET_CURRENT_CONTEXT(ctx);
3720    Node *n;
3721    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3722    n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
3723    if (n) {
3724       n[1].e = pname;
3725       n[2].f = param;
3726    }
3727    if (ctx->ExecuteFlag) {
3728       CALL_PixelTransferf(ctx->Exec, (pname, param));
3729    }
3730 }
3731 
3732 
3733 static void GLAPIENTRY
save_PixelTransferi(GLenum pname,GLint param)3734 save_PixelTransferi(GLenum pname, GLint param)
3735 {
3736    save_PixelTransferf(pname, (GLfloat) param);
3737 }
3738 
3739 
3740 static void GLAPIENTRY
save_PixelZoom(GLfloat xfactor,GLfloat yfactor)3741 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
3742 {
3743    GET_CURRENT_CONTEXT(ctx);
3744    Node *n;
3745    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3746    n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
3747    if (n) {
3748       n[1].f = xfactor;
3749       n[2].f = yfactor;
3750    }
3751    if (ctx->ExecuteFlag) {
3752       CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
3753    }
3754 }
3755 
3756 
3757 static void GLAPIENTRY
save_PointParameterfvEXT(GLenum pname,const GLfloat * params)3758 save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
3759 {
3760    GET_CURRENT_CONTEXT(ctx);
3761    Node *n;
3762    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3763    n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
3764    if (n) {
3765       n[1].e = pname;
3766       n[2].f = params[0];
3767       n[3].f = params[1];
3768       n[4].f = params[2];
3769    }
3770    if (ctx->ExecuteFlag) {
3771       CALL_PointParameterfv(ctx->Exec, (pname, params));
3772    }
3773 }
3774 
3775 
3776 static void GLAPIENTRY
save_PointParameterfEXT(GLenum pname,GLfloat param)3777 save_PointParameterfEXT(GLenum pname, GLfloat param)
3778 {
3779    GLfloat parray[3];
3780    parray[0] = param;
3781    parray[1] = parray[2] = 0.0F;
3782    save_PointParameterfvEXT(pname, parray);
3783 }
3784 
3785 static void GLAPIENTRY
save_PointParameteriNV(GLenum pname,GLint param)3786 save_PointParameteriNV(GLenum pname, GLint param)
3787 {
3788    GLfloat parray[3];
3789    parray[0] = (GLfloat) param;
3790    parray[1] = parray[2] = 0.0F;
3791    save_PointParameterfvEXT(pname, parray);
3792 }
3793 
3794 static void GLAPIENTRY
save_PointParameterivNV(GLenum pname,const GLint * param)3795 save_PointParameterivNV(GLenum pname, const GLint * param)
3796 {
3797    GLfloat parray[3];
3798    parray[0] = (GLfloat) param[0];
3799    parray[1] = parray[2] = 0.0F;
3800    save_PointParameterfvEXT(pname, parray);
3801 }
3802 
3803 
3804 static void GLAPIENTRY
save_PointSize(GLfloat size)3805 save_PointSize(GLfloat size)
3806 {
3807    GET_CURRENT_CONTEXT(ctx);
3808    Node *n;
3809    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3810    n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
3811    if (n) {
3812       n[1].f = size;
3813    }
3814    if (ctx->ExecuteFlag) {
3815       CALL_PointSize(ctx->Exec, (size));
3816    }
3817 }
3818 
3819 
3820 static void GLAPIENTRY
save_PolygonMode(GLenum face,GLenum mode)3821 save_PolygonMode(GLenum face, GLenum mode)
3822 {
3823    GET_CURRENT_CONTEXT(ctx);
3824    Node *n;
3825    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3826    n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
3827    if (n) {
3828       n[1].e = face;
3829       n[2].e = mode;
3830    }
3831    if (ctx->ExecuteFlag) {
3832       CALL_PolygonMode(ctx->Exec, (face, mode));
3833    }
3834 }
3835 
3836 
3837 static void GLAPIENTRY
save_PolygonStipple(const GLubyte * pattern)3838 save_PolygonStipple(const GLubyte * pattern)
3839 {
3840    GET_CURRENT_CONTEXT(ctx);
3841    Node *n;
3842 
3843    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3844 
3845    n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, POINTER_DWORDS);
3846    if (n) {
3847       save_pointer(&n[1],
3848                    unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
3849                                 pattern, &ctx->Unpack));
3850    }
3851    if (ctx->ExecuteFlag) {
3852       CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
3853    }
3854 }
3855 
3856 
3857 static void GLAPIENTRY
save_PolygonOffset(GLfloat factor,GLfloat units)3858 save_PolygonOffset(GLfloat factor, GLfloat units)
3859 {
3860    GET_CURRENT_CONTEXT(ctx);
3861    Node *n;
3862    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3863    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
3864    if (n) {
3865       n[1].f = factor;
3866       n[2].f = units;
3867    }
3868    if (ctx->ExecuteFlag) {
3869       CALL_PolygonOffset(ctx->Exec, (factor, units));
3870    }
3871 }
3872 
3873 
3874 static void GLAPIENTRY
save_PolygonOffsetClampEXT(GLfloat factor,GLfloat units,GLfloat clamp)3875 save_PolygonOffsetClampEXT(GLfloat factor, GLfloat units, GLfloat clamp)
3876 {
3877    GET_CURRENT_CONTEXT(ctx);
3878    Node *n;
3879    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3880    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET_CLAMP, 3);
3881    if (n) {
3882       n[1].f = factor;
3883       n[2].f = units;
3884       n[3].f = clamp;
3885    }
3886    if (ctx->ExecuteFlag) {
3887       CALL_PolygonOffsetClampEXT(ctx->Exec, (factor, units, clamp));
3888    }
3889 }
3890 
3891 static void GLAPIENTRY
save_PopAttrib(void)3892 save_PopAttrib(void)
3893 {
3894    GET_CURRENT_CONTEXT(ctx);
3895    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3896    (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
3897    if (ctx->ExecuteFlag) {
3898       CALL_PopAttrib(ctx->Exec, ());
3899    }
3900 }
3901 
3902 
3903 static void GLAPIENTRY
save_PopMatrix(void)3904 save_PopMatrix(void)
3905 {
3906    GET_CURRENT_CONTEXT(ctx);
3907    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3908    (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
3909    if (ctx->ExecuteFlag) {
3910       CALL_PopMatrix(ctx->Exec, ());
3911    }
3912 }
3913 
3914 
3915 static void GLAPIENTRY
save_PopName(void)3916 save_PopName(void)
3917 {
3918    GET_CURRENT_CONTEXT(ctx);
3919    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3920    (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
3921    if (ctx->ExecuteFlag) {
3922       CALL_PopName(ctx->Exec, ());
3923    }
3924 }
3925 
3926 
3927 static void GLAPIENTRY
save_PrioritizeTextures(GLsizei num,const GLuint * textures,const GLclampf * priorities)3928 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
3929                         const GLclampf * priorities)
3930 {
3931    GET_CURRENT_CONTEXT(ctx);
3932    GLint i;
3933    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3934 
3935    for (i = 0; i < num; i++) {
3936       Node *n;
3937       n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
3938       if (n) {
3939          n[1].ui = textures[i];
3940          n[2].f = priorities[i];
3941       }
3942    }
3943    if (ctx->ExecuteFlag) {
3944       CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
3945    }
3946 }
3947 
3948 
3949 static void GLAPIENTRY
save_PushAttrib(GLbitfield mask)3950 save_PushAttrib(GLbitfield mask)
3951 {
3952    GET_CURRENT_CONTEXT(ctx);
3953    Node *n;
3954    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3955    n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
3956    if (n) {
3957       n[1].bf = mask;
3958    }
3959    if (ctx->ExecuteFlag) {
3960       CALL_PushAttrib(ctx->Exec, (mask));
3961    }
3962 }
3963 
3964 
3965 static void GLAPIENTRY
save_PushMatrix(void)3966 save_PushMatrix(void)
3967 {
3968    GET_CURRENT_CONTEXT(ctx);
3969    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3970    (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
3971    if (ctx->ExecuteFlag) {
3972       CALL_PushMatrix(ctx->Exec, ());
3973    }
3974 }
3975 
3976 
3977 static void GLAPIENTRY
save_PushName(GLuint name)3978 save_PushName(GLuint name)
3979 {
3980    GET_CURRENT_CONTEXT(ctx);
3981    Node *n;
3982    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3983    n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
3984    if (n) {
3985       n[1].ui = name;
3986    }
3987    if (ctx->ExecuteFlag) {
3988       CALL_PushName(ctx->Exec, (name));
3989    }
3990 }
3991 
3992 
3993 static void GLAPIENTRY
save_RasterPos4f(GLfloat x,GLfloat y,GLfloat z,GLfloat w)3994 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3995 {
3996    GET_CURRENT_CONTEXT(ctx);
3997    Node *n;
3998    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3999    n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
4000    if (n) {
4001       n[1].f = x;
4002       n[2].f = y;
4003       n[3].f = z;
4004       n[4].f = w;
4005    }
4006    if (ctx->ExecuteFlag) {
4007       CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
4008    }
4009 }
4010 
4011 static void GLAPIENTRY
save_RasterPos2d(GLdouble x,GLdouble y)4012 save_RasterPos2d(GLdouble x, GLdouble y)
4013 {
4014    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4015 }
4016 
4017 static void GLAPIENTRY
save_RasterPos2f(GLfloat x,GLfloat y)4018 save_RasterPos2f(GLfloat x, GLfloat y)
4019 {
4020    save_RasterPos4f(x, y, 0.0F, 1.0F);
4021 }
4022 
4023 static void GLAPIENTRY
save_RasterPos2i(GLint x,GLint y)4024 save_RasterPos2i(GLint x, GLint y)
4025 {
4026    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4027 }
4028 
4029 static void GLAPIENTRY
save_RasterPos2s(GLshort x,GLshort y)4030 save_RasterPos2s(GLshort x, GLshort y)
4031 {
4032    save_RasterPos4f(x, y, 0.0F, 1.0F);
4033 }
4034 
4035 static void GLAPIENTRY
save_RasterPos3d(GLdouble x,GLdouble y,GLdouble z)4036 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
4037 {
4038    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4039 }
4040 
4041 static void GLAPIENTRY
save_RasterPos3f(GLfloat x,GLfloat y,GLfloat z)4042 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
4043 {
4044    save_RasterPos4f(x, y, z, 1.0F);
4045 }
4046 
4047 static void GLAPIENTRY
save_RasterPos3i(GLint x,GLint y,GLint z)4048 save_RasterPos3i(GLint x, GLint y, GLint z)
4049 {
4050    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4051 }
4052 
4053 static void GLAPIENTRY
save_RasterPos3s(GLshort x,GLshort y,GLshort z)4054 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
4055 {
4056    save_RasterPos4f(x, y, z, 1.0F);
4057 }
4058 
4059 static void GLAPIENTRY
save_RasterPos4d(GLdouble x,GLdouble y,GLdouble z,GLdouble w)4060 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4061 {
4062    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4063 }
4064 
4065 static void GLAPIENTRY
save_RasterPos4i(GLint x,GLint y,GLint z,GLint w)4066 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
4067 {
4068    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4069 }
4070 
4071 static void GLAPIENTRY
save_RasterPos4s(GLshort x,GLshort y,GLshort z,GLshort w)4072 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
4073 {
4074    save_RasterPos4f(x, y, z, w);
4075 }
4076 
4077 static void GLAPIENTRY
save_RasterPos2dv(const GLdouble * v)4078 save_RasterPos2dv(const GLdouble * v)
4079 {
4080    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4081 }
4082 
4083 static void GLAPIENTRY
save_RasterPos2fv(const GLfloat * v)4084 save_RasterPos2fv(const GLfloat * v)
4085 {
4086    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
4087 }
4088 
4089 static void GLAPIENTRY
save_RasterPos2iv(const GLint * v)4090 save_RasterPos2iv(const GLint * v)
4091 {
4092    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4093 }
4094 
4095 static void GLAPIENTRY
save_RasterPos2sv(const GLshort * v)4096 save_RasterPos2sv(const GLshort * v)
4097 {
4098    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
4099 }
4100 
4101 static void GLAPIENTRY
save_RasterPos3dv(const GLdouble * v)4102 save_RasterPos3dv(const GLdouble * v)
4103 {
4104    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4105 }
4106 
4107 static void GLAPIENTRY
save_RasterPos3fv(const GLfloat * v)4108 save_RasterPos3fv(const GLfloat * v)
4109 {
4110    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
4111 }
4112 
4113 static void GLAPIENTRY
save_RasterPos3iv(const GLint * v)4114 save_RasterPos3iv(const GLint * v)
4115 {
4116    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4117 }
4118 
4119 static void GLAPIENTRY
save_RasterPos3sv(const GLshort * v)4120 save_RasterPos3sv(const GLshort * v)
4121 {
4122    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
4123 }
4124 
4125 static void GLAPIENTRY
save_RasterPos4dv(const GLdouble * v)4126 save_RasterPos4dv(const GLdouble * v)
4127 {
4128    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
4129                     (GLfloat) v[2], (GLfloat) v[3]);
4130 }
4131 
4132 static void GLAPIENTRY
save_RasterPos4fv(const GLfloat * v)4133 save_RasterPos4fv(const GLfloat * v)
4134 {
4135    save_RasterPos4f(v[0], v[1], v[2], v[3]);
4136 }
4137 
4138 static void GLAPIENTRY
save_RasterPos4iv(const GLint * v)4139 save_RasterPos4iv(const GLint * v)
4140 {
4141    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
4142                     (GLfloat) v[2], (GLfloat) v[3]);
4143 }
4144 
4145 static void GLAPIENTRY
save_RasterPos4sv(const GLshort * v)4146 save_RasterPos4sv(const GLshort * v)
4147 {
4148    save_RasterPos4f(v[0], v[1], v[2], v[3]);
4149 }
4150 
4151 
4152 static void GLAPIENTRY
save_PassThrough(GLfloat token)4153 save_PassThrough(GLfloat token)
4154 {
4155    GET_CURRENT_CONTEXT(ctx);
4156    Node *n;
4157    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4158    n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
4159    if (n) {
4160       n[1].f = token;
4161    }
4162    if (ctx->ExecuteFlag) {
4163       CALL_PassThrough(ctx->Exec, (token));
4164    }
4165 }
4166 
4167 
4168 static void GLAPIENTRY
save_ReadBuffer(GLenum mode)4169 save_ReadBuffer(GLenum mode)
4170 {
4171    GET_CURRENT_CONTEXT(ctx);
4172    Node *n;
4173    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4174    n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
4175    if (n) {
4176       n[1].e = mode;
4177    }
4178    if (ctx->ExecuteFlag) {
4179       CALL_ReadBuffer(ctx->Exec, (mode));
4180    }
4181 }
4182 
4183 
4184 static void GLAPIENTRY
save_Rotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)4185 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
4186 {
4187    GET_CURRENT_CONTEXT(ctx);
4188    Node *n;
4189    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4190    n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
4191    if (n) {
4192       n[1].f = angle;
4193       n[2].f = x;
4194       n[3].f = y;
4195       n[4].f = z;
4196    }
4197    if (ctx->ExecuteFlag) {
4198       CALL_Rotatef(ctx->Exec, (angle, x, y, z));
4199    }
4200 }
4201 
4202 
4203 static void GLAPIENTRY
save_Rotated(GLdouble angle,GLdouble x,GLdouble y,GLdouble z)4204 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
4205 {
4206    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
4207 }
4208 
4209 
4210 static void GLAPIENTRY
save_Scalef(GLfloat x,GLfloat y,GLfloat z)4211 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
4212 {
4213    GET_CURRENT_CONTEXT(ctx);
4214    Node *n;
4215    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4216    n = alloc_instruction(ctx, OPCODE_SCALE, 3);
4217    if (n) {
4218       n[1].f = x;
4219       n[2].f = y;
4220       n[3].f = z;
4221    }
4222    if (ctx->ExecuteFlag) {
4223       CALL_Scalef(ctx->Exec, (x, y, z));
4224    }
4225 }
4226 
4227 
4228 static void GLAPIENTRY
save_Scaled(GLdouble x,GLdouble y,GLdouble z)4229 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
4230 {
4231    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4232 }
4233 
4234 
4235 static void GLAPIENTRY
save_Scissor(GLint x,GLint y,GLsizei width,GLsizei height)4236 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
4237 {
4238    GET_CURRENT_CONTEXT(ctx);
4239    Node *n;
4240    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4241    n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
4242    if (n) {
4243       n[1].i = x;
4244       n[2].i = y;
4245       n[3].i = width;
4246       n[4].i = height;
4247    }
4248    if (ctx->ExecuteFlag) {
4249       CALL_Scissor(ctx->Exec, (x, y, width, height));
4250    }
4251 }
4252 
4253 
4254 static void GLAPIENTRY
save_ShadeModel(GLenum mode)4255 save_ShadeModel(GLenum mode)
4256 {
4257    GET_CURRENT_CONTEXT(ctx);
4258    Node *n;
4259    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
4260 
4261    if (ctx->ExecuteFlag) {
4262       CALL_ShadeModel(ctx->Exec, (mode));
4263    }
4264 
4265    /* Don't compile this call if it's a no-op.
4266     * By avoiding this state change we have a better chance of
4267     * coalescing subsequent drawing commands into one batch.
4268     */
4269    if (ctx->ListState.Current.ShadeModel == mode)
4270       return;
4271 
4272    SAVE_FLUSH_VERTICES(ctx);
4273 
4274    ctx->ListState.Current.ShadeModel = mode;
4275 
4276    n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
4277    if (n) {
4278       n[1].e = mode;
4279    }
4280 }
4281 
4282 
4283 static void GLAPIENTRY
save_StencilFunc(GLenum func,GLint ref,GLuint mask)4284 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
4285 {
4286    GET_CURRENT_CONTEXT(ctx);
4287    Node *n;
4288    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4289    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
4290    if (n) {
4291       n[1].e = func;
4292       n[2].i = ref;
4293       n[3].ui = mask;
4294    }
4295    if (ctx->ExecuteFlag) {
4296       CALL_StencilFunc(ctx->Exec, (func, ref, mask));
4297    }
4298 }
4299 
4300 
4301 static void GLAPIENTRY
save_StencilMask(GLuint mask)4302 save_StencilMask(GLuint mask)
4303 {
4304    GET_CURRENT_CONTEXT(ctx);
4305    Node *n;
4306    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4307    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
4308    if (n) {
4309       n[1].ui = mask;
4310    }
4311    if (ctx->ExecuteFlag) {
4312       CALL_StencilMask(ctx->Exec, (mask));
4313    }
4314 }
4315 
4316 
4317 static void GLAPIENTRY
save_StencilOp(GLenum fail,GLenum zfail,GLenum zpass)4318 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
4319 {
4320    GET_CURRENT_CONTEXT(ctx);
4321    Node *n;
4322    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4323    n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
4324    if (n) {
4325       n[1].e = fail;
4326       n[2].e = zfail;
4327       n[3].e = zpass;
4328    }
4329    if (ctx->ExecuteFlag) {
4330       CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
4331    }
4332 }
4333 
4334 
4335 static void GLAPIENTRY
save_StencilFuncSeparate(GLenum face,GLenum func,GLint ref,GLuint mask)4336 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
4337 {
4338    GET_CURRENT_CONTEXT(ctx);
4339    Node *n;
4340    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4341    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4342    if (n) {
4343       n[1].e = face;
4344       n[2].e = func;
4345       n[3].i = ref;
4346       n[4].ui = mask;
4347    }
4348    if (ctx->ExecuteFlag) {
4349       CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
4350    }
4351 }
4352 
4353 
4354 static void GLAPIENTRY
save_StencilFuncSeparateATI(GLenum frontfunc,GLenum backfunc,GLint ref,GLuint mask)4355 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
4356                             GLuint mask)
4357 {
4358    GET_CURRENT_CONTEXT(ctx);
4359    Node *n;
4360    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4361    /* GL_FRONT */
4362    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4363    if (n) {
4364       n[1].e = GL_FRONT;
4365       n[2].e = frontfunc;
4366       n[3].i = ref;
4367       n[4].ui = mask;
4368    }
4369    /* GL_BACK */
4370    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4371    if (n) {
4372       n[1].e = GL_BACK;
4373       n[2].e = backfunc;
4374       n[3].i = ref;
4375       n[4].ui = mask;
4376    }
4377    if (ctx->ExecuteFlag) {
4378       CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
4379       CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
4380    }
4381 }
4382 
4383 
4384 static void GLAPIENTRY
save_StencilMaskSeparate(GLenum face,GLuint mask)4385 save_StencilMaskSeparate(GLenum face, GLuint mask)
4386 {
4387    GET_CURRENT_CONTEXT(ctx);
4388    Node *n;
4389    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4390    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
4391    if (n) {
4392       n[1].e = face;
4393       n[2].ui = mask;
4394    }
4395    if (ctx->ExecuteFlag) {
4396       CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
4397    }
4398 }
4399 
4400 
4401 static void GLAPIENTRY
save_StencilOpSeparate(GLenum face,GLenum fail,GLenum zfail,GLenum zpass)4402 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
4403 {
4404    GET_CURRENT_CONTEXT(ctx);
4405    Node *n;
4406    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4407    n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
4408    if (n) {
4409       n[1].e = face;
4410       n[2].e = fail;
4411       n[3].e = zfail;
4412       n[4].e = zpass;
4413    }
4414    if (ctx->ExecuteFlag) {
4415       CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
4416    }
4417 }
4418 
4419 
4420 static void GLAPIENTRY
save_TexEnvfv(GLenum target,GLenum pname,const GLfloat * params)4421 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
4422 {
4423    GET_CURRENT_CONTEXT(ctx);
4424    Node *n;
4425    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4426    n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
4427    if (n) {
4428       n[1].e = target;
4429       n[2].e = pname;
4430       if (pname == GL_TEXTURE_ENV_COLOR) {
4431          n[3].f = params[0];
4432          n[4].f = params[1];
4433          n[5].f = params[2];
4434          n[6].f = params[3];
4435       }
4436       else {
4437          n[3].f = params[0];
4438          n[4].f = n[5].f = n[6].f = 0.0F;
4439       }
4440    }
4441    if (ctx->ExecuteFlag) {
4442       CALL_TexEnvfv(ctx->Exec, (target, pname, params));
4443    }
4444 }
4445 
4446 
4447 static void GLAPIENTRY
save_TexEnvf(GLenum target,GLenum pname,GLfloat param)4448 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
4449 {
4450    GLfloat parray[4];
4451    parray[0] = (GLfloat) param;
4452    parray[1] = parray[2] = parray[3] = 0.0F;
4453    save_TexEnvfv(target, pname, parray);
4454 }
4455 
4456 
4457 static void GLAPIENTRY
save_TexEnvi(GLenum target,GLenum pname,GLint param)4458 save_TexEnvi(GLenum target, GLenum pname, GLint param)
4459 {
4460    GLfloat p[4];
4461    p[0] = (GLfloat) param;
4462    p[1] = p[2] = p[3] = 0.0F;
4463    save_TexEnvfv(target, pname, p);
4464 }
4465 
4466 
4467 static void GLAPIENTRY
save_TexEnviv(GLenum target,GLenum pname,const GLint * param)4468 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
4469 {
4470    GLfloat p[4];
4471    if (pname == GL_TEXTURE_ENV_COLOR) {
4472       p[0] = INT_TO_FLOAT(param[0]);
4473       p[1] = INT_TO_FLOAT(param[1]);
4474       p[2] = INT_TO_FLOAT(param[2]);
4475       p[3] = INT_TO_FLOAT(param[3]);
4476    }
4477    else {
4478       p[0] = (GLfloat) param[0];
4479       p[1] = p[2] = p[3] = 0.0F;
4480    }
4481    save_TexEnvfv(target, pname, p);
4482 }
4483 
4484 
4485 static void GLAPIENTRY
save_TexGenfv(GLenum coord,GLenum pname,const GLfloat * params)4486 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
4487 {
4488    GET_CURRENT_CONTEXT(ctx);
4489    Node *n;
4490    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4491    n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
4492    if (n) {
4493       n[1].e = coord;
4494       n[2].e = pname;
4495       n[3].f = params[0];
4496       n[4].f = params[1];
4497       n[5].f = params[2];
4498       n[6].f = params[3];
4499    }
4500    if (ctx->ExecuteFlag) {
4501       CALL_TexGenfv(ctx->Exec, (coord, pname, params));
4502    }
4503 }
4504 
4505 
4506 static void GLAPIENTRY
save_TexGeniv(GLenum coord,GLenum pname,const GLint * params)4507 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
4508 {
4509    GLfloat p[4];
4510    p[0] = (GLfloat) params[0];
4511    p[1] = (GLfloat) params[1];
4512    p[2] = (GLfloat) params[2];
4513    p[3] = (GLfloat) params[3];
4514    save_TexGenfv(coord, pname, p);
4515 }
4516 
4517 
4518 static void GLAPIENTRY
save_TexGend(GLenum coord,GLenum pname,GLdouble param)4519 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
4520 {
4521    GLfloat parray[4];
4522    parray[0] = (GLfloat) param;
4523    parray[1] = parray[2] = parray[3] = 0.0F;
4524    save_TexGenfv(coord, pname, parray);
4525 }
4526 
4527 
4528 static void GLAPIENTRY
save_TexGendv(GLenum coord,GLenum pname,const GLdouble * params)4529 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
4530 {
4531    GLfloat p[4];
4532    p[0] = (GLfloat) params[0];
4533    p[1] = (GLfloat) params[1];
4534    p[2] = (GLfloat) params[2];
4535    p[3] = (GLfloat) params[3];
4536    save_TexGenfv(coord, pname, p);
4537 }
4538 
4539 
4540 static void GLAPIENTRY
save_TexGenf(GLenum coord,GLenum pname,GLfloat param)4541 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
4542 {
4543    GLfloat parray[4];
4544    parray[0] = param;
4545    parray[1] = parray[2] = parray[3] = 0.0F;
4546    save_TexGenfv(coord, pname, parray);
4547 }
4548 
4549 
4550 static void GLAPIENTRY
save_TexGeni(GLenum coord,GLenum pname,GLint param)4551 save_TexGeni(GLenum coord, GLenum pname, GLint param)
4552 {
4553    GLint parray[4];
4554    parray[0] = param;
4555    parray[1] = parray[2] = parray[3] = 0;
4556    save_TexGeniv(coord, pname, parray);
4557 }
4558 
4559 
4560 static void GLAPIENTRY
save_TexParameterfv(GLenum target,GLenum pname,const GLfloat * params)4561 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
4562 {
4563    GET_CURRENT_CONTEXT(ctx);
4564    Node *n;
4565    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4566    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
4567    if (n) {
4568       n[1].e = target;
4569       n[2].e = pname;
4570       n[3].f = params[0];
4571       n[4].f = params[1];
4572       n[5].f = params[2];
4573       n[6].f = params[3];
4574    }
4575    if (ctx->ExecuteFlag) {
4576       CALL_TexParameterfv(ctx->Exec, (target, pname, params));
4577    }
4578 }
4579 
4580 
4581 static void GLAPIENTRY
save_TexParameterf(GLenum target,GLenum pname,GLfloat param)4582 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
4583 {
4584    GLfloat parray[4];
4585    parray[0] = param;
4586    parray[1] = parray[2] = parray[3] = 0.0F;
4587    save_TexParameterfv(target, pname, parray);
4588 }
4589 
4590 
4591 static void GLAPIENTRY
save_TexParameteri(GLenum target,GLenum pname,GLint param)4592 save_TexParameteri(GLenum target, GLenum pname, GLint param)
4593 {
4594    GLfloat fparam[4];
4595    fparam[0] = (GLfloat) param;
4596    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4597    save_TexParameterfv(target, pname, fparam);
4598 }
4599 
4600 
4601 static void GLAPIENTRY
save_TexParameteriv(GLenum target,GLenum pname,const GLint * params)4602 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
4603 {
4604    GLfloat fparam[4];
4605    fparam[0] = (GLfloat) params[0];
4606    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4607    save_TexParameterfv(target, pname, fparam);
4608 }
4609 
4610 
4611 static void GLAPIENTRY
save_TexImage1D(GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4612 save_TexImage1D(GLenum target,
4613                 GLint level, GLint components,
4614                 GLsizei width, GLint border,
4615                 GLenum format, GLenum type, const GLvoid * pixels)
4616 {
4617    GET_CURRENT_CONTEXT(ctx);
4618    if (target == GL_PROXY_TEXTURE_1D) {
4619       /* don't compile, execute immediately */
4620       CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4621                                   border, format, type, pixels));
4622    }
4623    else {
4624       Node *n;
4625       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4626       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 7 + POINTER_DWORDS);
4627       if (n) {
4628          n[1].e = target;
4629          n[2].i = level;
4630          n[3].i = components;
4631          n[4].i = (GLint) width;
4632          n[5].i = border;
4633          n[6].e = format;
4634          n[7].e = type;
4635          save_pointer(&n[8],
4636                       unpack_image(ctx, 1, width, 1, 1, format, type,
4637                                    pixels, &ctx->Unpack));
4638       }
4639       if (ctx->ExecuteFlag) {
4640          CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4641                                      border, format, type, pixels));
4642       }
4643    }
4644 }
4645 
4646 
4647 static void GLAPIENTRY
save_TexImage2D(GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4648 save_TexImage2D(GLenum target,
4649                 GLint level, GLint components,
4650                 GLsizei width, GLsizei height, GLint border,
4651                 GLenum format, GLenum type, const GLvoid * pixels)
4652 {
4653    GET_CURRENT_CONTEXT(ctx);
4654    if (target == GL_PROXY_TEXTURE_2D) {
4655       /* don't compile, execute immediately */
4656       CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4657                                   height, border, format, type, pixels));
4658    }
4659    else {
4660       Node *n;
4661       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4662       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 8 + POINTER_DWORDS);
4663       if (n) {
4664          n[1].e = target;
4665          n[2].i = level;
4666          n[3].i = components;
4667          n[4].i = (GLint) width;
4668          n[5].i = (GLint) height;
4669          n[6].i = border;
4670          n[7].e = format;
4671          n[8].e = type;
4672          save_pointer(&n[9],
4673                       unpack_image(ctx, 2, width, height, 1, format, type,
4674                                    pixels, &ctx->Unpack));
4675       }
4676       if (ctx->ExecuteFlag) {
4677          CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4678                                      height, border, format, type, pixels));
4679       }
4680    }
4681 }
4682 
4683 
4684 static void GLAPIENTRY
save_TexImage3D(GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4685 save_TexImage3D(GLenum target,
4686                 GLint level, GLint internalFormat,
4687                 GLsizei width, GLsizei height, GLsizei depth,
4688                 GLint border,
4689                 GLenum format, GLenum type, const GLvoid * pixels)
4690 {
4691    GET_CURRENT_CONTEXT(ctx);
4692    if (target == GL_PROXY_TEXTURE_3D) {
4693       /* don't compile, execute immediately */
4694       CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4695                                   height, depth, border, format, type,
4696                                   pixels));
4697    }
4698    else {
4699       Node *n;
4700       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4701       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 9 + POINTER_DWORDS);
4702       if (n) {
4703          n[1].e = target;
4704          n[2].i = level;
4705          n[3].i = (GLint) internalFormat;
4706          n[4].i = (GLint) width;
4707          n[5].i = (GLint) height;
4708          n[6].i = (GLint) depth;
4709          n[7].i = border;
4710          n[8].e = format;
4711          n[9].e = type;
4712          save_pointer(&n[10],
4713                       unpack_image(ctx, 3, width, height, depth, format, type,
4714                                    pixels, &ctx->Unpack));
4715       }
4716       if (ctx->ExecuteFlag) {
4717          CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4718                                      height, depth, border, format, type,
4719                                      pixels));
4720       }
4721    }
4722 }
4723 
4724 
4725 static void GLAPIENTRY
save_TexSubImage1D(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)4726 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
4727                    GLsizei width, GLenum format, GLenum type,
4728                    const GLvoid * pixels)
4729 {
4730    GET_CURRENT_CONTEXT(ctx);
4731    Node *n;
4732 
4733    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4734 
4735    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 6 + POINTER_DWORDS);
4736    if (n) {
4737       n[1].e = target;
4738       n[2].i = level;
4739       n[3].i = xoffset;
4740       n[4].i = (GLint) width;
4741       n[5].e = format;
4742       n[6].e = type;
4743       save_pointer(&n[7],
4744                    unpack_image(ctx, 1, width, 1, 1, format, type,
4745                                 pixels, &ctx->Unpack));
4746    }
4747    if (ctx->ExecuteFlag) {
4748       CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
4749                                      format, type, pixels));
4750    }
4751 }
4752 
4753 
4754 static void GLAPIENTRY
save_TexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)4755 save_TexSubImage2D(GLenum target, GLint level,
4756                    GLint xoffset, GLint yoffset,
4757                    GLsizei width, GLsizei height,
4758                    GLenum format, GLenum type, const GLvoid * pixels)
4759 {
4760    GET_CURRENT_CONTEXT(ctx);
4761    Node *n;
4762 
4763    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4764 
4765    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 8 + POINTER_DWORDS);
4766    if (n) {
4767       n[1].e = target;
4768       n[2].i = level;
4769       n[3].i = xoffset;
4770       n[4].i = yoffset;
4771       n[5].i = (GLint) width;
4772       n[6].i = (GLint) height;
4773       n[7].e = format;
4774       n[8].e = type;
4775       save_pointer(&n[9],
4776                    unpack_image(ctx, 2, width, height, 1, format, type,
4777                                 pixels, &ctx->Unpack));
4778    }
4779    if (ctx->ExecuteFlag) {
4780       CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
4781                                      width, height, format, type, pixels));
4782    }
4783 }
4784 
4785 
4786 static void GLAPIENTRY
save_TexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * pixels)4787 save_TexSubImage3D(GLenum target, GLint level,
4788                    GLint xoffset, GLint yoffset, GLint zoffset,
4789                    GLsizei width, GLsizei height, GLsizei depth,
4790                    GLenum format, GLenum type, const GLvoid * pixels)
4791 {
4792    GET_CURRENT_CONTEXT(ctx);
4793    Node *n;
4794 
4795    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4796 
4797    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 10 + POINTER_DWORDS);
4798    if (n) {
4799       n[1].e = target;
4800       n[2].i = level;
4801       n[3].i = xoffset;
4802       n[4].i = yoffset;
4803       n[5].i = zoffset;
4804       n[6].i = (GLint) width;
4805       n[7].i = (GLint) height;
4806       n[8].i = (GLint) depth;
4807       n[9].e = format;
4808       n[10].e = type;
4809       save_pointer(&n[11],
4810                    unpack_image(ctx, 3, width, height, depth, format, type,
4811                                 pixels, &ctx->Unpack));
4812    }
4813    if (ctx->ExecuteFlag) {
4814       CALL_TexSubImage3D(ctx->Exec, (target, level,
4815                                      xoffset, yoffset, zoffset,
4816                                      width, height, depth, format, type,
4817                                      pixels));
4818    }
4819 }
4820 
4821 
4822 static void GLAPIENTRY
save_Translatef(GLfloat x,GLfloat y,GLfloat z)4823 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
4824 {
4825    GET_CURRENT_CONTEXT(ctx);
4826    Node *n;
4827    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4828    n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
4829    if (n) {
4830       n[1].f = x;
4831       n[2].f = y;
4832       n[3].f = z;
4833    }
4834    if (ctx->ExecuteFlag) {
4835       CALL_Translatef(ctx->Exec, (x, y, z));
4836    }
4837 }
4838 
4839 
4840 static void GLAPIENTRY
save_Translated(GLdouble x,GLdouble y,GLdouble z)4841 save_Translated(GLdouble x, GLdouble y, GLdouble z)
4842 {
4843    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4844 }
4845 
4846 
4847 
4848 static void GLAPIENTRY
save_Viewport(GLint x,GLint y,GLsizei width,GLsizei height)4849 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
4850 {
4851    GET_CURRENT_CONTEXT(ctx);
4852    Node *n;
4853    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4854    n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
4855    if (n) {
4856       n[1].i = x;
4857       n[2].i = y;
4858       n[3].i = (GLint) width;
4859       n[4].i = (GLint) height;
4860    }
4861    if (ctx->ExecuteFlag) {
4862       CALL_Viewport(ctx->Exec, (x, y, width, height));
4863    }
4864 }
4865 
4866 static void GLAPIENTRY
save_ViewportIndexedf(GLuint index,GLfloat x,GLfloat y,GLfloat width,GLfloat height)4867 save_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat width,
4868                       GLfloat height)
4869 {
4870    GET_CURRENT_CONTEXT(ctx);
4871    Node *n;
4872    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4873    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_F, 5);
4874    if (n) {
4875       n[1].ui = index;
4876       n[2].f = x;
4877       n[3].f = y;
4878       n[4].f = width;
4879       n[5].f = height;
4880    }
4881    if (ctx->ExecuteFlag) {
4882       CALL_ViewportIndexedf(ctx->Exec, (index, x, y, width, height));
4883    }
4884 }
4885 
4886 static void GLAPIENTRY
save_ViewportIndexedfv(GLuint index,const GLfloat * v)4887 save_ViewportIndexedfv(GLuint index, const GLfloat *v)
4888 {
4889    GET_CURRENT_CONTEXT(ctx);
4890    Node *n;
4891    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4892    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_FV, 5);
4893    if (n) {
4894       n[1].ui = index;
4895       n[2].f = v[0];
4896       n[3].f = v[1];
4897       n[4].f = v[2];
4898       n[5].f = v[3];
4899    }
4900    if (ctx->ExecuteFlag) {
4901       CALL_ViewportIndexedfv(ctx->Exec, (index, v));
4902    }
4903 }
4904 
4905 static void GLAPIENTRY
save_ViewportArrayv(GLuint first,GLsizei count,const GLfloat * v)4906 save_ViewportArrayv(GLuint first, GLsizei count, const GLfloat *v)
4907 {
4908    GET_CURRENT_CONTEXT(ctx);
4909    Node *n;
4910    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4911    n = alloc_instruction(ctx, OPCODE_VIEWPORT_ARRAY_V, 2 + POINTER_DWORDS);
4912    if (n) {
4913       n[1].ui = first;
4914       n[2].si = count;
4915       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
4916    }
4917    if (ctx->ExecuteFlag) {
4918       CALL_ViewportArrayv(ctx->Exec, (first, count, v));
4919    }
4920 }
4921 
4922 static void GLAPIENTRY
save_ScissorIndexed(GLuint index,GLint left,GLint bottom,GLsizei width,GLsizei height)4923 save_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width,
4924                     GLsizei height)
4925 {
4926    GET_CURRENT_CONTEXT(ctx);
4927    Node *n;
4928    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4929    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED, 5);
4930    if (n) {
4931       n[1].ui = index;
4932       n[2].i = left;
4933       n[3].i = bottom;
4934       n[4].si = width;
4935       n[5].si = height;
4936    }
4937    if (ctx->ExecuteFlag) {
4938       CALL_ScissorIndexed(ctx->Exec, (index, left, bottom, width, height));
4939    }
4940 }
4941 
4942 static void GLAPIENTRY
save_ScissorIndexedv(GLuint index,const GLint * v)4943 save_ScissorIndexedv(GLuint index, const GLint *v)
4944 {
4945    GET_CURRENT_CONTEXT(ctx);
4946    Node *n;
4947    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4948    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED_V, 5);
4949    if (n) {
4950       n[1].ui = index;
4951       n[2].i = v[0];
4952       n[3].i = v[1];
4953       n[4].si = v[2];
4954       n[5].si = v[3];
4955    }
4956    if (ctx->ExecuteFlag) {
4957       CALL_ScissorIndexedv(ctx->Exec, (index, v));
4958    }
4959 }
4960 
4961 static void GLAPIENTRY
save_ScissorArrayv(GLuint first,GLsizei count,const GLint * v)4962 save_ScissorArrayv(GLuint first, GLsizei count, const GLint *v)
4963 {
4964    GET_CURRENT_CONTEXT(ctx);
4965    Node *n;
4966    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4967    n = alloc_instruction(ctx, OPCODE_SCISSOR_ARRAY_V, 2 + POINTER_DWORDS);
4968    if (n) {
4969       n[1].ui = first;
4970       n[2].si = count;
4971       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint)));
4972    }
4973    if (ctx->ExecuteFlag) {
4974       CALL_ScissorArrayv(ctx->Exec, (first, count, v));
4975    }
4976 }
4977 
4978 static void GLAPIENTRY
save_DepthRangeIndexed(GLuint index,GLclampd n,GLclampd f)4979 save_DepthRangeIndexed(GLuint index, GLclampd n, GLclampd f)
4980 {
4981    GET_CURRENT_CONTEXT(ctx);
4982    Node *node;
4983    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4984    node = alloc_instruction(ctx, OPCODE_DEPTH_INDEXED, 3);
4985    if (node) {
4986       node[1].ui = index;
4987       /* Mesa stores these as floats internally so we deliberately convert
4988        * them to a float here.
4989        */
4990       node[2].f = n;
4991       node[3].f = f;
4992    }
4993    if (ctx->ExecuteFlag) {
4994       CALL_DepthRangeIndexed(ctx->Exec, (index, n, f));
4995    }
4996 }
4997 
4998 static void GLAPIENTRY
save_DepthRangeArrayv(GLuint first,GLsizei count,const GLclampd * v)4999 save_DepthRangeArrayv(GLuint first, GLsizei count, const GLclampd *v)
5000 {
5001    GET_CURRENT_CONTEXT(ctx);
5002    Node *n;
5003    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5004    n = alloc_instruction(ctx, OPCODE_DEPTH_ARRAY_V, 2 + POINTER_DWORDS);
5005    if (n) {
5006       n[1].ui = first;
5007       n[2].si = count;
5008       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLclampd)));
5009    }
5010    if (ctx->ExecuteFlag) {
5011       CALL_DepthRangeArrayv(ctx->Exec, (first, count, v));
5012    }
5013 }
5014 
5015 static void GLAPIENTRY
save_WindowPos4fMESA(GLfloat x,GLfloat y,GLfloat z,GLfloat w)5016 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5017 {
5018    GET_CURRENT_CONTEXT(ctx);
5019    Node *n;
5020    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5021    n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
5022    if (n) {
5023       n[1].f = x;
5024       n[2].f = y;
5025       n[3].f = z;
5026       n[4].f = w;
5027    }
5028    if (ctx->ExecuteFlag) {
5029       CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
5030    }
5031 }
5032 
5033 static void GLAPIENTRY
save_WindowPos2dMESA(GLdouble x,GLdouble y)5034 save_WindowPos2dMESA(GLdouble x, GLdouble y)
5035 {
5036    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
5037 }
5038 
5039 static void GLAPIENTRY
save_WindowPos2fMESA(GLfloat x,GLfloat y)5040 save_WindowPos2fMESA(GLfloat x, GLfloat y)
5041 {
5042    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
5043 }
5044 
5045 static void GLAPIENTRY
save_WindowPos2iMESA(GLint x,GLint y)5046 save_WindowPos2iMESA(GLint x, GLint y)
5047 {
5048    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
5049 }
5050 
5051 static void GLAPIENTRY
save_WindowPos2sMESA(GLshort x,GLshort y)5052 save_WindowPos2sMESA(GLshort x, GLshort y)
5053 {
5054    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
5055 }
5056 
5057 static void GLAPIENTRY
save_WindowPos3dMESA(GLdouble x,GLdouble y,GLdouble z)5058 save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
5059 {
5060    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
5061 }
5062 
5063 static void GLAPIENTRY
save_WindowPos3fMESA(GLfloat x,GLfloat y,GLfloat z)5064 save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
5065 {
5066    save_WindowPos4fMESA(x, y, z, 1.0F);
5067 }
5068 
5069 static void GLAPIENTRY
save_WindowPos3iMESA(GLint x,GLint y,GLint z)5070 save_WindowPos3iMESA(GLint x, GLint y, GLint z)
5071 {
5072    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
5073 }
5074 
5075 static void GLAPIENTRY
save_WindowPos3sMESA(GLshort x,GLshort y,GLshort z)5076 save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
5077 {
5078    save_WindowPos4fMESA(x, y, z, 1.0F);
5079 }
5080 
5081 static void GLAPIENTRY
save_WindowPos4dMESA(GLdouble x,GLdouble y,GLdouble z,GLdouble w)5082 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5083 {
5084    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
5085 }
5086 
5087 static void GLAPIENTRY
save_WindowPos4iMESA(GLint x,GLint y,GLint z,GLint w)5088 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
5089 {
5090    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
5091 }
5092 
5093 static void GLAPIENTRY
save_WindowPos4sMESA(GLshort x,GLshort y,GLshort z,GLshort w)5094 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
5095 {
5096    save_WindowPos4fMESA(x, y, z, w);
5097 }
5098 
5099 static void GLAPIENTRY
save_WindowPos2dvMESA(const GLdouble * v)5100 save_WindowPos2dvMESA(const GLdouble * v)
5101 {
5102    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
5103 }
5104 
5105 static void GLAPIENTRY
save_WindowPos2fvMESA(const GLfloat * v)5106 save_WindowPos2fvMESA(const GLfloat * v)
5107 {
5108    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
5109 }
5110 
5111 static void GLAPIENTRY
save_WindowPos2ivMESA(const GLint * v)5112 save_WindowPos2ivMESA(const GLint * v)
5113 {
5114    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
5115 }
5116 
5117 static void GLAPIENTRY
save_WindowPos2svMESA(const GLshort * v)5118 save_WindowPos2svMESA(const GLshort * v)
5119 {
5120    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
5121 }
5122 
5123 static void GLAPIENTRY
save_WindowPos3dvMESA(const GLdouble * v)5124 save_WindowPos3dvMESA(const GLdouble * v)
5125 {
5126    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
5127 }
5128 
5129 static void GLAPIENTRY
save_WindowPos3fvMESA(const GLfloat * v)5130 save_WindowPos3fvMESA(const GLfloat * v)
5131 {
5132    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
5133 }
5134 
5135 static void GLAPIENTRY
save_WindowPos3ivMESA(const GLint * v)5136 save_WindowPos3ivMESA(const GLint * v)
5137 {
5138    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
5139 }
5140 
5141 static void GLAPIENTRY
save_WindowPos3svMESA(const GLshort * v)5142 save_WindowPos3svMESA(const GLshort * v)
5143 {
5144    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
5145 }
5146 
5147 static void GLAPIENTRY
save_WindowPos4dvMESA(const GLdouble * v)5148 save_WindowPos4dvMESA(const GLdouble * v)
5149 {
5150    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
5151                         (GLfloat) v[2], (GLfloat) v[3]);
5152 }
5153 
5154 static void GLAPIENTRY
save_WindowPos4fvMESA(const GLfloat * v)5155 save_WindowPos4fvMESA(const GLfloat * v)
5156 {
5157    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
5158 }
5159 
5160 static void GLAPIENTRY
save_WindowPos4ivMESA(const GLint * v)5161 save_WindowPos4ivMESA(const GLint * v)
5162 {
5163    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
5164                         (GLfloat) v[2], (GLfloat) v[3]);
5165 }
5166 
5167 static void GLAPIENTRY
save_WindowPos4svMESA(const GLshort * v)5168 save_WindowPos4svMESA(const GLshort * v)
5169 {
5170    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
5171 }
5172 
5173 
5174 
5175 /* GL_ARB_multitexture */
5176 static void GLAPIENTRY
save_ActiveTextureARB(GLenum target)5177 save_ActiveTextureARB(GLenum target)
5178 {
5179    GET_CURRENT_CONTEXT(ctx);
5180    Node *n;
5181    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5182    n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
5183    if (n) {
5184       n[1].e = target;
5185    }
5186    if (ctx->ExecuteFlag) {
5187       CALL_ActiveTexture(ctx->Exec, (target));
5188    }
5189 }
5190 
5191 
5192 /* GL_ARB_transpose_matrix */
5193 
5194 static void GLAPIENTRY
save_LoadTransposeMatrixdARB(const GLdouble m[16])5195 save_LoadTransposeMatrixdARB(const GLdouble m[16])
5196 {
5197    GLfloat tm[16];
5198    _math_transposefd(tm, m);
5199    save_LoadMatrixf(tm);
5200 }
5201 
5202 
5203 static void GLAPIENTRY
save_LoadTransposeMatrixfARB(const GLfloat m[16])5204 save_LoadTransposeMatrixfARB(const GLfloat m[16])
5205 {
5206    GLfloat tm[16];
5207    _math_transposef(tm, m);
5208    save_LoadMatrixf(tm);
5209 }
5210 
5211 
5212 static void GLAPIENTRY
save_MultTransposeMatrixdARB(const GLdouble m[16])5213 save_MultTransposeMatrixdARB(const GLdouble m[16])
5214 {
5215    GLfloat tm[16];
5216    _math_transposefd(tm, m);
5217    save_MultMatrixf(tm);
5218 }
5219 
5220 
5221 static void GLAPIENTRY
save_MultTransposeMatrixfARB(const GLfloat m[16])5222 save_MultTransposeMatrixfARB(const GLfloat m[16])
5223 {
5224    GLfloat tm[16];
5225    _math_transposef(tm, m);
5226    save_MultMatrixf(tm);
5227 }
5228 
copy_data(const GLvoid * data,GLsizei size,const char * func)5229 static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func)
5230 {
5231    GET_CURRENT_CONTEXT(ctx);
5232    GLvoid *image;
5233 
5234    if (!data)
5235       return NULL;
5236 
5237    image = malloc(size);
5238    if (!image) {
5239       _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
5240       return NULL;
5241    }
5242    memcpy(image, data, size);
5243 
5244    return image;
5245 }
5246 
5247 
5248 /* GL_ARB_texture_compression */
5249 static void GLAPIENTRY
save_CompressedTexImage1DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)5250 save_CompressedTexImage1DARB(GLenum target, GLint level,
5251                              GLenum internalFormat, GLsizei width,
5252                              GLint border, GLsizei imageSize,
5253                              const GLvoid * data)
5254 {
5255    GET_CURRENT_CONTEXT(ctx);
5256    if (target == GL_PROXY_TEXTURE_1D) {
5257       /* don't compile, execute immediately */
5258       CALL_CompressedTexImage1D(ctx->Exec, (target, level, internalFormat,
5259                                                width, border, imageSize,
5260                                                data));
5261    }
5262    else {
5263       Node *n;
5264       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5265 
5266       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D,
5267                             6 + POINTER_DWORDS);
5268       if (n) {
5269          n[1].e = target;
5270          n[2].i = level;
5271          n[3].e = internalFormat;
5272          n[4].i = (GLint) width;
5273          n[5].i = border;
5274          n[6].i = imageSize;
5275          save_pointer(&n[7],
5276                       copy_data(data, imageSize, "glCompressedTexImage1DARB"));
5277       }
5278       if (ctx->ExecuteFlag) {
5279          CALL_CompressedTexImage1D(ctx->Exec,
5280                                       (target, level, internalFormat, width,
5281                                        border, imageSize, data));
5282       }
5283    }
5284 }
5285 
5286 
5287 static void GLAPIENTRY
save_CompressedTexImage2DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)5288 save_CompressedTexImage2DARB(GLenum target, GLint level,
5289                              GLenum internalFormat, GLsizei width,
5290                              GLsizei height, GLint border, GLsizei imageSize,
5291                              const GLvoid * data)
5292 {
5293    GET_CURRENT_CONTEXT(ctx);
5294    if (target == GL_PROXY_TEXTURE_2D) {
5295       /* don't compile, execute immediately */
5296       CALL_CompressedTexImage2D(ctx->Exec, (target, level, internalFormat,
5297                                                width, height, border,
5298                                                imageSize, data));
5299    }
5300    else {
5301       Node *n;
5302       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5303 
5304       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D,
5305                             7 + POINTER_DWORDS);
5306       if (n) {
5307          n[1].e = target;
5308          n[2].i = level;
5309          n[3].e = internalFormat;
5310          n[4].i = (GLint) width;
5311          n[5].i = (GLint) height;
5312          n[6].i = border;
5313          n[7].i = imageSize;
5314          save_pointer(&n[8],
5315                       copy_data(data, imageSize, "glCompressedTexImage2DARB"));
5316       }
5317       if (ctx->ExecuteFlag) {
5318          CALL_CompressedTexImage2D(ctx->Exec,
5319                                       (target, level, internalFormat, width,
5320                                        height, border, imageSize, data));
5321       }
5322    }
5323 }
5324 
5325 
5326 static void GLAPIENTRY
save_CompressedTexImage3DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)5327 save_CompressedTexImage3DARB(GLenum target, GLint level,
5328                              GLenum internalFormat, GLsizei width,
5329                              GLsizei height, GLsizei depth, GLint border,
5330                              GLsizei imageSize, const GLvoid * data)
5331 {
5332    GET_CURRENT_CONTEXT(ctx);
5333    if (target == GL_PROXY_TEXTURE_3D) {
5334       /* don't compile, execute immediately */
5335       CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat,
5336                                                width, height, depth, border,
5337                                                imageSize, data));
5338    }
5339    else {
5340       Node *n;
5341       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5342 
5343       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D,
5344                             8 + POINTER_DWORDS);
5345       if (n) {
5346          n[1].e = target;
5347          n[2].i = level;
5348          n[3].e = internalFormat;
5349          n[4].i = (GLint) width;
5350          n[5].i = (GLint) height;
5351          n[6].i = (GLint) depth;
5352          n[7].i = border;
5353          n[8].i = imageSize;
5354          save_pointer(&n[9],
5355                       copy_data(data, imageSize, "glCompressedTexImage3DARB"));
5356       }
5357       if (ctx->ExecuteFlag) {
5358          CALL_CompressedTexImage3D(ctx->Exec,
5359                                       (target, level, internalFormat, width,
5360                                        height, depth, border, imageSize,
5361                                        data));
5362       }
5363    }
5364 }
5365 
5366 
5367 static void GLAPIENTRY
save_CompressedTexSubImage1DARB(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)5368 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
5369                                 GLsizei width, GLenum format,
5370                                 GLsizei imageSize, const GLvoid * data)
5371 {
5372    Node *n;
5373    GET_CURRENT_CONTEXT(ctx);
5374    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5375 
5376    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
5377                          6 + POINTER_DWORDS);
5378    if (n) {
5379       n[1].e = target;
5380       n[2].i = level;
5381       n[3].i = xoffset;
5382       n[4].i = (GLint) width;
5383       n[5].e = format;
5384       n[6].i = imageSize;
5385       save_pointer(&n[7],
5386                    copy_data(data, imageSize, "glCompressedTexSubImage1DARB"));
5387    }
5388    if (ctx->ExecuteFlag) {
5389       CALL_CompressedTexSubImage1D(ctx->Exec, (target, level, xoffset,
5390                                                   width, format, imageSize,
5391                                                   data));
5392    }
5393 }
5394 
5395 
5396 static void GLAPIENTRY
save_CompressedTexSubImage2DARB(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)5397 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
5398                                 GLint yoffset, GLsizei width, GLsizei height,
5399                                 GLenum format, GLsizei imageSize,
5400                                 const GLvoid * data)
5401 {
5402    Node *n;
5403    GET_CURRENT_CONTEXT(ctx);
5404    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5405 
5406    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
5407                          8 + POINTER_DWORDS);
5408    if (n) {
5409       n[1].e = target;
5410       n[2].i = level;
5411       n[3].i = xoffset;
5412       n[4].i = yoffset;
5413       n[5].i = (GLint) width;
5414       n[6].i = (GLint) height;
5415       n[7].e = format;
5416       n[8].i = imageSize;
5417       save_pointer(&n[9],
5418                    copy_data(data, imageSize, "glCompressedTexSubImage2DARB"));
5419    }
5420    if (ctx->ExecuteFlag) {
5421       CALL_CompressedTexSubImage2D(ctx->Exec,
5422                                       (target, level, xoffset, yoffset, width,
5423                                        height, format, imageSize, data));
5424    }
5425 }
5426 
5427 
5428 static void GLAPIENTRY
save_CompressedTexSubImage3DARB(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const GLvoid * data)5429 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
5430                                 GLint yoffset, GLint zoffset, GLsizei width,
5431                                 GLsizei height, GLsizei depth, GLenum format,
5432                                 GLsizei imageSize, const GLvoid * data)
5433 {
5434    Node *n;
5435    GET_CURRENT_CONTEXT(ctx);
5436    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5437 
5438    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
5439                          10 + POINTER_DWORDS);
5440    if (n) {
5441       n[1].e = target;
5442       n[2].i = level;
5443       n[3].i = xoffset;
5444       n[4].i = yoffset;
5445       n[5].i = zoffset;
5446       n[6].i = (GLint) width;
5447       n[7].i = (GLint) height;
5448       n[8].i = (GLint) depth;
5449       n[9].e = format;
5450       n[10].i = imageSize;
5451       save_pointer(&n[11],
5452                    copy_data(data, imageSize, "glCompressedTexSubImage3DARB"));
5453    }
5454    if (ctx->ExecuteFlag) {
5455       CALL_CompressedTexSubImage3D(ctx->Exec,
5456                                       (target, level, xoffset, yoffset,
5457                                        zoffset, width, height, depth, format,
5458                                        imageSize, data));
5459    }
5460 }
5461 
5462 
5463 /* GL_ARB_multisample */
5464 static void GLAPIENTRY
save_SampleCoverageARB(GLclampf value,GLboolean invert)5465 save_SampleCoverageARB(GLclampf value, GLboolean invert)
5466 {
5467    GET_CURRENT_CONTEXT(ctx);
5468    Node *n;
5469    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5470    n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
5471    if (n) {
5472       n[1].f = value;
5473       n[2].b = invert;
5474    }
5475    if (ctx->ExecuteFlag) {
5476       CALL_SampleCoverage(ctx->Exec, (value, invert));
5477    }
5478 }
5479 
5480 
5481 /*
5482  * GL_ARB_vertex_program
5483  */
5484 static void GLAPIENTRY
save_BindProgramARB(GLenum target,GLuint id)5485 save_BindProgramARB(GLenum target, GLuint id)
5486 {
5487    GET_CURRENT_CONTEXT(ctx);
5488    Node *n;
5489    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5490    n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_ARB, 2);
5491    if (n) {
5492       n[1].e = target;
5493       n[2].ui = id;
5494    }
5495    if (ctx->ExecuteFlag) {
5496       CALL_BindProgramARB(ctx->Exec, (target, id));
5497    }
5498 }
5499 
5500 static void GLAPIENTRY
save_ProgramEnvParameter4fARB(GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5501 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
5502                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5503 {
5504    GET_CURRENT_CONTEXT(ctx);
5505    Node *n;
5506    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5507    n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5508    if (n) {
5509       n[1].e = target;
5510       n[2].ui = index;
5511       n[3].f = x;
5512       n[4].f = y;
5513       n[5].f = z;
5514       n[6].f = w;
5515    }
5516    if (ctx->ExecuteFlag) {
5517       CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5518    }
5519 }
5520 
5521 
5522 static void GLAPIENTRY
save_ProgramEnvParameter4fvARB(GLenum target,GLuint index,const GLfloat * params)5523 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
5524                                const GLfloat *params)
5525 {
5526    save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
5527                                  params[2], params[3]);
5528 }
5529 
5530 
5531 static void GLAPIENTRY
save_ProgramEnvParameters4fvEXT(GLenum target,GLuint index,GLsizei count,const GLfloat * params)5532 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5533                                 const GLfloat * params)
5534 {
5535    GET_CURRENT_CONTEXT(ctx);
5536    Node *n;
5537    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5538 
5539    if (count > 0) {
5540       GLint i;
5541       const GLfloat * p = params;
5542 
5543       for (i = 0 ; i < count ; i++) {
5544          n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5545          if (n) {
5546             n[1].e = target;
5547             n[2].ui = index;
5548             n[3].f = p[0];
5549             n[4].f = p[1];
5550             n[5].f = p[2];
5551             n[6].f = p[3];
5552             p += 4;
5553          }
5554       }
5555    }
5556 
5557    if (ctx->ExecuteFlag) {
5558       CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
5559    }
5560 }
5561 
5562 
5563 static void GLAPIENTRY
save_ProgramEnvParameter4dARB(GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)5564 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
5565                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5566 {
5567    save_ProgramEnvParameter4fARB(target, index,
5568                                  (GLfloat) x,
5569                                  (GLfloat) y, (GLfloat) z, (GLfloat) w);
5570 }
5571 
5572 
5573 static void GLAPIENTRY
save_ProgramEnvParameter4dvARB(GLenum target,GLuint index,const GLdouble * params)5574 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
5575                                const GLdouble *params)
5576 {
5577    save_ProgramEnvParameter4fARB(target, index,
5578                                  (GLfloat) params[0],
5579                                  (GLfloat) params[1],
5580                                  (GLfloat) params[2], (GLfloat) params[3]);
5581 }
5582 
5583 
5584 static void GLAPIENTRY
save_ProgramLocalParameter4fARB(GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5585 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
5586                                 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5587 {
5588    GET_CURRENT_CONTEXT(ctx);
5589    Node *n;
5590    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5591    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5592    if (n) {
5593       n[1].e = target;
5594       n[2].ui = index;
5595       n[3].f = x;
5596       n[4].f = y;
5597       n[5].f = z;
5598       n[6].f = w;
5599    }
5600    if (ctx->ExecuteFlag) {
5601       CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5602    }
5603 }
5604 
5605 
5606 static void GLAPIENTRY
save_ProgramLocalParameter4fvARB(GLenum target,GLuint index,const GLfloat * params)5607 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
5608                                  const GLfloat *params)
5609 {
5610    GET_CURRENT_CONTEXT(ctx);
5611    Node *n;
5612    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5613    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5614    if (n) {
5615       n[1].e = target;
5616       n[2].ui = index;
5617       n[3].f = params[0];
5618       n[4].f = params[1];
5619       n[5].f = params[2];
5620       n[6].f = params[3];
5621    }
5622    if (ctx->ExecuteFlag) {
5623       CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
5624    }
5625 }
5626 
5627 
5628 static void GLAPIENTRY
save_ProgramLocalParameters4fvEXT(GLenum target,GLuint index,GLsizei count,const GLfloat * params)5629 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5630                                   const GLfloat *params)
5631 {
5632    GET_CURRENT_CONTEXT(ctx);
5633    Node *n;
5634    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5635 
5636    if (count > 0) {
5637       GLint i;
5638       const GLfloat * p = params;
5639 
5640       for (i = 0 ; i < count ; i++) {
5641          n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5642          if (n) {
5643             n[1].e = target;
5644             n[2].ui = index;
5645             n[3].f = p[0];
5646             n[4].f = p[1];
5647             n[5].f = p[2];
5648             n[6].f = p[3];
5649             p += 4;
5650          }
5651       }
5652    }
5653 
5654    if (ctx->ExecuteFlag) {
5655       CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
5656    }
5657 }
5658 
5659 
5660 static void GLAPIENTRY
save_ProgramLocalParameter4dARB(GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)5661 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
5662                                 GLdouble x, GLdouble y,
5663                                 GLdouble z, GLdouble w)
5664 {
5665    GET_CURRENT_CONTEXT(ctx);
5666    Node *n;
5667    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5668    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5669    if (n) {
5670       n[1].e = target;
5671       n[2].ui = index;
5672       n[3].f = (GLfloat) x;
5673       n[4].f = (GLfloat) y;
5674       n[5].f = (GLfloat) z;
5675       n[6].f = (GLfloat) w;
5676    }
5677    if (ctx->ExecuteFlag) {
5678       CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
5679    }
5680 }
5681 
5682 
5683 static void GLAPIENTRY
save_ProgramLocalParameter4dvARB(GLenum target,GLuint index,const GLdouble * params)5684 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
5685                                  const GLdouble *params)
5686 {
5687    GET_CURRENT_CONTEXT(ctx);
5688    Node *n;
5689    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5690    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5691    if (n) {
5692       n[1].e = target;
5693       n[2].ui = index;
5694       n[3].f = (GLfloat) params[0];
5695       n[4].f = (GLfloat) params[1];
5696       n[5].f = (GLfloat) params[2];
5697       n[6].f = (GLfloat) params[3];
5698    }
5699    if (ctx->ExecuteFlag) {
5700       CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
5701    }
5702 }
5703 
5704 
5705 /* GL_EXT_stencil_two_side */
5706 static void GLAPIENTRY
save_ActiveStencilFaceEXT(GLenum face)5707 save_ActiveStencilFaceEXT(GLenum face)
5708 {
5709    GET_CURRENT_CONTEXT(ctx);
5710    Node *n;
5711    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5712    n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
5713    if (n) {
5714       n[1].e = face;
5715    }
5716    if (ctx->ExecuteFlag) {
5717       CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
5718    }
5719 }
5720 
5721 
5722 /* GL_EXT_depth_bounds_test */
5723 static void GLAPIENTRY
save_DepthBoundsEXT(GLclampd zmin,GLclampd zmax)5724 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
5725 {
5726    GET_CURRENT_CONTEXT(ctx);
5727    Node *n;
5728    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5729    n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
5730    if (n) {
5731       n[1].f = (GLfloat) zmin;
5732       n[2].f = (GLfloat) zmax;
5733    }
5734    if (ctx->ExecuteFlag) {
5735       CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
5736    }
5737 }
5738 
5739 
5740 
5741 static void GLAPIENTRY
save_ProgramStringARB(GLenum target,GLenum format,GLsizei len,const GLvoid * string)5742 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
5743                       const GLvoid * string)
5744 {
5745    GET_CURRENT_CONTEXT(ctx);
5746    Node *n;
5747 
5748    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5749 
5750    n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 3 + POINTER_DWORDS);
5751    if (n) {
5752       GLubyte *programCopy = malloc(len);
5753       if (!programCopy) {
5754          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5755          return;
5756       }
5757       memcpy(programCopy, string, len);
5758       n[1].e = target;
5759       n[2].e = format;
5760       n[3].i = len;
5761       save_pointer(&n[4], programCopy);
5762    }
5763    if (ctx->ExecuteFlag) {
5764       CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
5765    }
5766 }
5767 
5768 
5769 static void GLAPIENTRY
save_BeginQueryARB(GLenum target,GLuint id)5770 save_BeginQueryARB(GLenum target, GLuint id)
5771 {
5772    GET_CURRENT_CONTEXT(ctx);
5773    Node *n;
5774    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5775    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
5776    if (n) {
5777       n[1].e = target;
5778       n[2].ui = id;
5779    }
5780    if (ctx->ExecuteFlag) {
5781       CALL_BeginQuery(ctx->Exec, (target, id));
5782    }
5783 }
5784 
5785 static void GLAPIENTRY
save_EndQueryARB(GLenum target)5786 save_EndQueryARB(GLenum target)
5787 {
5788    GET_CURRENT_CONTEXT(ctx);
5789    Node *n;
5790    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5791    n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
5792    if (n) {
5793       n[1].e = target;
5794    }
5795    if (ctx->ExecuteFlag) {
5796       CALL_EndQuery(ctx->Exec, (target));
5797    }
5798 }
5799 
5800 static void GLAPIENTRY
save_QueryCounter(GLuint id,GLenum target)5801 save_QueryCounter(GLuint id, GLenum target)
5802 {
5803    GET_CURRENT_CONTEXT(ctx);
5804    Node *n;
5805    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5806    n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2);
5807    if (n) {
5808       n[1].ui = id;
5809       n[2].e = target;
5810    }
5811    if (ctx->ExecuteFlag) {
5812       CALL_QueryCounter(ctx->Exec, (id, target));
5813    }
5814 }
5815 
5816 static void GLAPIENTRY
save_BeginQueryIndexed(GLenum target,GLuint index,GLuint id)5817 save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
5818 {
5819    GET_CURRENT_CONTEXT(ctx);
5820    Node *n;
5821    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5822    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3);
5823    if (n) {
5824       n[1].e = target;
5825       n[2].ui = index;
5826       n[3].ui = id;
5827    }
5828    if (ctx->ExecuteFlag) {
5829       CALL_BeginQueryIndexed(ctx->Exec, (target, index, id));
5830    }
5831 }
5832 
5833 static void GLAPIENTRY
save_EndQueryIndexed(GLenum target,GLuint index)5834 save_EndQueryIndexed(GLenum target, GLuint index)
5835 {
5836    GET_CURRENT_CONTEXT(ctx);
5837    Node *n;
5838    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5839    n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2);
5840    if (n) {
5841       n[1].e = target;
5842       n[2].ui = index;
5843    }
5844    if (ctx->ExecuteFlag) {
5845       CALL_EndQueryIndexed(ctx->Exec, (target, index));
5846    }
5847 }
5848 
5849 
5850 static void GLAPIENTRY
save_DrawBuffersARB(GLsizei count,const GLenum * buffers)5851 save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
5852 {
5853    GET_CURRENT_CONTEXT(ctx);
5854    Node *n;
5855    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5856    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
5857    if (n) {
5858       GLint i;
5859       n[1].i = count;
5860       if (count > MAX_DRAW_BUFFERS)
5861          count = MAX_DRAW_BUFFERS;
5862       for (i = 0; i < count; i++) {
5863          n[2 + i].e = buffers[i];
5864       }
5865    }
5866    if (ctx->ExecuteFlag) {
5867       CALL_DrawBuffers(ctx->Exec, (count, buffers));
5868    }
5869 }
5870 
5871 static void GLAPIENTRY
save_BindFragmentShaderATI(GLuint id)5872 save_BindFragmentShaderATI(GLuint id)
5873 {
5874    GET_CURRENT_CONTEXT(ctx);
5875    Node *n;
5876 
5877    n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
5878    if (n) {
5879       n[1].ui = id;
5880    }
5881    if (ctx->ExecuteFlag) {
5882       CALL_BindFragmentShaderATI(ctx->Exec, (id));
5883    }
5884 }
5885 
5886 static void GLAPIENTRY
save_SetFragmentShaderConstantATI(GLuint dst,const GLfloat * value)5887 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
5888 {
5889    GET_CURRENT_CONTEXT(ctx);
5890    Node *n;
5891 
5892    n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
5893    if (n) {
5894       n[1].ui = dst;
5895       n[2].f = value[0];
5896       n[3].f = value[1];
5897       n[4].f = value[2];
5898       n[5].f = value[3];
5899    }
5900    if (ctx->ExecuteFlag) {
5901       CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
5902    }
5903 }
5904 
5905 static void GLAPIENTRY
save_EvalCoord1f(GLfloat x)5906 save_EvalCoord1f(GLfloat x)
5907 {
5908    GET_CURRENT_CONTEXT(ctx);
5909    Node *n;
5910    SAVE_FLUSH_VERTICES(ctx);
5911    n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
5912    if (n) {
5913       n[1].f = x;
5914    }
5915    if (ctx->ExecuteFlag) {
5916       CALL_EvalCoord1f(ctx->Exec, (x));
5917    }
5918 }
5919 
5920 static void GLAPIENTRY
save_EvalCoord1fv(const GLfloat * v)5921 save_EvalCoord1fv(const GLfloat * v)
5922 {
5923    save_EvalCoord1f(v[0]);
5924 }
5925 
5926 static void GLAPIENTRY
save_EvalCoord2f(GLfloat x,GLfloat y)5927 save_EvalCoord2f(GLfloat x, GLfloat y)
5928 {
5929    GET_CURRENT_CONTEXT(ctx);
5930    Node *n;
5931    SAVE_FLUSH_VERTICES(ctx);
5932    n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
5933    if (n) {
5934       n[1].f = x;
5935       n[2].f = y;
5936    }
5937    if (ctx->ExecuteFlag) {
5938       CALL_EvalCoord2f(ctx->Exec, (x, y));
5939    }
5940 }
5941 
5942 static void GLAPIENTRY
save_EvalCoord2fv(const GLfloat * v)5943 save_EvalCoord2fv(const GLfloat * v)
5944 {
5945    save_EvalCoord2f(v[0], v[1]);
5946 }
5947 
5948 
5949 static void GLAPIENTRY
save_EvalPoint1(GLint x)5950 save_EvalPoint1(GLint x)
5951 {
5952    GET_CURRENT_CONTEXT(ctx);
5953    Node *n;
5954    SAVE_FLUSH_VERTICES(ctx);
5955    n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
5956    if (n) {
5957       n[1].i = x;
5958    }
5959    if (ctx->ExecuteFlag) {
5960       CALL_EvalPoint1(ctx->Exec, (x));
5961    }
5962 }
5963 
5964 static void GLAPIENTRY
save_EvalPoint2(GLint x,GLint y)5965 save_EvalPoint2(GLint x, GLint y)
5966 {
5967    GET_CURRENT_CONTEXT(ctx);
5968    Node *n;
5969    SAVE_FLUSH_VERTICES(ctx);
5970    n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
5971    if (n) {
5972       n[1].i = x;
5973       n[2].i = y;
5974    }
5975    if (ctx->ExecuteFlag) {
5976       CALL_EvalPoint2(ctx->Exec, (x, y));
5977    }
5978 }
5979 
5980 
5981 /**
5982  * Compare 'count' elements of vectors 'a' and 'b'.
5983  * \return GL_TRUE if equal, GL_FALSE if different.
5984  */
5985 static inline GLboolean
compare_vec(const GLfloat * a,const GLfloat * b,GLuint count)5986 compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
5987 {
5988    return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5989 }
5990 
5991 
5992 /**
5993  * This glMaterial function is used for glMaterial calls that are outside
5994  * a glBegin/End pair.  For glMaterial inside glBegin/End, see the VBO code.
5995  */
5996 static void GLAPIENTRY
save_Materialfv(GLenum face,GLenum pname,const GLfloat * param)5997 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5998 {
5999    GET_CURRENT_CONTEXT(ctx);
6000    Node *n;
6001    int args, i;
6002    GLuint bitmask;
6003 
6004    switch (face) {
6005    case GL_BACK:
6006    case GL_FRONT:
6007    case GL_FRONT_AND_BACK:
6008       break;
6009    default:
6010       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
6011       return;
6012    }
6013 
6014    switch (pname) {
6015    case GL_EMISSION:
6016    case GL_AMBIENT:
6017    case GL_DIFFUSE:
6018    case GL_SPECULAR:
6019    case GL_AMBIENT_AND_DIFFUSE:
6020       args = 4;
6021       break;
6022    case GL_SHININESS:
6023       args = 1;
6024       break;
6025    case GL_COLOR_INDEXES:
6026       args = 3;
6027       break;
6028    default:
6029       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
6030       return;
6031    }
6032 
6033    if (ctx->ExecuteFlag) {
6034       CALL_Materialfv(ctx->Exec, (face, pname, param));
6035    }
6036 
6037    bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
6038 
6039    /* Try to eliminate redundant statechanges.  Because it is legal to
6040     * call glMaterial even inside begin/end calls, don't need to worry
6041     * about ctx->Driver.CurrentSavePrimitive here.
6042     */
6043    for (i = 0; i < MAT_ATTRIB_MAX; i++) {
6044       if (bitmask & (1 << i)) {
6045          if (ctx->ListState.ActiveMaterialSize[i] == args &&
6046              compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
6047             /* no change in material value */
6048             bitmask &= ~(1 << i);
6049          }
6050          else {
6051             ctx->ListState.ActiveMaterialSize[i] = args;
6052             COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
6053          }
6054       }
6055    }
6056 
6057    /* If this call has no effect, return early */
6058    if (bitmask == 0)
6059       return;
6060 
6061    SAVE_FLUSH_VERTICES(ctx);
6062 
6063    n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
6064    if (n) {
6065       n[1].e = face;
6066       n[2].e = pname;
6067       for (i = 0; i < args; i++)
6068          n[3 + i].f = param[i];
6069    }
6070 }
6071 
6072 static void GLAPIENTRY
save_Begin(GLenum mode)6073 save_Begin(GLenum mode)
6074 {
6075    GET_CURRENT_CONTEXT(ctx);
6076 
6077    if (!_mesa_is_valid_prim_mode(ctx, mode)) {
6078       /* compile this error into the display list */
6079       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)");
6080    }
6081    else if (_mesa_inside_dlist_begin_end(ctx)) {
6082       /* compile this error into the display list */
6083       _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive glBegin");
6084    }
6085    else {
6086       ctx->Driver.CurrentSavePrimitive = mode;
6087 
6088       vbo_save_NotifyBegin(ctx, mode, false);
6089    }
6090 }
6091 
6092 static void GLAPIENTRY
save_End(void)6093 save_End(void)
6094 {
6095    GET_CURRENT_CONTEXT(ctx);
6096    SAVE_FLUSH_VERTICES(ctx);
6097    (void) alloc_instruction(ctx, OPCODE_END, 0);
6098    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
6099    if (ctx->ExecuteFlag) {
6100       CALL_End(ctx->Exec, ());
6101    }
6102 }
6103 
6104 static void GLAPIENTRY
save_Rectf(GLfloat a,GLfloat b,GLfloat c,GLfloat d)6105 save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d)
6106 {
6107    GET_CURRENT_CONTEXT(ctx);
6108    Node *n;
6109    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6110    n = alloc_instruction(ctx, OPCODE_RECTF, 4);
6111    if (n) {
6112       n[1].f = a;
6113       n[2].f = b;
6114       n[3].f = c;
6115       n[4].f = d;
6116    }
6117    if (ctx->ExecuteFlag) {
6118       CALL_Rectf(ctx->Exec, (a, b, c, d));
6119    }
6120 }
6121 
6122 static void GLAPIENTRY
save_Rectd(GLdouble x1,GLdouble y1,GLdouble x2,GLdouble y2)6123 save_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
6124 {
6125    save_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
6126 }
6127 
6128 static void GLAPIENTRY
save_Rectdv(const GLdouble * v1,const GLdouble * v2)6129 save_Rectdv(const GLdouble *v1, const GLdouble *v2)
6130 {
6131    save_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
6132 }
6133 
6134 static void GLAPIENTRY
save_Rectfv(const GLfloat * v1,const GLfloat * v2)6135 save_Rectfv(const GLfloat *v1, const GLfloat *v2)
6136 {
6137    save_Rectf(v1[0], v1[1], v2[0], v2[1]);
6138 }
6139 
6140 static void GLAPIENTRY
save_Recti(GLint x1,GLint y1,GLint x2,GLint y2)6141 save_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
6142 {
6143    save_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
6144 }
6145 
6146 static void GLAPIENTRY
save_Rectiv(const GLint * v1,const GLint * v2)6147 save_Rectiv(const GLint *v1, const GLint *v2)
6148 {
6149    save_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
6150 }
6151 
6152 static void GLAPIENTRY
save_Rects(GLshort x1,GLshort y1,GLshort x2,GLshort y2)6153 save_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
6154 {
6155    save_Rectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
6156 }
6157 
6158 static void GLAPIENTRY
save_Rectsv(const GLshort * v1,const GLshort * v2)6159 save_Rectsv(const GLshort *v1, const GLshort *v2)
6160 {
6161    save_Rectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
6162 }
6163 
6164 static void GLAPIENTRY
save_PrimitiveRestartNV(void)6165 save_PrimitiveRestartNV(void)
6166 {
6167    /* Note: this is used when outside a glBegin/End pair in a display list */
6168    GET_CURRENT_CONTEXT(ctx);
6169    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6170    (void) alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0);
6171    if (ctx->ExecuteFlag) {
6172       CALL_PrimitiveRestartNV(ctx->Exec, ());
6173    }
6174 }
6175 
6176 
6177 static void GLAPIENTRY
save_BlitFramebufferEXT(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)6178 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
6179                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
6180                         GLbitfield mask, GLenum filter)
6181 {
6182    GET_CURRENT_CONTEXT(ctx);
6183    Node *n;
6184    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6185    n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
6186    if (n) {
6187       n[1].i = srcX0;
6188       n[2].i = srcY0;
6189       n[3].i = srcX1;
6190       n[4].i = srcY1;
6191       n[5].i = dstX0;
6192       n[6].i = dstY0;
6193       n[7].i = dstX1;
6194       n[8].i = dstY1;
6195       n[9].i = mask;
6196       n[10].e = filter;
6197    }
6198    if (ctx->ExecuteFlag) {
6199       CALL_BlitFramebuffer(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
6200                                           dstX0, dstY0, dstX1, dstY1,
6201                                           mask, filter));
6202    }
6203 }
6204 
6205 
6206 /** GL_EXT_provoking_vertex */
6207 static void GLAPIENTRY
save_ProvokingVertexEXT(GLenum mode)6208 save_ProvokingVertexEXT(GLenum mode)
6209 {
6210    GET_CURRENT_CONTEXT(ctx);
6211    Node *n;
6212    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6213    n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
6214    if (n) {
6215       n[1].e = mode;
6216    }
6217    if (ctx->ExecuteFlag) {
6218       /*CALL_ProvokingVertex(ctx->Exec, (mode));*/
6219       _mesa_ProvokingVertex(mode);
6220    }
6221 }
6222 
6223 
6224 /** GL_EXT_transform_feedback */
6225 static void GLAPIENTRY
save_BeginTransformFeedback(GLenum mode)6226 save_BeginTransformFeedback(GLenum mode)
6227 {
6228    GET_CURRENT_CONTEXT(ctx);
6229    Node *n;
6230    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6231    n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1);
6232    if (n) {
6233       n[1].e = mode;
6234    }
6235    if (ctx->ExecuteFlag) {
6236       CALL_BeginTransformFeedback(ctx->Exec, (mode));
6237    }
6238 }
6239 
6240 
6241 /** GL_EXT_transform_feedback */
6242 static void GLAPIENTRY
save_EndTransformFeedback(void)6243 save_EndTransformFeedback(void)
6244 {
6245    GET_CURRENT_CONTEXT(ctx);
6246    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6247    (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0);
6248    if (ctx->ExecuteFlag) {
6249       CALL_EndTransformFeedback(ctx->Exec, ());
6250    }
6251 }
6252 
6253 static void GLAPIENTRY
save_BindTransformFeedback(GLenum target,GLuint name)6254 save_BindTransformFeedback(GLenum target, GLuint name)
6255 {
6256    GET_CURRENT_CONTEXT(ctx);
6257    Node *n;
6258    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6259    n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2);
6260    if (n) {
6261       n[1].e = target;
6262       n[2].ui = name;
6263    }
6264    if (ctx->ExecuteFlag) {
6265       CALL_BindTransformFeedback(ctx->Exec, (target, name));
6266    }
6267 }
6268 
6269 static void GLAPIENTRY
save_PauseTransformFeedback(void)6270 save_PauseTransformFeedback(void)
6271 {
6272    GET_CURRENT_CONTEXT(ctx);
6273    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6274    (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0);
6275    if (ctx->ExecuteFlag) {
6276       CALL_PauseTransformFeedback(ctx->Exec, ());
6277    }
6278 }
6279 
6280 static void GLAPIENTRY
save_ResumeTransformFeedback(void)6281 save_ResumeTransformFeedback(void)
6282 {
6283    GET_CURRENT_CONTEXT(ctx);
6284    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6285    (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0);
6286    if (ctx->ExecuteFlag) {
6287       CALL_ResumeTransformFeedback(ctx->Exec, ());
6288    }
6289 }
6290 
6291 static void GLAPIENTRY
save_DrawTransformFeedback(GLenum mode,GLuint name)6292 save_DrawTransformFeedback(GLenum mode, GLuint name)
6293 {
6294    GET_CURRENT_CONTEXT(ctx);
6295    Node *n;
6296    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6297    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2);
6298    if (n) {
6299       n[1].e = mode;
6300       n[2].ui = name;
6301    }
6302    if (ctx->ExecuteFlag) {
6303       CALL_DrawTransformFeedback(ctx->Exec, (mode, name));
6304    }
6305 }
6306 
6307 static void GLAPIENTRY
save_DrawTransformFeedbackStream(GLenum mode,GLuint name,GLuint stream)6308 save_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream)
6309 {
6310    GET_CURRENT_CONTEXT(ctx);
6311    Node *n;
6312    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6313    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM, 3);
6314    if (n) {
6315       n[1].e = mode;
6316       n[2].ui = name;
6317       n[3].ui = stream;
6318    }
6319    if (ctx->ExecuteFlag) {
6320       CALL_DrawTransformFeedbackStream(ctx->Exec, (mode, name, stream));
6321    }
6322 }
6323 
6324 static void GLAPIENTRY
save_DrawTransformFeedbackInstanced(GLenum mode,GLuint name,GLsizei primcount)6325 save_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
6326                                     GLsizei primcount)
6327 {
6328    GET_CURRENT_CONTEXT(ctx);
6329    Node *n;
6330    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6331    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED, 3);
6332    if (n) {
6333       n[1].e = mode;
6334       n[2].ui = name;
6335       n[3].si = primcount;
6336    }
6337    if (ctx->ExecuteFlag) {
6338       CALL_DrawTransformFeedbackInstanced(ctx->Exec, (mode, name, primcount));
6339    }
6340 }
6341 
6342 static void GLAPIENTRY
save_DrawTransformFeedbackStreamInstanced(GLenum mode,GLuint name,GLuint stream,GLsizei primcount)6343 save_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
6344                                           GLuint stream, GLsizei primcount)
6345 {
6346    GET_CURRENT_CONTEXT(ctx);
6347    Node *n;
6348    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6349    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED, 4);
6350    if (n) {
6351       n[1].e = mode;
6352       n[2].ui = name;
6353       n[3].ui = stream;
6354       n[4].si = primcount;
6355    }
6356    if (ctx->ExecuteFlag) {
6357       CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec, (mode, name, stream,
6358                                                             primcount));
6359    }
6360 }
6361 
6362 static void GLAPIENTRY
save_DispatchCompute(GLuint num_groups_x,GLuint num_groups_y,GLuint num_groups_z)6363 save_DispatchCompute(GLuint num_groups_x, GLuint num_groups_y,
6364                      GLuint num_groups_z)
6365 {
6366    GET_CURRENT_CONTEXT(ctx);
6367    Node *n;
6368    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6369    n = alloc_instruction(ctx, OPCODE_DISPATCH_COMPUTE, 3);
6370    if (n) {
6371       n[1].ui = num_groups_x;
6372       n[2].ui = num_groups_y;
6373       n[3].ui = num_groups_z;
6374    }
6375    if (ctx->ExecuteFlag) {
6376       CALL_DispatchCompute(ctx->Exec, (num_groups_x, num_groups_y,
6377                                        num_groups_z));
6378    }
6379 }
6380 
6381 static void GLAPIENTRY
save_DispatchComputeIndirect(GLintptr indirect)6382 save_DispatchComputeIndirect(GLintptr indirect)
6383 {
6384    GET_CURRENT_CONTEXT(ctx);
6385    _mesa_error(ctx, GL_INVALID_OPERATION,
6386                "glDispatchComputeIndirect() during display list compile");
6387 }
6388 
6389 static void ALWAYS_INLINE
save_Attr32bit(struct gl_context * ctx,unsigned attr,unsigned size,GLenum type,uint32_t x,uint32_t y,uint32_t z,uint32_t w)6390 save_Attr32bit(struct gl_context *ctx, unsigned attr, unsigned size,
6391                GLenum type, uint32_t x, uint32_t y, uint32_t z, uint32_t w)
6392 {
6393    Node *n;
6394    SAVE_FLUSH_VERTICES(ctx);
6395    unsigned base_op;
6396    unsigned index = attr;
6397 
6398    /* We don't care about GL_INT vs GL_UNSIGNED_INT. The idea is to get W=1
6399     * right for 3 or lower number of components, so only distinguish between
6400     * FLOAT and INT.
6401     */
6402    if (type == GL_FLOAT) {
6403       if (attr >= VERT_ATTRIB_GENERIC0) {
6404          base_op = OPCODE_ATTR_1F_ARB;
6405          attr -= VERT_ATTRIB_GENERIC0;
6406       } else {
6407          base_op = OPCODE_ATTR_1F_NV;
6408       }
6409    } else {
6410       base_op = OPCODE_ATTR_1I;
6411       attr -= VERT_ATTRIB_GENERIC0;
6412    }
6413 
6414    n = alloc_instruction(ctx, base_op + size - 1, 1 + size);
6415    if (n) {
6416       n[1].ui = attr;
6417       n[2].ui = x;
6418       if (size >= 2) n[3].ui = y;
6419       if (size >= 3) n[4].ui = z;
6420       if (size >= 4) n[5].ui = w;
6421    }
6422 
6423    ctx->ListState.ActiveAttribSize[index] = size;
6424    ASSIGN_4V(ctx->ListState.CurrentAttrib[index], x, y, z, w);
6425 
6426    if (ctx->ExecuteFlag) {
6427       if (type == GL_FLOAT) {
6428          if (base_op == OPCODE_ATTR_1F_NV) {
6429             if (size == 4)
6430                CALL_VertexAttrib4fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
6431             else if (size == 3)
6432                CALL_VertexAttrib3fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
6433             else if (size == 2)
6434                CALL_VertexAttrib2fNV(ctx->Exec, (attr, uif(x), uif(y)));
6435             else
6436                CALL_VertexAttrib1fNV(ctx->Exec, (attr, uif(x)));
6437          } else {
6438             if (size == 4)
6439                CALL_VertexAttrib4fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
6440             else if (size == 3)
6441                CALL_VertexAttrib3fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
6442             else if (size == 2)
6443                CALL_VertexAttrib2fARB(ctx->Exec, (attr, uif(x), uif(y)));
6444             else
6445                CALL_VertexAttrib1fARB(ctx->Exec, (attr, uif(x)));
6446          }
6447       } else {
6448          if (size == 4)
6449             CALL_VertexAttribI4iEXT(ctx->Exec, (attr, x, y, z, w));
6450          else if (size == 3)
6451             CALL_VertexAttribI3iEXT(ctx->Exec, (attr, x, y, z));
6452          else if (size == 2)
6453             CALL_VertexAttribI2iEXT(ctx->Exec, (attr, x, y));
6454          else
6455             CALL_VertexAttribI1iEXT(ctx->Exec, (attr, x));
6456       }
6457    }
6458 }
6459 
6460 static void ALWAYS_INLINE
save_Attr64bit(struct gl_context * ctx,unsigned attr,unsigned size,GLenum type,uint64_t x,uint64_t y,uint64_t z,uint64_t w)6461 save_Attr64bit(struct gl_context *ctx, unsigned attr, unsigned size,
6462                GLenum type, uint64_t x, uint64_t y, uint64_t z, uint64_t w)
6463 {
6464    Node *n;
6465    SAVE_FLUSH_VERTICES(ctx);
6466    unsigned base_op;
6467    unsigned index = attr;
6468 
6469    if (type == GL_DOUBLE) {
6470       base_op = OPCODE_ATTR_1D;
6471    } else {
6472       base_op = OPCODE_ATTR_1UI64;
6473       assert(size == 1);
6474    }
6475 
6476    attr -= VERT_ATTRIB_GENERIC0;
6477    n = alloc_instruction(ctx, base_op + size - 1, 1 + size * 2);
6478    if (n) {
6479       n[1].ui = attr;
6480       ASSIGN_UINT64_TO_NODES(n, 2, x);
6481       if (size >= 2) ASSIGN_UINT64_TO_NODES(n, 4, y);
6482       if (size >= 3) ASSIGN_UINT64_TO_NODES(n, 6, z);
6483       if (size >= 4) ASSIGN_UINT64_TO_NODES(n, 8, w);
6484    }
6485 
6486    ctx->ListState.ActiveAttribSize[index] = size;
6487    memcpy(ctx->ListState.CurrentAttrib[index], &n[2], size * sizeof(uint64_t));
6488 
6489    if (ctx->ExecuteFlag) {
6490       uint64_t v[] = {x, y, z, w};
6491       if (type == GL_DOUBLE) {
6492          if (size == 4)
6493             CALL_VertexAttribL4dv(ctx->Exec, (attr, (GLdouble*)v));
6494          else if (size == 3)
6495             CALL_VertexAttribL3dv(ctx->Exec, (attr, (GLdouble*)v));
6496          else if (size == 2)
6497             CALL_VertexAttribL2dv(ctx->Exec, (attr, (GLdouble*)v));
6498          else
6499             CALL_VertexAttribL1d(ctx->Exec, (attr, UINT64_AS_DOUBLE(x)));
6500       } else {
6501          CALL_VertexAttribL1ui64ARB(ctx->Exec, (attr, x));
6502       }
6503    }
6504 }
6505 
6506 /**
6507  * If index=0, does glVertexAttrib*() alias glVertex() to emit a vertex?
6508  * It depends on a few things, including whether we're inside or outside
6509  * of glBegin/glEnd.
6510  */
6511 static inline bool
is_vertex_position(const struct gl_context * ctx,GLuint index)6512 is_vertex_position(const struct gl_context *ctx, GLuint index)
6513 {
6514    return (index == 0 &&
6515            _mesa_attr_zero_aliases_vertex(ctx) &&
6516            _mesa_inside_dlist_begin_end(ctx));
6517 }
6518 
6519 /**
6520  * This macro is used to implement all the glVertex, glColor, glTexCoord,
6521  * glVertexAttrib, etc functions.
6522  * \param A  VBO_ATTRIB_x attribute index
6523  * \param N  attribute size (1..4)
6524  * \param T  type (GL_FLOAT, GL_DOUBLE, GL_INT, GL_UNSIGNED_INT)
6525  * \param C  cast type (uint32_t or uint64_t)
6526  * \param V0, V1, v2, V3  attribute value
6527  */
6528 #define ATTR_UNION(A, N, T, C, V0, V1, V2, V3)                          \
6529 do {                                                                    \
6530    if (sizeof(C) == 4) {                                                \
6531       save_Attr32bit(ctx, A, N, T, V0, V1, V2, V3);                     \
6532    } else {                                                             \
6533       save_Attr64bit(ctx, A, N, T, V0, V1, V2, V3);                     \
6534    }                                                                    \
6535 } while (0)
6536 
6537 #undef ERROR
6538 #define ERROR(err) _mesa_error(ctx, err, __func__)
6539 #define TAG(x) save_##x
6540 
6541 #define VBO_ATTRIB_POS           VERT_ATTRIB_POS
6542 #define VBO_ATTRIB_NORMAL        VERT_ATTRIB_NORMAL
6543 #define VBO_ATTRIB_COLOR0        VERT_ATTRIB_COLOR0
6544 #define VBO_ATTRIB_COLOR1        VERT_ATTRIB_COLOR1
6545 #define VBO_ATTRIB_FOG           VERT_ATTRIB_FOG
6546 #define VBO_ATTRIB_COLOR_INDEX   VERT_ATTRIB_COLOR_INDEX
6547 #define VBO_ATTRIB_EDGEFLAG      VERT_ATTRIB_EDGEFLAG
6548 #define VBO_ATTRIB_TEX0          VERT_ATTRIB_TEX0
6549 #define VBO_ATTRIB_GENERIC0      VERT_ATTRIB_GENERIC0
6550 #define VBO_ATTRIB_MAX           VERT_ATTRIB_MAX
6551 
6552 #include "vbo/vbo_attrib_tmp.h"
6553 
6554 static void GLAPIENTRY
save_UseProgram(GLuint program)6555 save_UseProgram(GLuint program)
6556 {
6557    GET_CURRENT_CONTEXT(ctx);
6558    Node *n;
6559    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6560    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
6561    if (n) {
6562       n[1].ui = program;
6563    }
6564    if (ctx->ExecuteFlag) {
6565       CALL_UseProgram(ctx->Exec, (program));
6566    }
6567 }
6568 
6569 
6570 static void GLAPIENTRY
save_Uniform1fARB(GLint location,GLfloat x)6571 save_Uniform1fARB(GLint location, GLfloat x)
6572 {
6573    GET_CURRENT_CONTEXT(ctx);
6574    Node *n;
6575    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6576    n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
6577    if (n) {
6578       n[1].i = location;
6579       n[2].f = x;
6580    }
6581    if (ctx->ExecuteFlag) {
6582       CALL_Uniform1f(ctx->Exec, (location, x));
6583    }
6584 }
6585 
6586 
6587 static void GLAPIENTRY
save_Uniform2fARB(GLint location,GLfloat x,GLfloat y)6588 save_Uniform2fARB(GLint location, GLfloat x, GLfloat y)
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_2F, 3);
6594    if (n) {
6595       n[1].i = location;
6596       n[2].f = x;
6597       n[3].f = y;
6598    }
6599    if (ctx->ExecuteFlag) {
6600       CALL_Uniform2f(ctx->Exec, (location, x, y));
6601    }
6602 }
6603 
6604 
6605 static void GLAPIENTRY
save_Uniform3fARB(GLint location,GLfloat x,GLfloat y,GLfloat z)6606 save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z)
6607 {
6608    GET_CURRENT_CONTEXT(ctx);
6609    Node *n;
6610    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6611    n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
6612    if (n) {
6613       n[1].i = location;
6614       n[2].f = x;
6615       n[3].f = y;
6616       n[4].f = z;
6617    }
6618    if (ctx->ExecuteFlag) {
6619       CALL_Uniform3f(ctx->Exec, (location, x, y, z));
6620    }
6621 }
6622 
6623 
6624 static void GLAPIENTRY
save_Uniform4fARB(GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)6625 save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6626 {
6627    GET_CURRENT_CONTEXT(ctx);
6628    Node *n;
6629    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6630    n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
6631    if (n) {
6632       n[1].i = location;
6633       n[2].f = x;
6634       n[3].f = y;
6635       n[4].f = z;
6636       n[5].f = w;
6637    }
6638    if (ctx->ExecuteFlag) {
6639       CALL_Uniform4f(ctx->Exec, (location, x, y, z, w));
6640    }
6641 }
6642 
6643 
6644 static void GLAPIENTRY
save_Uniform1fvARB(GLint location,GLsizei count,const GLfloat * v)6645 save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v)
6646 {
6647    GET_CURRENT_CONTEXT(ctx);
6648    Node *n;
6649    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6650    n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 2 + POINTER_DWORDS);
6651    if (n) {
6652       n[1].i = location;
6653       n[2].i = count;
6654       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLfloat)));
6655    }
6656    if (ctx->ExecuteFlag) {
6657       CALL_Uniform1fv(ctx->Exec, (location, count, v));
6658    }
6659 }
6660 
6661 static void GLAPIENTRY
save_Uniform2fvARB(GLint location,GLsizei count,const GLfloat * v)6662 save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v)
6663 {
6664    GET_CURRENT_CONTEXT(ctx);
6665    Node *n;
6666    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6667    n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 2 + POINTER_DWORDS);
6668    if (n) {
6669       n[1].i = location;
6670       n[2].i = count;
6671       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLfloat)));
6672    }
6673    if (ctx->ExecuteFlag) {
6674       CALL_Uniform2fv(ctx->Exec, (location, count, v));
6675    }
6676 }
6677 
6678 static void GLAPIENTRY
save_Uniform3fvARB(GLint location,GLsizei count,const GLfloat * v)6679 save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v)
6680 {
6681    GET_CURRENT_CONTEXT(ctx);
6682    Node *n;
6683    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6684    n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 2 + POINTER_DWORDS);
6685    if (n) {
6686       n[1].i = location;
6687       n[2].i = count;
6688       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLfloat)));
6689    }
6690    if (ctx->ExecuteFlag) {
6691       CALL_Uniform3fv(ctx->Exec, (location, count, v));
6692    }
6693 }
6694 
6695 static void GLAPIENTRY
save_Uniform4fvARB(GLint location,GLsizei count,const GLfloat * v)6696 save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v)
6697 {
6698    GET_CURRENT_CONTEXT(ctx);
6699    Node *n;
6700    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6701    n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 2 + POINTER_DWORDS);
6702    if (n) {
6703       n[1].i = location;
6704       n[2].i = count;
6705       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6706    }
6707    if (ctx->ExecuteFlag) {
6708       CALL_Uniform4fv(ctx->Exec, (location, count, v));
6709    }
6710 }
6711 
6712 
6713 static void GLAPIENTRY
save_Uniform1d(GLint location,GLdouble x)6714 save_Uniform1d(GLint location, GLdouble x)
6715 {
6716    GET_CURRENT_CONTEXT(ctx);
6717    Node *n;
6718    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6719    n = alloc_instruction(ctx, OPCODE_UNIFORM_1D, 3);
6720    if (n) {
6721       n[1].i = location;
6722       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6723    }
6724    if (ctx->ExecuteFlag) {
6725       CALL_Uniform1d(ctx->Exec, (location, x));
6726    }
6727 }
6728 
6729 
6730 static void GLAPIENTRY
save_Uniform2d(GLint location,GLdouble x,GLdouble y)6731 save_Uniform2d(GLint location, GLdouble x, GLdouble y)
6732 {
6733    GET_CURRENT_CONTEXT(ctx);
6734    Node *n;
6735    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6736    n = alloc_instruction(ctx, OPCODE_UNIFORM_2D, 5);
6737    if (n) {
6738       n[1].i = location;
6739       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6740       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6741    }
6742    if (ctx->ExecuteFlag) {
6743       CALL_Uniform2d(ctx->Exec, (location, x, y));
6744    }
6745 }
6746 
6747 
6748 static void GLAPIENTRY
save_Uniform3d(GLint location,GLdouble x,GLdouble y,GLdouble z)6749 save_Uniform3d(GLint location, GLdouble x, GLdouble y, GLdouble z)
6750 {
6751    GET_CURRENT_CONTEXT(ctx);
6752    Node *n;
6753    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6754    n = alloc_instruction(ctx, OPCODE_UNIFORM_3D, 7);
6755    if (n) {
6756       n[1].i = location;
6757       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6758       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6759       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6760    }
6761    if (ctx->ExecuteFlag) {
6762       CALL_Uniform3d(ctx->Exec, (location, x, y, z));
6763    }
6764 }
6765 
6766 
6767 static void GLAPIENTRY
save_Uniform4d(GLint location,GLdouble x,GLdouble y,GLdouble z,GLdouble w)6768 save_Uniform4d(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
6769 {
6770    GET_CURRENT_CONTEXT(ctx);
6771    Node *n;
6772    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6773    n = alloc_instruction(ctx, OPCODE_UNIFORM_4D, 9);
6774    if (n) {
6775       n[1].i = location;
6776       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6777       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6778       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6779       ASSIGN_DOUBLE_TO_NODES(n, 8, w);
6780    }
6781    if (ctx->ExecuteFlag) {
6782       CALL_Uniform4d(ctx->Exec, (location, x, y, z, w));
6783    }
6784 }
6785 
6786 
6787 static void GLAPIENTRY
save_Uniform1dv(GLint location,GLsizei count,const GLdouble * v)6788 save_Uniform1dv(GLint location, GLsizei count, const GLdouble *v)
6789 {
6790    GET_CURRENT_CONTEXT(ctx);
6791    Node *n;
6792    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6793    n = alloc_instruction(ctx, OPCODE_UNIFORM_1DV, 2 + POINTER_DWORDS);
6794    if (n) {
6795       n[1].i = location;
6796       n[2].i = count;
6797       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLdouble)));
6798    }
6799    if (ctx->ExecuteFlag) {
6800       CALL_Uniform1dv(ctx->Exec, (location, count, v));
6801    }
6802 }
6803 
6804 
6805 static void GLAPIENTRY
save_Uniform2dv(GLint location,GLsizei count,const GLdouble * v)6806 save_Uniform2dv(GLint location, GLsizei count, const GLdouble *v)
6807 {
6808    GET_CURRENT_CONTEXT(ctx);
6809    Node *n;
6810    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6811    n = alloc_instruction(ctx, OPCODE_UNIFORM_2DV, 2 + POINTER_DWORDS);
6812    if (n) {
6813       n[1].i = location;
6814       n[2].i = count;
6815       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLdouble)));
6816    }
6817    if (ctx->ExecuteFlag) {
6818       CALL_Uniform2dv(ctx->Exec, (location, count, v));
6819    }
6820 }
6821 
6822 
6823 static void GLAPIENTRY
save_Uniform3dv(GLint location,GLsizei count,const GLdouble * v)6824 save_Uniform3dv(GLint location, GLsizei count, const GLdouble *v)
6825 {
6826    GET_CURRENT_CONTEXT(ctx);
6827    Node *n;
6828    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6829    n = alloc_instruction(ctx, OPCODE_UNIFORM_3DV, 2 + POINTER_DWORDS);
6830    if (n) {
6831       n[1].i = location;
6832       n[2].i = count;
6833       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLdouble)));
6834    }
6835    if (ctx->ExecuteFlag) {
6836       CALL_Uniform3dv(ctx->Exec, (location, count, v));
6837    }
6838 }
6839 
6840 
6841 static void GLAPIENTRY
save_Uniform4dv(GLint location,GLsizei count,const GLdouble * v)6842 save_Uniform4dv(GLint location, GLsizei count, const GLdouble *v)
6843 {
6844    GET_CURRENT_CONTEXT(ctx);
6845    Node *n;
6846    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6847    n = alloc_instruction(ctx, OPCODE_UNIFORM_4DV, 2 + POINTER_DWORDS);
6848    if (n) {
6849       n[1].i = location;
6850       n[2].i = count;
6851       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLdouble)));
6852    }
6853    if (ctx->ExecuteFlag) {
6854       CALL_Uniform4dv(ctx->Exec, (location, count, v));
6855    }
6856 }
6857 
6858 
6859 static void GLAPIENTRY
save_Uniform1iARB(GLint location,GLint x)6860 save_Uniform1iARB(GLint location, GLint x)
6861 {
6862    GET_CURRENT_CONTEXT(ctx);
6863    Node *n;
6864    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6865    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
6866    if (n) {
6867       n[1].i = location;
6868       n[2].i = x;
6869    }
6870    if (ctx->ExecuteFlag) {
6871       CALL_Uniform1i(ctx->Exec, (location, x));
6872    }
6873 }
6874 
6875 static void GLAPIENTRY
save_Uniform2iARB(GLint location,GLint x,GLint y)6876 save_Uniform2iARB(GLint location, GLint x, GLint y)
6877 {
6878    GET_CURRENT_CONTEXT(ctx);
6879    Node *n;
6880    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6881    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
6882    if (n) {
6883       n[1].i = location;
6884       n[2].i = x;
6885       n[3].i = y;
6886    }
6887    if (ctx->ExecuteFlag) {
6888       CALL_Uniform2i(ctx->Exec, (location, x, y));
6889    }
6890 }
6891 
6892 static void GLAPIENTRY
save_Uniform3iARB(GLint location,GLint x,GLint y,GLint z)6893 save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z)
6894 {
6895    GET_CURRENT_CONTEXT(ctx);
6896    Node *n;
6897    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6898    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
6899    if (n) {
6900       n[1].i = location;
6901       n[2].i = x;
6902       n[3].i = y;
6903       n[4].i = z;
6904    }
6905    if (ctx->ExecuteFlag) {
6906       CALL_Uniform3i(ctx->Exec, (location, x, y, z));
6907    }
6908 }
6909 
6910 static void GLAPIENTRY
save_Uniform4iARB(GLint location,GLint x,GLint y,GLint z,GLint w)6911 save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w)
6912 {
6913    GET_CURRENT_CONTEXT(ctx);
6914    Node *n;
6915    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6916    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
6917    if (n) {
6918       n[1].i = location;
6919       n[2].i = x;
6920       n[3].i = y;
6921       n[4].i = z;
6922       n[5].i = w;
6923    }
6924    if (ctx->ExecuteFlag) {
6925       CALL_Uniform4i(ctx->Exec, (location, x, y, z, w));
6926    }
6927 }
6928 
6929 
6930 
6931 static void GLAPIENTRY
save_Uniform1ivARB(GLint location,GLsizei count,const GLint * v)6932 save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v)
6933 {
6934    GET_CURRENT_CONTEXT(ctx);
6935    Node *n;
6936    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6937    n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 2 + POINTER_DWORDS);
6938    if (n) {
6939       n[1].i = location;
6940       n[2].i = count;
6941       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint)));
6942    }
6943    if (ctx->ExecuteFlag) {
6944       CALL_Uniform1iv(ctx->Exec, (location, count, v));
6945    }
6946 }
6947 
6948 static void GLAPIENTRY
save_Uniform2ivARB(GLint location,GLsizei count,const GLint * v)6949 save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v)
6950 {
6951    GET_CURRENT_CONTEXT(ctx);
6952    Node *n;
6953    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6954    n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 2 + POINTER_DWORDS);
6955    if (n) {
6956       n[1].i = location;
6957       n[2].i = count;
6958       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint)));
6959    }
6960    if (ctx->ExecuteFlag) {
6961       CALL_Uniform2iv(ctx->Exec, (location, count, v));
6962    }
6963 }
6964 
6965 static void GLAPIENTRY
save_Uniform3ivARB(GLint location,GLsizei count,const GLint * v)6966 save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v)
6967 {
6968    GET_CURRENT_CONTEXT(ctx);
6969    Node *n;
6970    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6971    n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 2 + POINTER_DWORDS);
6972    if (n) {
6973       n[1].i = location;
6974       n[2].i = count;
6975       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint)));
6976    }
6977    if (ctx->ExecuteFlag) {
6978       CALL_Uniform3iv(ctx->Exec, (location, count, v));
6979    }
6980 }
6981 
6982 static void GLAPIENTRY
save_Uniform4ivARB(GLint location,GLsizei count,const GLint * v)6983 save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v)
6984 {
6985    GET_CURRENT_CONTEXT(ctx);
6986    Node *n;
6987    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6988    n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 2 + POINTER_DWORDS);
6989    if (n) {
6990       n[1].i = location;
6991       n[2].i = count;
6992       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6993    }
6994    if (ctx->ExecuteFlag) {
6995       CALL_Uniform4iv(ctx->Exec, (location, count, v));
6996    }
6997 }
6998 
6999 
7000 
7001 static void GLAPIENTRY
save_Uniform1ui(GLint location,GLuint x)7002 save_Uniform1ui(GLint location, GLuint x)
7003 {
7004    GET_CURRENT_CONTEXT(ctx);
7005    Node *n;
7006    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7007    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2);
7008    if (n) {
7009       n[1].i = location;
7010       n[2].i = x;
7011    }
7012    if (ctx->ExecuteFlag) {
7013       CALL_Uniform1ui(ctx->Exec, (location, x));
7014    }
7015 }
7016 
7017 static void GLAPIENTRY
save_Uniform2ui(GLint location,GLuint x,GLuint y)7018 save_Uniform2ui(GLint location, GLuint x, GLuint y)
7019 {
7020    GET_CURRENT_CONTEXT(ctx);
7021    Node *n;
7022    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7023    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3);
7024    if (n) {
7025       n[1].i = location;
7026       n[2].i = x;
7027       n[3].i = y;
7028    }
7029    if (ctx->ExecuteFlag) {
7030       CALL_Uniform2ui(ctx->Exec, (location, x, y));
7031    }
7032 }
7033 
7034 static void GLAPIENTRY
save_Uniform3ui(GLint location,GLuint x,GLuint y,GLuint z)7035 save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z)
7036 {
7037    GET_CURRENT_CONTEXT(ctx);
7038    Node *n;
7039    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7040    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4);
7041    if (n) {
7042       n[1].i = location;
7043       n[2].i = x;
7044       n[3].i = y;
7045       n[4].i = z;
7046    }
7047    if (ctx->ExecuteFlag) {
7048       CALL_Uniform3ui(ctx->Exec, (location, x, y, z));
7049    }
7050 }
7051 
7052 static void GLAPIENTRY
save_Uniform4ui(GLint location,GLuint x,GLuint y,GLuint z,GLuint w)7053 save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w)
7054 {
7055    GET_CURRENT_CONTEXT(ctx);
7056    Node *n;
7057    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7058    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5);
7059    if (n) {
7060       n[1].i = location;
7061       n[2].i = x;
7062       n[3].i = y;
7063       n[4].i = z;
7064       n[5].i = w;
7065    }
7066    if (ctx->ExecuteFlag) {
7067       CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));
7068    }
7069 }
7070 
7071 
7072 
7073 static void GLAPIENTRY
save_Uniform1uiv(GLint location,GLsizei count,const GLuint * v)7074 save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v)
7075 {
7076    GET_CURRENT_CONTEXT(ctx);
7077    Node *n;
7078    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7079    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 2 + POINTER_DWORDS);
7080    if (n) {
7081       n[1].i = location;
7082       n[2].i = count;
7083       save_pointer(&n[3], memdup(v, count * 1 * sizeof(*v)));
7084    }
7085    if (ctx->ExecuteFlag) {
7086       CALL_Uniform1uiv(ctx->Exec, (location, count, v));
7087    }
7088 }
7089 
7090 static void GLAPIENTRY
save_Uniform2uiv(GLint location,GLsizei count,const GLuint * v)7091 save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v)
7092 {
7093    GET_CURRENT_CONTEXT(ctx);
7094    Node *n;
7095    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7096    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 2 + POINTER_DWORDS);
7097    if (n) {
7098       n[1].i = location;
7099       n[2].i = count;
7100       save_pointer(&n[3], memdup(v, count * 2 * sizeof(*v)));
7101    }
7102    if (ctx->ExecuteFlag) {
7103       CALL_Uniform2uiv(ctx->Exec, (location, count, v));
7104    }
7105 }
7106 
7107 static void GLAPIENTRY
save_Uniform3uiv(GLint location,GLsizei count,const GLuint * v)7108 save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v)
7109 {
7110    GET_CURRENT_CONTEXT(ctx);
7111    Node *n;
7112    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7113    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 2 + POINTER_DWORDS);
7114    if (n) {
7115       n[1].i = location;
7116       n[2].i = count;
7117       save_pointer(&n[3], memdup(v, count * 3 * sizeof(*v)));
7118    }
7119    if (ctx->ExecuteFlag) {
7120       CALL_Uniform3uiv(ctx->Exec, (location, count, v));
7121    }
7122 }
7123 
7124 static void GLAPIENTRY
save_Uniform4uiv(GLint location,GLsizei count,const GLuint * v)7125 save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v)
7126 {
7127    GET_CURRENT_CONTEXT(ctx);
7128    Node *n;
7129    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7130    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 2 + POINTER_DWORDS);
7131    if (n) {
7132       n[1].i = location;
7133       n[2].i = count;
7134       save_pointer(&n[3], memdup(v, count * 4 * sizeof(*v)));
7135    }
7136    if (ctx->ExecuteFlag) {
7137       CALL_Uniform4uiv(ctx->Exec, (location, count, v));
7138    }
7139 }
7140 
7141 
7142 
7143 static void GLAPIENTRY
save_UniformMatrix2fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7144 save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
7145                          const GLfloat *m)
7146 {
7147    GET_CURRENT_CONTEXT(ctx);
7148    Node *n;
7149    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7150    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 3 + POINTER_DWORDS);
7151    if (n) {
7152       n[1].i = location;
7153       n[2].i = count;
7154       n[3].b = transpose;
7155       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLfloat)));
7156    }
7157    if (ctx->ExecuteFlag) {
7158       CALL_UniformMatrix2fv(ctx->Exec, (location, count, transpose, m));
7159    }
7160 }
7161 
7162 static void GLAPIENTRY
save_UniformMatrix3fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7163 save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
7164                          const GLfloat *m)
7165 {
7166    GET_CURRENT_CONTEXT(ctx);
7167    Node *n;
7168    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7169    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 3 + POINTER_DWORDS);
7170    if (n) {
7171       n[1].i = location;
7172       n[2].i = count;
7173       n[3].b = transpose;
7174       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLfloat)));
7175    }
7176    if (ctx->ExecuteFlag) {
7177       CALL_UniformMatrix3fv(ctx->Exec, (location, count, transpose, m));
7178    }
7179 }
7180 
7181 static void GLAPIENTRY
save_UniformMatrix4fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7182 save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
7183                          const GLfloat *m)
7184 {
7185    GET_CURRENT_CONTEXT(ctx);
7186    Node *n;
7187    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7188    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 3 + POINTER_DWORDS);
7189    if (n) {
7190       n[1].i = location;
7191       n[2].i = count;
7192       n[3].b = transpose;
7193       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLfloat)));
7194    }
7195    if (ctx->ExecuteFlag) {
7196       CALL_UniformMatrix4fv(ctx->Exec, (location, count, transpose, m));
7197    }
7198 }
7199 
7200 
7201 static void GLAPIENTRY
save_UniformMatrix2x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7202 save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
7203                         const GLfloat *m)
7204 {
7205    GET_CURRENT_CONTEXT(ctx);
7206    Node *n;
7207    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7208    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 3 + POINTER_DWORDS);
7209    if (n) {
7210       n[1].i = location;
7211       n[2].i = count;
7212       n[3].b = transpose;
7213       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLfloat)));
7214    }
7215    if (ctx->ExecuteFlag) {
7216       CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m));
7217    }
7218 }
7219 
7220 static void GLAPIENTRY
save_UniformMatrix3x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7221 save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
7222                         const GLfloat *m)
7223 {
7224    GET_CURRENT_CONTEXT(ctx);
7225    Node *n;
7226    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7227    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 3 + POINTER_DWORDS);
7228    if (n) {
7229       n[1].i = location;
7230       n[2].i = count;
7231       n[3].b = transpose;
7232       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLfloat)));
7233    }
7234    if (ctx->ExecuteFlag) {
7235       CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m));
7236    }
7237 }
7238 
7239 
7240 static void GLAPIENTRY
save_UniformMatrix2x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7241 save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
7242                         const GLfloat *m)
7243 {
7244    GET_CURRENT_CONTEXT(ctx);
7245    Node *n;
7246    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7247    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 3 + POINTER_DWORDS);
7248    if (n) {
7249       n[1].i = location;
7250       n[2].i = count;
7251       n[3].b = transpose;
7252       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLfloat)));
7253    }
7254    if (ctx->ExecuteFlag) {
7255       CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m));
7256    }
7257 }
7258 
7259 static void GLAPIENTRY
save_UniformMatrix4x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7260 save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
7261                         const GLfloat *m)
7262 {
7263    GET_CURRENT_CONTEXT(ctx);
7264    Node *n;
7265    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7266    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 3 + POINTER_DWORDS);
7267    if (n) {
7268       n[1].i = location;
7269       n[2].i = count;
7270       n[3].b = transpose;
7271       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLfloat)));
7272    }
7273    if (ctx->ExecuteFlag) {
7274       CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m));
7275    }
7276 }
7277 
7278 
7279 static void GLAPIENTRY
save_UniformMatrix3x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7280 save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
7281                         const GLfloat *m)
7282 {
7283    GET_CURRENT_CONTEXT(ctx);
7284    Node *n;
7285    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7286    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 3 + POINTER_DWORDS);
7287    if (n) {
7288       n[1].i = location;
7289       n[2].i = count;
7290       n[3].b = transpose;
7291       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLfloat)));
7292    }
7293    if (ctx->ExecuteFlag) {
7294       CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m));
7295    }
7296 }
7297 
7298 static void GLAPIENTRY
save_UniformMatrix4x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7299 save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
7300                         const GLfloat *m)
7301 {
7302    GET_CURRENT_CONTEXT(ctx);
7303    Node *n;
7304    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7305    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 3 + POINTER_DWORDS);
7306    if (n) {
7307       n[1].i = location;
7308       n[2].i = count;
7309       n[3].b = transpose;
7310       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLfloat)));
7311    }
7312    if (ctx->ExecuteFlag) {
7313       CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m));
7314    }
7315 }
7316 
7317 
7318 static void GLAPIENTRY
save_UniformMatrix2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7319 save_UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose,
7320                       const GLdouble *m)
7321 {
7322    GET_CURRENT_CONTEXT(ctx);
7323    Node *n;
7324    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7325    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22D, 3 + POINTER_DWORDS);
7326    if (n) {
7327       n[1].i = location;
7328       n[2].i = count;
7329       n[3].b = transpose;
7330       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLdouble)));
7331    }
7332    if (ctx->ExecuteFlag) {
7333       CALL_UniformMatrix2dv(ctx->Exec, (location, count, transpose, m));
7334    }
7335 }
7336 
7337 static void GLAPIENTRY
save_UniformMatrix3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7338 save_UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose,
7339                       const GLdouble *m)
7340 {
7341    GET_CURRENT_CONTEXT(ctx);
7342    Node *n;
7343    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7344    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33D, 3 + POINTER_DWORDS);
7345    if (n) {
7346       n[1].i = location;
7347       n[2].i = count;
7348       n[3].b = transpose;
7349       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLdouble)));
7350    }
7351    if (ctx->ExecuteFlag) {
7352       CALL_UniformMatrix3dv(ctx->Exec, (location, count, transpose, m));
7353    }
7354 }
7355 
7356 static void GLAPIENTRY
save_UniformMatrix4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7357 save_UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose,
7358                       const GLdouble *m)
7359 {
7360    GET_CURRENT_CONTEXT(ctx);
7361    Node *n;
7362    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7363    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44D, 3 + POINTER_DWORDS);
7364    if (n) {
7365       n[1].i = location;
7366       n[2].i = count;
7367       n[3].b = transpose;
7368       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLdouble)));
7369    }
7370    if (ctx->ExecuteFlag) {
7371       CALL_UniformMatrix4dv(ctx->Exec, (location, count, transpose, m));
7372    }
7373 }
7374 
7375 
7376 static void GLAPIENTRY
save_UniformMatrix2x3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7377 save_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose,
7378                         const GLdouble *m)
7379 {
7380    GET_CURRENT_CONTEXT(ctx);
7381    Node *n;
7382    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7383    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23D, 3 + POINTER_DWORDS);
7384    if (n) {
7385       n[1].i = location;
7386       n[2].i = count;
7387       n[3].b = transpose;
7388       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLdouble)));
7389    }
7390    if (ctx->ExecuteFlag) {
7391       CALL_UniformMatrix2x3dv(ctx->Exec, (location, count, transpose, m));
7392    }
7393 }
7394 
7395 
7396 static void GLAPIENTRY
save_UniformMatrix3x2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7397 save_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose,
7398                         const GLdouble *m)
7399 {
7400    GET_CURRENT_CONTEXT(ctx);
7401    Node *n;
7402    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7403    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32D, 3 + POINTER_DWORDS);
7404    if (n) {
7405       n[1].i = location;
7406       n[2].i = count;
7407       n[3].b = transpose;
7408       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLdouble)));
7409    }
7410    if (ctx->ExecuteFlag) {
7411       CALL_UniformMatrix3x2dv(ctx->Exec, (location, count, transpose, m));
7412    }
7413 }
7414 
7415 
7416 static void GLAPIENTRY
save_UniformMatrix2x4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7417 save_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose,
7418                         const GLdouble *m)
7419 {
7420    GET_CURRENT_CONTEXT(ctx);
7421    Node *n;
7422    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7423    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24D, 3 + POINTER_DWORDS);
7424    if (n) {
7425       n[1].i = location;
7426       n[2].i = count;
7427       n[3].b = transpose;
7428       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLdouble)));
7429    }
7430    if (ctx->ExecuteFlag) {
7431       CALL_UniformMatrix2x4dv(ctx->Exec, (location, count, transpose, m));
7432    }
7433 }
7434 
7435 static void GLAPIENTRY
save_UniformMatrix4x2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7436 save_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose,
7437                         const GLdouble *m)
7438 {
7439    GET_CURRENT_CONTEXT(ctx);
7440    Node *n;
7441    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7442    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42D, 3 + POINTER_DWORDS);
7443    if (n) {
7444       n[1].i = location;
7445       n[2].i = count;
7446       n[3].b = transpose;
7447       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLdouble)));
7448    }
7449    if (ctx->ExecuteFlag) {
7450       CALL_UniformMatrix4x2dv(ctx->Exec, (location, count, transpose, m));
7451    }
7452 }
7453 
7454 
7455 static void GLAPIENTRY
save_UniformMatrix3x4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7456 save_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose,
7457                         const GLdouble *m)
7458 {
7459    GET_CURRENT_CONTEXT(ctx);
7460    Node *n;
7461    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7462    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34D, 3 + POINTER_DWORDS);
7463    if (n) {
7464       n[1].i = location;
7465       n[2].i = count;
7466       n[3].b = transpose;
7467       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLdouble)));
7468    }
7469    if (ctx->ExecuteFlag) {
7470       CALL_UniformMatrix3x4dv(ctx->Exec, (location, count, transpose, m));
7471    }
7472 }
7473 
7474 
7475 static void GLAPIENTRY
save_UniformMatrix4x3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7476 save_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose,
7477                         const GLdouble *m)
7478 {
7479    GET_CURRENT_CONTEXT(ctx);
7480    Node *n;
7481    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7482    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43D, 3 + POINTER_DWORDS);
7483    if (n) {
7484       n[1].i = location;
7485       n[2].i = count;
7486       n[3].b = transpose;
7487       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLdouble)));
7488    }
7489    if (ctx->ExecuteFlag) {
7490       CALL_UniformMatrix4x3dv(ctx->Exec, (location, count, transpose, m));
7491    }
7492 }
7493 
7494 static void GLAPIENTRY
save_Uniform1i64ARB(GLint location,GLint64 x)7495 save_Uniform1i64ARB(GLint location, GLint64 x)
7496 {
7497    GET_CURRENT_CONTEXT(ctx);
7498    Node *n;
7499    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7500    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64, 3);
7501    if (n) {
7502       n[1].i = location;
7503       ASSIGN_INT64_TO_NODES(n, 2, x);
7504    }
7505    if (ctx->ExecuteFlag) {
7506       CALL_Uniform1i64ARB(ctx->Exec, (location, x));
7507    }
7508 }
7509 
7510 static void GLAPIENTRY
save_Uniform2i64ARB(GLint location,GLint64 x,GLint64 y)7511 save_Uniform2i64ARB(GLint location, GLint64 x, GLint64 y)
7512 {
7513    GET_CURRENT_CONTEXT(ctx);
7514    Node *n;
7515    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7516    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64, 5);
7517    if (n) {
7518       n[1].i = location;
7519       ASSIGN_INT64_TO_NODES(n, 2, x);
7520       ASSIGN_INT64_TO_NODES(n, 4, y);
7521    }
7522    if (ctx->ExecuteFlag) {
7523       CALL_Uniform2i64ARB(ctx->Exec, (location, x, y));
7524    }
7525 }
7526 
7527 static void GLAPIENTRY
save_Uniform3i64ARB(GLint location,GLint64 x,GLint64 y,GLint64 z)7528 save_Uniform3i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z)
7529 {
7530    GET_CURRENT_CONTEXT(ctx);
7531    Node *n;
7532    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7533    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64, 7);
7534    if (n) {
7535       n[1].i = location;
7536       ASSIGN_INT64_TO_NODES(n, 2, x);
7537       ASSIGN_INT64_TO_NODES(n, 4, y);
7538       ASSIGN_INT64_TO_NODES(n, 6, z);
7539    }
7540    if (ctx->ExecuteFlag) {
7541       CALL_Uniform3i64ARB(ctx->Exec, (location, x, y, z));
7542    }
7543 }
7544 
7545 static void GLAPIENTRY
save_Uniform4i64ARB(GLint location,GLint64 x,GLint64 y,GLint64 z,GLint64 w)7546 save_Uniform4i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w)
7547 {
7548    GET_CURRENT_CONTEXT(ctx);
7549    Node *n;
7550    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7551    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64, 9);
7552    if (n) {
7553       n[1].i = location;
7554       ASSIGN_INT64_TO_NODES(n, 2, x);
7555       ASSIGN_INT64_TO_NODES(n, 4, y);
7556       ASSIGN_INT64_TO_NODES(n, 6, z);
7557       ASSIGN_INT64_TO_NODES(n, 8, w);
7558    }
7559    if (ctx->ExecuteFlag) {
7560       CALL_Uniform4i64ARB(ctx->Exec, (location, x, y, z, w));
7561    }
7562 }
7563 
7564 static void GLAPIENTRY
save_Uniform1i64vARB(GLint location,GLsizei count,const GLint64 * v)7565 save_Uniform1i64vARB(GLint location, GLsizei count, const GLint64 *v)
7566 {
7567    GET_CURRENT_CONTEXT(ctx);
7568    Node *n;
7569    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7570    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64V, 2 + POINTER_DWORDS);
7571    if (n) {
7572      n[1].i = location;
7573      n[2].i = count;
7574      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint64)));
7575    }
7576    if (ctx->ExecuteFlag) {
7577       CALL_Uniform1i64vARB(ctx->Exec, (location, count, v));
7578    }
7579 }
7580 
7581 static void GLAPIENTRY
save_Uniform2i64vARB(GLint location,GLsizei count,const GLint64 * v)7582 save_Uniform2i64vARB(GLint location, GLsizei count, const GLint64 *v)
7583 {
7584    GET_CURRENT_CONTEXT(ctx);
7585    Node *n;
7586    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7587    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64V, 2 + POINTER_DWORDS);
7588    if (n) {
7589      n[1].i = location;
7590      n[2].i = count;
7591      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint64)));
7592    }
7593    if (ctx->ExecuteFlag) {
7594       CALL_Uniform2i64vARB(ctx->Exec, (location, count, v));
7595    }
7596 }
7597 
7598 static void GLAPIENTRY
save_Uniform3i64vARB(GLint location,GLsizei count,const GLint64 * v)7599 save_Uniform3i64vARB(GLint location, GLsizei count, const GLint64 *v)
7600 {
7601    GET_CURRENT_CONTEXT(ctx);
7602    Node *n;
7603    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7604    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64V, 2 + POINTER_DWORDS);
7605    if (n) {
7606      n[1].i = location;
7607      n[2].i = count;
7608      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint64)));
7609    }
7610    if (ctx->ExecuteFlag) {
7611       CALL_Uniform3i64vARB(ctx->Exec, (location, count, v));
7612    }
7613 }
7614 
7615 static void GLAPIENTRY
save_Uniform4i64vARB(GLint location,GLsizei count,const GLint64 * v)7616 save_Uniform4i64vARB(GLint location, GLsizei count, const GLint64 *v)
7617 {
7618    GET_CURRENT_CONTEXT(ctx);
7619    Node *n;
7620    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7621    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64V, 2 + POINTER_DWORDS);
7622    if (n) {
7623      n[1].i = location;
7624      n[2].i = count;
7625      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint64)));
7626    }
7627    if (ctx->ExecuteFlag) {
7628       CALL_Uniform4i64vARB(ctx->Exec, (location, count, v));
7629    }
7630 }
7631 
7632 static void GLAPIENTRY
save_Uniform1ui64ARB(GLint location,GLuint64 x)7633 save_Uniform1ui64ARB(GLint location, GLuint64 x)
7634 {
7635    GET_CURRENT_CONTEXT(ctx);
7636    Node *n;
7637    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7638    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64, 3);
7639    if (n) {
7640       n[1].i = location;
7641       ASSIGN_UINT64_TO_NODES(n, 2, x);
7642    }
7643    if (ctx->ExecuteFlag) {
7644       CALL_Uniform1ui64ARB(ctx->Exec, (location, x));
7645    }
7646 }
7647 
7648 static void GLAPIENTRY
save_Uniform2ui64ARB(GLint location,GLuint64 x,GLuint64 y)7649 save_Uniform2ui64ARB(GLint location, GLuint64 x, GLuint64 y)
7650 {
7651    GET_CURRENT_CONTEXT(ctx);
7652    Node *n;
7653    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7654    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64, 5);
7655    if (n) {
7656       n[1].i = location;
7657       ASSIGN_UINT64_TO_NODES(n, 2, x);
7658       ASSIGN_UINT64_TO_NODES(n, 4, y);
7659    }
7660    if (ctx->ExecuteFlag) {
7661       CALL_Uniform2ui64ARB(ctx->Exec, (location, x, y));
7662    }
7663 }
7664 
7665 static void GLAPIENTRY
save_Uniform3ui64ARB(GLint location,GLuint64 x,GLuint64 y,GLuint64 z)7666 save_Uniform3ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z)
7667 {
7668    GET_CURRENT_CONTEXT(ctx);
7669    Node *n;
7670    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7671    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64, 7);
7672    if (n) {
7673       n[1].i = location;
7674       ASSIGN_UINT64_TO_NODES(n, 2, x);
7675       ASSIGN_UINT64_TO_NODES(n, 4, y);
7676       ASSIGN_UINT64_TO_NODES(n, 6, z);
7677    }
7678    if (ctx->ExecuteFlag) {
7679       CALL_Uniform3ui64ARB(ctx->Exec, (location, x, y, z));
7680    }
7681 }
7682 
7683 static void GLAPIENTRY
save_Uniform4ui64ARB(GLint location,GLuint64 x,GLuint64 y,GLuint64 z,GLuint64 w)7684 save_Uniform4ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w)
7685 {
7686    GET_CURRENT_CONTEXT(ctx);
7687    Node *n;
7688    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7689    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64, 9);
7690    if (n) {
7691       n[1].i = location;
7692       ASSIGN_UINT64_TO_NODES(n, 2, x);
7693       ASSIGN_UINT64_TO_NODES(n, 4, y);
7694       ASSIGN_UINT64_TO_NODES(n, 6, z);
7695       ASSIGN_UINT64_TO_NODES(n, 8, w);
7696    }
7697    if (ctx->ExecuteFlag) {
7698       CALL_Uniform4ui64ARB(ctx->Exec, (location, x, y, z, w));
7699    }
7700 }
7701 
7702 static void GLAPIENTRY
save_Uniform1ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7703 save_Uniform1ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7704 {
7705    GET_CURRENT_CONTEXT(ctx);
7706    Node *n;
7707    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7708    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64V, 2 + POINTER_DWORDS);
7709    if (n) {
7710      n[1].i = location;
7711      n[2].i = count;
7712      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLuint64)));
7713    }
7714    if (ctx->ExecuteFlag) {
7715       CALL_Uniform1ui64vARB(ctx->Exec, (location, count, v));
7716    }
7717 }
7718 
7719 static void GLAPIENTRY
save_Uniform2ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7720 save_Uniform2ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7721 {
7722    GET_CURRENT_CONTEXT(ctx);
7723    Node *n;
7724    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7725    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64V, 2 + POINTER_DWORDS);
7726    if (n) {
7727      n[1].i = location;
7728      n[2].i = count;
7729      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLuint64)));
7730    }
7731    if (ctx->ExecuteFlag) {
7732       CALL_Uniform2ui64vARB(ctx->Exec, (location, count, v));
7733    }
7734 }
7735 
7736 static void GLAPIENTRY
save_Uniform3ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7737 save_Uniform3ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7738 {
7739    GET_CURRENT_CONTEXT(ctx);
7740    Node *n;
7741    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7742    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64V, 2 + POINTER_DWORDS);
7743    if (n) {
7744      n[1].i = location;
7745      n[2].i = count;
7746      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLuint64)));
7747    }
7748    if (ctx->ExecuteFlag) {
7749       CALL_Uniform3ui64vARB(ctx->Exec, (location, count, v));
7750    }
7751 }
7752 
7753 static void GLAPIENTRY
save_Uniform4ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7754 save_Uniform4ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7755 {
7756    GET_CURRENT_CONTEXT(ctx);
7757    Node *n;
7758    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7759    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64V, 2 + POINTER_DWORDS);
7760    if (n) {
7761      n[1].i = location;
7762      n[2].i = count;
7763      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLuint64)));
7764    }
7765    if (ctx->ExecuteFlag) {
7766       CALL_Uniform4ui64vARB(ctx->Exec, (location, count, v));
7767    }
7768 }
7769 
7770 static void GLAPIENTRY
save_ProgramUniform1i64ARB(GLuint program,GLint location,GLint64 x)7771 save_ProgramUniform1i64ARB(GLuint program, GLint location, GLint64 x)
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_1I64, 4);
7777    if (n) {
7778       n[1].ui = program;
7779       n[2].i = location;
7780       ASSIGN_INT64_TO_NODES(n, 3, x);
7781    }
7782    if (ctx->ExecuteFlag) {
7783       CALL_ProgramUniform1i64ARB(ctx->Exec, (program, location, x));
7784    }
7785 }
7786 
7787 static void GLAPIENTRY
save_ProgramUniform2i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y)7788 save_ProgramUniform2i64ARB(GLuint program, GLint location, GLint64 x,
7789                            GLint64 y)
7790 {
7791    GET_CURRENT_CONTEXT(ctx);
7792    Node *n;
7793    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7794    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64, 6);
7795    if (n) {
7796       n[1].ui = program;
7797       n[2].i = location;
7798       ASSIGN_INT64_TO_NODES(n, 3, x);
7799       ASSIGN_INT64_TO_NODES(n, 5, y);
7800    }
7801    if (ctx->ExecuteFlag) {
7802       CALL_ProgramUniform2i64ARB(ctx->Exec, (program, location, x, y));
7803    }
7804 }
7805 
7806 static void GLAPIENTRY
save_ProgramUniform3i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y,GLint64 z)7807 save_ProgramUniform3i64ARB(GLuint program, GLint location, GLint64 x,
7808                            GLint64 y, GLint64 z)
7809 {
7810    GET_CURRENT_CONTEXT(ctx);
7811    Node *n;
7812    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7813    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64, 8);
7814    if (n) {
7815       n[1].ui = program;
7816       n[2].i = location;
7817       ASSIGN_INT64_TO_NODES(n, 3, x);
7818       ASSIGN_INT64_TO_NODES(n, 5, y);
7819       ASSIGN_INT64_TO_NODES(n, 7, z);
7820    }
7821    if (ctx->ExecuteFlag) {
7822       CALL_ProgramUniform3i64ARB(ctx->Exec, (program, location, x, y, z));
7823    }
7824 }
7825 
7826 static void GLAPIENTRY
save_ProgramUniform4i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y,GLint64 z,GLint64 w)7827 save_ProgramUniform4i64ARB(GLuint program, GLint location, GLint64 x,
7828                            GLint64 y, GLint64 z, GLint64 w)
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_4I64, 10);
7834    if (n) {
7835       n[1].ui = program;
7836       n[2].i = location;
7837       ASSIGN_INT64_TO_NODES(n, 3, x);
7838       ASSIGN_INT64_TO_NODES(n, 5, y);
7839       ASSIGN_INT64_TO_NODES(n, 7, z);
7840       ASSIGN_INT64_TO_NODES(n, 9, w);
7841    }
7842    if (ctx->ExecuteFlag) {
7843       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7844    }
7845 }
7846 
7847 static void GLAPIENTRY
save_ProgramUniform1i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7848 save_ProgramUniform1i64vARB(GLuint program, GLint location, GLsizei count,
7849                             const GLint64 *v)
7850 {
7851    GET_CURRENT_CONTEXT(ctx);
7852    Node *n;
7853    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7854    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I64V, 3 + POINTER_DWORDS);
7855    if (n) {
7856       n[1].ui = program;
7857       n[2].i = location;
7858       n[3].i = count;
7859       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7860    }
7861    if (ctx->ExecuteFlag) {
7862       CALL_ProgramUniform1i64vARB(ctx->Exec, (program, location, count, v));
7863    }
7864 }
7865 
7866 static void GLAPIENTRY
save_ProgramUniform2i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7867 save_ProgramUniform2i64vARB(GLuint program, GLint location, GLsizei count,
7868                             const GLint64 *v)
7869 {
7870    GET_CURRENT_CONTEXT(ctx);
7871    Node *n;
7872    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7873    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64V, 3 + POINTER_DWORDS);
7874    if (n) {
7875       n[1].ui = program;
7876       n[2].i = location;
7877       n[3].i = count;
7878       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7879    }
7880    if (ctx->ExecuteFlag) {
7881       CALL_ProgramUniform2i64vARB(ctx->Exec, (program, location, count, v));
7882    }
7883 }
7884 
7885 static void GLAPIENTRY
save_ProgramUniform3i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7886 save_ProgramUniform3i64vARB(GLuint program, GLint location, GLsizei count,
7887                             const GLint64 *v)
7888 {
7889    GET_CURRENT_CONTEXT(ctx);
7890    Node *n;
7891    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7892    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64V, 3 + POINTER_DWORDS);
7893    if (n) {
7894       n[1].ui = program;
7895       n[2].i = location;
7896       n[3].i = count;
7897       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7898    }
7899    if (ctx->ExecuteFlag) {
7900       CALL_ProgramUniform3i64vARB(ctx->Exec, (program, location, count, v));
7901    }
7902 }
7903 
7904 static void GLAPIENTRY
save_ProgramUniform4i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7905 save_ProgramUniform4i64vARB(GLuint program, GLint location, GLsizei count,
7906                             const GLint64 *v)
7907 {
7908    GET_CURRENT_CONTEXT(ctx);
7909    Node *n;
7910    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7911    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I64V, 3 + POINTER_DWORDS);
7912    if (n) {
7913       n[1].ui = program;
7914       n[2].i = location;
7915       n[3].i = count;
7916       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7917    }
7918    if (ctx->ExecuteFlag) {
7919       CALL_ProgramUniform4i64vARB(ctx->Exec, (program, location, count, v));
7920    }
7921 }
7922 
7923 static void GLAPIENTRY
save_ProgramUniform1ui64ARB(GLuint program,GLint location,GLuint64 x)7924 save_ProgramUniform1ui64ARB(GLuint program, GLint location, GLuint64 x)
7925 {
7926    GET_CURRENT_CONTEXT(ctx);
7927    Node *n;
7928    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7929    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64, 4);
7930    if (n) {
7931       n[1].ui = program;
7932       n[2].i = location;
7933       ASSIGN_UINT64_TO_NODES(n, 3, x);
7934    }
7935    if (ctx->ExecuteFlag) {
7936       CALL_ProgramUniform1ui64ARB(ctx->Exec, (program, location, x));
7937    }
7938 }
7939 
7940 static void GLAPIENTRY
save_ProgramUniform2ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y)7941 save_ProgramUniform2ui64ARB(GLuint program, GLint location, GLuint64 x,
7942                             GLuint64 y)
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_2UI64, 6);
7948    if (n) {
7949       n[1].ui = program;
7950       n[2].i = location;
7951       ASSIGN_UINT64_TO_NODES(n, 3, x);
7952       ASSIGN_UINT64_TO_NODES(n, 5, y);
7953    }
7954    if (ctx->ExecuteFlag) {
7955       CALL_ProgramUniform2ui64ARB(ctx->Exec, (program, location, x, y));
7956    }
7957 }
7958 
7959 static void GLAPIENTRY
save_ProgramUniform3ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y,GLuint64 z)7960 save_ProgramUniform3ui64ARB(GLuint program, GLint location, GLuint64 x,
7961                             GLuint64 y, GLuint64 z)
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_3UI64, 8);
7967    if (n) {
7968       n[1].ui = program;
7969       n[2].i = location;
7970       ASSIGN_UINT64_TO_NODES(n, 3, x);
7971       ASSIGN_UINT64_TO_NODES(n, 5, y);
7972       ASSIGN_UINT64_TO_NODES(n, 7, z);
7973    }
7974    if (ctx->ExecuteFlag) {
7975       CALL_ProgramUniform3ui64ARB(ctx->Exec, (program, location, x, y, z));
7976    }
7977 }
7978 
7979 static void GLAPIENTRY
save_ProgramUniform4ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y,GLuint64 z,GLuint64 w)7980 save_ProgramUniform4ui64ARB(GLuint program, GLint location, GLuint64 x,
7981                             GLuint64 y, GLuint64 z, GLuint64 w)
7982 {
7983    GET_CURRENT_CONTEXT(ctx);
7984    Node *n;
7985    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7986    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64, 10);
7987    if (n) {
7988       n[1].ui = program;
7989       n[2].i = location;
7990       ASSIGN_UINT64_TO_NODES(n, 3, x);
7991       ASSIGN_UINT64_TO_NODES(n, 5, y);
7992       ASSIGN_UINT64_TO_NODES(n, 7, z);
7993       ASSIGN_UINT64_TO_NODES(n, 9, w);
7994    }
7995    if (ctx->ExecuteFlag) {
7996       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7997    }
7998 }
7999 
8000 static void GLAPIENTRY
save_ProgramUniform1ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)8001 save_ProgramUniform1ui64vARB(GLuint program, GLint location, GLsizei count,
8002                              const GLuint64 *v)
8003 {
8004    GET_CURRENT_CONTEXT(ctx);
8005    Node *n;
8006    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8007    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64V,
8008                          3 + POINTER_DWORDS);
8009    if (n) {
8010       n[1].ui = program;
8011       n[2].i = location;
8012       n[3].i = count;
8013       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
8014    }
8015    if (ctx->ExecuteFlag) {
8016       CALL_ProgramUniform1ui64vARB(ctx->Exec, (program, location, count, v));
8017    }
8018 }
8019 
8020 static void GLAPIENTRY
save_ProgramUniform2ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)8021 save_ProgramUniform2ui64vARB(GLuint program, GLint location, GLsizei count,
8022                             const GLuint64 *v)
8023 {
8024    GET_CURRENT_CONTEXT(ctx);
8025    Node *n;
8026    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8027    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI64V,
8028                          3 + POINTER_DWORDS);
8029    if (n) {
8030       n[1].ui = program;
8031       n[2].i = location;
8032       n[3].i = count;
8033       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
8034    }
8035    if (ctx->ExecuteFlag) {
8036       CALL_ProgramUniform2ui64vARB(ctx->Exec, (program, location, count, v));
8037    }
8038 }
8039 
8040 static void GLAPIENTRY
save_ProgramUniform3ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)8041 save_ProgramUniform3ui64vARB(GLuint program, GLint location, GLsizei count,
8042                              const GLuint64 *v)
8043 {
8044    GET_CURRENT_CONTEXT(ctx);
8045    Node *n;
8046    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8047    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI64V,
8048                          3 + POINTER_DWORDS);
8049    if (n) {
8050       n[1].ui = program;
8051       n[2].i = location;
8052       n[3].i = count;
8053       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
8054    }
8055    if (ctx->ExecuteFlag) {
8056       CALL_ProgramUniform3ui64vARB(ctx->Exec, (program, location, count, v));
8057    }
8058 }
8059 
8060 static void GLAPIENTRY
save_ProgramUniform4ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)8061 save_ProgramUniform4ui64vARB(GLuint program, GLint location, GLsizei count,
8062                              const GLuint64 *v)
8063 {
8064    GET_CURRENT_CONTEXT(ctx);
8065    Node *n;
8066    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8067    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64V,
8068                          3 + POINTER_DWORDS);
8069    if (n) {
8070       n[1].ui = program;
8071       n[2].i = location;
8072       n[3].i = count;
8073       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
8074    }
8075    if (ctx->ExecuteFlag) {
8076       CALL_ProgramUniform4ui64vARB(ctx->Exec, (program, location, count, v));
8077    }
8078 }
8079 
8080 
8081 static void GLAPIENTRY
save_UseProgramStages(GLuint pipeline,GLbitfield stages,GLuint program)8082 save_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
8083 {
8084    GET_CURRENT_CONTEXT(ctx);
8085    Node *n;
8086    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8087    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM_STAGES, 3);
8088    if (n) {
8089       n[1].ui = pipeline;
8090       n[2].ui = stages;
8091       n[3].ui = program;
8092    }
8093    if (ctx->ExecuteFlag) {
8094       CALL_UseProgramStages(ctx->Exec, (pipeline, stages, program));
8095    }
8096 }
8097 
8098 static void GLAPIENTRY
save_ProgramUniform1f(GLuint program,GLint location,GLfloat x)8099 save_ProgramUniform1f(GLuint program, GLint location, GLfloat x)
8100 {
8101    GET_CURRENT_CONTEXT(ctx);
8102    Node *n;
8103    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8104    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1F, 3);
8105    if (n) {
8106       n[1].ui = program;
8107       n[2].i = location;
8108       n[3].f = x;
8109    }
8110    if (ctx->ExecuteFlag) {
8111       CALL_ProgramUniform1f(ctx->Exec, (program, location, x));
8112    }
8113 }
8114 
8115 static void GLAPIENTRY
save_ProgramUniform2f(GLuint program,GLint location,GLfloat x,GLfloat y)8116 save_ProgramUniform2f(GLuint program, GLint location, GLfloat x, GLfloat y)
8117 {
8118    GET_CURRENT_CONTEXT(ctx);
8119    Node *n;
8120    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8121    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2F, 4);
8122    if (n) {
8123       n[1].ui = program;
8124       n[2].i = location;
8125       n[3].f = x;
8126       n[4].f = y;
8127    }
8128    if (ctx->ExecuteFlag) {
8129       CALL_ProgramUniform2f(ctx->Exec, (program, location, x, y));
8130    }
8131 }
8132 
8133 static void GLAPIENTRY
save_ProgramUniform3f(GLuint program,GLint location,GLfloat x,GLfloat y,GLfloat z)8134 save_ProgramUniform3f(GLuint program, GLint location,
8135                       GLfloat x, GLfloat y, GLfloat z)
8136 {
8137    GET_CURRENT_CONTEXT(ctx);
8138    Node *n;
8139    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8140    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3F, 5);
8141    if (n) {
8142       n[1].ui = program;
8143       n[2].i = location;
8144       n[3].f = x;
8145       n[4].f = y;
8146       n[5].f = z;
8147    }
8148    if (ctx->ExecuteFlag) {
8149       CALL_ProgramUniform3f(ctx->Exec, (program, location, x, y, z));
8150    }
8151 }
8152 
8153 static void GLAPIENTRY
save_ProgramUniform4f(GLuint program,GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)8154 save_ProgramUniform4f(GLuint program, GLint location,
8155                       GLfloat x, GLfloat y, GLfloat z, GLfloat w)
8156 {
8157    GET_CURRENT_CONTEXT(ctx);
8158    Node *n;
8159    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8160    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4F, 6);
8161    if (n) {
8162       n[1].ui = program;
8163       n[2].i = location;
8164       n[3].f = x;
8165       n[4].f = y;
8166       n[5].f = z;
8167       n[6].f = w;
8168    }
8169    if (ctx->ExecuteFlag) {
8170       CALL_ProgramUniform4f(ctx->Exec, (program, location, x, y, z, w));
8171    }
8172 }
8173 
8174 static void GLAPIENTRY
save_ProgramUniform1fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8175 save_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
8176                        const GLfloat *v)
8177 {
8178    GET_CURRENT_CONTEXT(ctx);
8179    Node *n;
8180    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8181    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1FV, 3 + POINTER_DWORDS);
8182    if (n) {
8183       n[1].ui = program;
8184       n[2].i = location;
8185       n[3].i = count;
8186       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLfloat)));
8187    }
8188    if (ctx->ExecuteFlag) {
8189       CALL_ProgramUniform1fv(ctx->Exec, (program, location, count, v));
8190    }
8191 }
8192 
8193 static void GLAPIENTRY
save_ProgramUniform2fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8194 save_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
8195                        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_2FV, 3 + POINTER_DWORDS);
8201    if (n) {
8202       n[1].ui = program;
8203       n[2].i = location;
8204       n[3].i = count;
8205       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLfloat)));
8206    }
8207    if (ctx->ExecuteFlag) {
8208       CALL_ProgramUniform2fv(ctx->Exec, (program, location, count, v));
8209    }
8210 }
8211 
8212 static void GLAPIENTRY
save_ProgramUniform3fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8213 save_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
8214                        const GLfloat *v)
8215 {
8216    GET_CURRENT_CONTEXT(ctx);
8217    Node *n;
8218    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8219    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3FV, 3 + POINTER_DWORDS);
8220    if (n) {
8221       n[1].ui = program;
8222       n[2].i = location;
8223       n[3].i = count;
8224       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLfloat)));
8225    }
8226    if (ctx->ExecuteFlag) {
8227       CALL_ProgramUniform3fv(ctx->Exec, (program, location, count, v));
8228    }
8229 }
8230 
8231 static void GLAPIENTRY
save_ProgramUniform4fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8232 save_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
8233                        const GLfloat *v)
8234 {
8235    GET_CURRENT_CONTEXT(ctx);
8236    Node *n;
8237    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8238    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4FV, 3 + POINTER_DWORDS);
8239    if (n) {
8240       n[1].ui = program;
8241       n[2].i = location;
8242       n[3].i = count;
8243       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLfloat)));
8244    }
8245    if (ctx->ExecuteFlag) {
8246       CALL_ProgramUniform4fv(ctx->Exec, (program, location, count, v));
8247    }
8248 }
8249 
8250 static void GLAPIENTRY
save_ProgramUniform1d(GLuint program,GLint location,GLdouble x)8251 save_ProgramUniform1d(GLuint program, GLint location, GLdouble x)
8252 {
8253    GET_CURRENT_CONTEXT(ctx);
8254    Node *n;
8255    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8256    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1D, 4);
8257    if (n) {
8258       n[1].ui = program;
8259       n[2].i = location;
8260       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8261    }
8262    if (ctx->ExecuteFlag) {
8263       CALL_ProgramUniform1d(ctx->Exec, (program, location, x));
8264    }
8265 }
8266 
8267 static void GLAPIENTRY
save_ProgramUniform2d(GLuint program,GLint location,GLdouble x,GLdouble y)8268 save_ProgramUniform2d(GLuint program, GLint location, GLdouble x, GLdouble y)
8269 {
8270    GET_CURRENT_CONTEXT(ctx);
8271    Node *n;
8272    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8273    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2D, 6);
8274    if (n) {
8275       n[1].ui = program;
8276       n[2].i = location;
8277       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8278       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8279    }
8280    if (ctx->ExecuteFlag) {
8281       CALL_ProgramUniform2d(ctx->Exec, (program, location, x, y));
8282    }
8283 }
8284 
8285 static void GLAPIENTRY
save_ProgramUniform3d(GLuint program,GLint location,GLdouble x,GLdouble y,GLdouble z)8286 save_ProgramUniform3d(GLuint program, GLint location,
8287                       GLdouble x, GLdouble y, GLdouble z)
8288 {
8289    GET_CURRENT_CONTEXT(ctx);
8290    Node *n;
8291    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8292    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3D, 8);
8293    if (n) {
8294       n[1].ui = program;
8295       n[2].i = location;
8296       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8297       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8298       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
8299    }
8300    if (ctx->ExecuteFlag) {
8301       CALL_ProgramUniform3d(ctx->Exec, (program, location, x, y, z));
8302    }
8303 }
8304 
8305 static void GLAPIENTRY
save_ProgramUniform4d(GLuint program,GLint location,GLdouble x,GLdouble y,GLdouble z,GLdouble w)8306 save_ProgramUniform4d(GLuint program, GLint location,
8307                       GLdouble x, GLdouble y, GLdouble z, GLdouble w)
8308 {
8309    GET_CURRENT_CONTEXT(ctx);
8310    Node *n;
8311    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8312    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4D, 10);
8313    if (n) {
8314       n[1].ui = program;
8315       n[2].i = location;
8316       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8317       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8318       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
8319       ASSIGN_DOUBLE_TO_NODES(n, 9, w);
8320    }
8321    if (ctx->ExecuteFlag) {
8322       CALL_ProgramUniform4d(ctx->Exec, (program, location, x, y, z, w));
8323    }
8324 }
8325 
8326 static void GLAPIENTRY
save_ProgramUniform1dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8327 save_ProgramUniform1dv(GLuint program, GLint location, GLsizei count,
8328                        const GLdouble *v)
8329 {
8330    GET_CURRENT_CONTEXT(ctx);
8331    Node *n;
8332    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8333    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1DV, 3 + POINTER_DWORDS);
8334    if (n) {
8335       n[1].ui = program;
8336       n[2].i = location;
8337       n[3].i = count;
8338       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLdouble)));
8339    }
8340    if (ctx->ExecuteFlag) {
8341       CALL_ProgramUniform1dv(ctx->Exec, (program, location, count, v));
8342    }
8343 }
8344 
8345 static void GLAPIENTRY
save_ProgramUniform2dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8346 save_ProgramUniform2dv(GLuint program, GLint location, GLsizei count,
8347                        const GLdouble *v)
8348 {
8349    GET_CURRENT_CONTEXT(ctx);
8350    Node *n;
8351    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8352    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2DV, 3 + POINTER_DWORDS);
8353    if (n) {
8354       n[1].ui = program;
8355       n[2].i = location;
8356       n[3].i = count;
8357       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLdouble)));
8358    }
8359    if (ctx->ExecuteFlag) {
8360       CALL_ProgramUniform2dv(ctx->Exec, (program, location, count, v));
8361    }
8362 }
8363 
8364 static void GLAPIENTRY
save_ProgramUniform3dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8365 save_ProgramUniform3dv(GLuint program, GLint location, GLsizei count,
8366                        const GLdouble *v)
8367 {
8368    GET_CURRENT_CONTEXT(ctx);
8369    Node *n;
8370    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8371    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3DV, 3 + POINTER_DWORDS);
8372    if (n) {
8373       n[1].ui = program;
8374       n[2].i = location;
8375       n[3].i = count;
8376       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLdouble)));
8377    }
8378    if (ctx->ExecuteFlag) {
8379       CALL_ProgramUniform3dv(ctx->Exec, (program, location, count, v));
8380    }
8381 }
8382 
8383 static void GLAPIENTRY
save_ProgramUniform4dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8384 save_ProgramUniform4dv(GLuint program, GLint location, GLsizei count,
8385                        const GLdouble *v)
8386 {
8387    GET_CURRENT_CONTEXT(ctx);
8388    Node *n;
8389    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8390    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4DV, 3 + POINTER_DWORDS);
8391    if (n) {
8392       n[1].ui = program;
8393       n[2].i = location;
8394       n[3].i = count;
8395       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLdouble)));
8396    }
8397    if (ctx->ExecuteFlag) {
8398       CALL_ProgramUniform4dv(ctx->Exec, (program, location, count, v));
8399    }
8400 }
8401 
8402 static void GLAPIENTRY
save_ProgramUniform1i(GLuint program,GLint location,GLint x)8403 save_ProgramUniform1i(GLuint program, GLint location, GLint x)
8404 {
8405    GET_CURRENT_CONTEXT(ctx);
8406    Node *n;
8407    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8408    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I, 3);
8409    if (n) {
8410       n[1].ui = program;
8411       n[2].i = location;
8412       n[3].i = x;
8413    }
8414    if (ctx->ExecuteFlag) {
8415       CALL_ProgramUniform1i(ctx->Exec, (program, location, x));
8416    }
8417 }
8418 
8419 static void GLAPIENTRY
save_ProgramUniform2i(GLuint program,GLint location,GLint x,GLint y)8420 save_ProgramUniform2i(GLuint program, GLint location, GLint x, GLint y)
8421 {
8422    GET_CURRENT_CONTEXT(ctx);
8423    Node *n;
8424    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8425    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I, 4);
8426    if (n) {
8427       n[1].ui = program;
8428       n[2].i = location;
8429       n[3].i = x;
8430       n[4].i = y;
8431    }
8432    if (ctx->ExecuteFlag) {
8433       CALL_ProgramUniform2i(ctx->Exec, (program, location, x, y));
8434    }
8435 }
8436 
8437 static void GLAPIENTRY
save_ProgramUniform3i(GLuint program,GLint location,GLint x,GLint y,GLint z)8438 save_ProgramUniform3i(GLuint program, GLint location,
8439                       GLint x, GLint y, GLint z)
8440 {
8441    GET_CURRENT_CONTEXT(ctx);
8442    Node *n;
8443    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8444    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I, 5);
8445    if (n) {
8446       n[1].ui = program;
8447       n[2].i = location;
8448       n[3].i = x;
8449       n[4].i = y;
8450       n[5].i = z;
8451    }
8452    if (ctx->ExecuteFlag) {
8453       CALL_ProgramUniform3i(ctx->Exec, (program, location, x, y, z));
8454    }
8455 }
8456 
8457 static void GLAPIENTRY
save_ProgramUniform4i(GLuint program,GLint location,GLint x,GLint y,GLint z,GLint w)8458 save_ProgramUniform4i(GLuint program, GLint location,
8459                       GLint x, GLint y, GLint z, GLint w)
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_4I, 6);
8465    if (n) {
8466       n[1].ui = program;
8467       n[2].i = location;
8468       n[3].i = x;
8469       n[4].i = y;
8470       n[5].i = z;
8471       n[6].i = w;
8472    }
8473    if (ctx->ExecuteFlag) {
8474       CALL_ProgramUniform4i(ctx->Exec, (program, location, x, y, z, w));
8475    }
8476 }
8477 
8478 static void GLAPIENTRY
save_ProgramUniform1iv(GLuint program,GLint location,GLsizei count,const GLint * v)8479 save_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
8480                        const GLint *v)
8481 {
8482    GET_CURRENT_CONTEXT(ctx);
8483    Node *n;
8484    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8485    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1IV, 3 + POINTER_DWORDS);
8486    if (n) {
8487       n[1].ui = program;
8488       n[2].i = location;
8489       n[3].i = count;
8490       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint)));
8491    }
8492    if (ctx->ExecuteFlag) {
8493       CALL_ProgramUniform1iv(ctx->Exec, (program, location, count, v));
8494    }
8495 }
8496 
8497 static void GLAPIENTRY
save_ProgramUniform2iv(GLuint program,GLint location,GLsizei count,const GLint * v)8498 save_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
8499                        const GLint *v)
8500 {
8501    GET_CURRENT_CONTEXT(ctx);
8502    Node *n;
8503    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8504    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2IV, 3 + POINTER_DWORDS);
8505    if (n) {
8506       n[1].ui = program;
8507       n[2].i = location;
8508       n[3].i = count;
8509       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLint)));
8510    }
8511    if (ctx->ExecuteFlag) {
8512       CALL_ProgramUniform2iv(ctx->Exec, (program, location, count, v));
8513    }
8514 }
8515 
8516 static void GLAPIENTRY
save_ProgramUniform3iv(GLuint program,GLint location,GLsizei count,const GLint * v)8517 save_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
8518                        const GLint *v)
8519 {
8520    GET_CURRENT_CONTEXT(ctx);
8521    Node *n;
8522    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8523    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3IV, 3 + POINTER_DWORDS);
8524    if (n) {
8525       n[1].ui = program;
8526       n[2].i = location;
8527       n[3].i = count;
8528       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLint)));
8529    }
8530    if (ctx->ExecuteFlag) {
8531       CALL_ProgramUniform3iv(ctx->Exec, (program, location, count, v));
8532    }
8533 }
8534 
8535 static void GLAPIENTRY
save_ProgramUniform4iv(GLuint program,GLint location,GLsizei count,const GLint * v)8536 save_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
8537                        const GLint *v)
8538 {
8539    GET_CURRENT_CONTEXT(ctx);
8540    Node *n;
8541    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8542    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4IV, 3 + POINTER_DWORDS);
8543    if (n) {
8544       n[1].ui = program;
8545       n[2].i = location;
8546       n[3].i = count;
8547       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLint)));
8548    }
8549    if (ctx->ExecuteFlag) {
8550       CALL_ProgramUniform4iv(ctx->Exec, (program, location, count, v));
8551    }
8552 }
8553 
8554 static void GLAPIENTRY
save_ProgramUniform1ui(GLuint program,GLint location,GLuint x)8555 save_ProgramUniform1ui(GLuint program, GLint location, GLuint x)
8556 {
8557    GET_CURRENT_CONTEXT(ctx);
8558    Node *n;
8559    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8560    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI, 3);
8561    if (n) {
8562       n[1].ui = program;
8563       n[2].i = location;
8564       n[3].ui = x;
8565    }
8566    if (ctx->ExecuteFlag) {
8567       CALL_ProgramUniform1ui(ctx->Exec, (program, location, x));
8568    }
8569 }
8570 
8571 static void GLAPIENTRY
save_ProgramUniform2ui(GLuint program,GLint location,GLuint x,GLuint y)8572 save_ProgramUniform2ui(GLuint program, GLint location, GLuint x, GLuint y)
8573 {
8574    GET_CURRENT_CONTEXT(ctx);
8575    Node *n;
8576    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8577    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI, 4);
8578    if (n) {
8579       n[1].ui = program;
8580       n[2].i = location;
8581       n[3].ui = x;
8582       n[4].ui = y;
8583    }
8584    if (ctx->ExecuteFlag) {
8585       CALL_ProgramUniform2ui(ctx->Exec, (program, location, x, y));
8586    }
8587 }
8588 
8589 static void GLAPIENTRY
save_ProgramUniform3ui(GLuint program,GLint location,GLuint x,GLuint y,GLuint z)8590 save_ProgramUniform3ui(GLuint program, GLint location,
8591                        GLuint x, GLuint y, GLuint z)
8592 {
8593    GET_CURRENT_CONTEXT(ctx);
8594    Node *n;
8595    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8596    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI, 5);
8597    if (n) {
8598       n[1].ui = program;
8599       n[2].i = location;
8600       n[3].ui = x;
8601       n[4].ui = y;
8602       n[5].ui = z;
8603    }
8604    if (ctx->ExecuteFlag) {
8605       CALL_ProgramUniform3ui(ctx->Exec, (program, location, x, y, z));
8606    }
8607 }
8608 
8609 static void GLAPIENTRY
save_ProgramUniform4ui(GLuint program,GLint location,GLuint x,GLuint y,GLuint z,GLuint w)8610 save_ProgramUniform4ui(GLuint program, GLint location,
8611                        GLuint x, GLuint y, GLuint z, GLuint w)
8612 {
8613    GET_CURRENT_CONTEXT(ctx);
8614    Node *n;
8615    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8616    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI, 6);
8617    if (n) {
8618       n[1].ui = program;
8619       n[2].i = location;
8620       n[3].ui = x;
8621       n[4].ui = y;
8622       n[5].ui = z;
8623       n[6].ui = w;
8624    }
8625    if (ctx->ExecuteFlag) {
8626       CALL_ProgramUniform4ui(ctx->Exec, (program, location, x, y, z, w));
8627    }
8628 }
8629 
8630 static void GLAPIENTRY
save_ProgramUniform1uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8631 save_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
8632                         const GLuint *v)
8633 {
8634    GET_CURRENT_CONTEXT(ctx);
8635    Node *n;
8636    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8637    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UIV, 3 + POINTER_DWORDS);
8638    if (n) {
8639       n[1].ui = program;
8640       n[2].i = location;
8641       n[3].i = count;
8642       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint)));
8643    }
8644    if (ctx->ExecuteFlag) {
8645       CALL_ProgramUniform1uiv(ctx->Exec, (program, location, count, v));
8646    }
8647 }
8648 
8649 static void GLAPIENTRY
save_ProgramUniform2uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8650 save_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
8651                         const GLuint *v)
8652 {
8653    GET_CURRENT_CONTEXT(ctx);
8654    Node *n;
8655    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8656    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UIV, 3 + POINTER_DWORDS);
8657    if (n) {
8658       n[1].ui = program;
8659       n[2].i = location;
8660       n[3].i = count;
8661       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLuint)));
8662    }
8663    if (ctx->ExecuteFlag) {
8664       CALL_ProgramUniform2uiv(ctx->Exec, (program, location, count, v));
8665    }
8666 }
8667 
8668 static void GLAPIENTRY
save_ProgramUniform3uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8669 save_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
8670                         const GLuint *v)
8671 {
8672    GET_CURRENT_CONTEXT(ctx);
8673    Node *n;
8674    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8675    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UIV, 3 + POINTER_DWORDS);
8676    if (n) {
8677       n[1].ui = program;
8678       n[2].i = location;
8679       n[3].i = count;
8680       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLuint)));
8681    }
8682    if (ctx->ExecuteFlag) {
8683       CALL_ProgramUniform3uiv(ctx->Exec, (program, location, count, v));
8684    }
8685 }
8686 
8687 static void GLAPIENTRY
save_ProgramUniform4uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8688 save_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
8689                         const GLuint *v)
8690 {
8691    GET_CURRENT_CONTEXT(ctx);
8692    Node *n;
8693    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8694    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UIV, 3 + POINTER_DWORDS);
8695    if (n) {
8696       n[1].ui = program;
8697       n[2].i = location;
8698       n[3].i = count;
8699       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLuint)));
8700    }
8701    if (ctx->ExecuteFlag) {
8702       CALL_ProgramUniform4uiv(ctx->Exec, (program, location, count, v));
8703    }
8704 }
8705 
8706 static void GLAPIENTRY
save_ProgramUniformMatrix2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8707 save_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count,
8708                              GLboolean transpose, const GLfloat *v)
8709 {
8710    GET_CURRENT_CONTEXT(ctx);
8711    Node *n;
8712    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8713    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22F,
8714                          4 + POINTER_DWORDS);
8715    if (n) {
8716       n[1].ui = program;
8717       n[2].i = location;
8718       n[3].i = count;
8719       n[4].b = transpose;
8720       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLfloat)));
8721    }
8722    if (ctx->ExecuteFlag) {
8723       CALL_ProgramUniformMatrix2fv(ctx->Exec,
8724                                    (program, location, count, transpose, v));
8725    }
8726 }
8727 
8728 static void GLAPIENTRY
save_ProgramUniformMatrix2x3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8729 save_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count,
8730                                GLboolean transpose, const GLfloat *v)
8731 {
8732    GET_CURRENT_CONTEXT(ctx);
8733    Node *n;
8734    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8735    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23F,
8736                          4 + POINTER_DWORDS);
8737    if (n) {
8738       n[1].ui = program;
8739       n[2].i = location;
8740       n[3].i = count;
8741       n[4].b = transpose;
8742       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLfloat)));
8743    }
8744    if (ctx->ExecuteFlag) {
8745       CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
8746                                      (program, location, count, transpose, v));
8747    }
8748 }
8749 
8750 static void GLAPIENTRY
save_ProgramUniformMatrix2x4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8751 save_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count,
8752                                GLboolean transpose, const GLfloat *v)
8753 {
8754    GET_CURRENT_CONTEXT(ctx);
8755    Node *n;
8756    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8757    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24F,
8758                          4 + POINTER_DWORDS);
8759    if (n) {
8760       n[1].ui = program;
8761       n[2].i = location;
8762       n[3].i = count;
8763       n[4].b = transpose;
8764       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLfloat)));
8765    }
8766    if (ctx->ExecuteFlag) {
8767       CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
8768                                      (program, location, count, transpose, v));
8769    }
8770 }
8771 
8772 static void GLAPIENTRY
save_ProgramUniformMatrix3x2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8773 save_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count,
8774                                GLboolean transpose, const GLfloat *v)
8775 {
8776    GET_CURRENT_CONTEXT(ctx);
8777    Node *n;
8778    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8779    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32F,
8780                          4 + POINTER_DWORDS);
8781    if (n) {
8782       n[1].ui = program;
8783       n[2].i = location;
8784       n[3].i = count;
8785       n[4].b = transpose;
8786       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLfloat)));
8787    }
8788    if (ctx->ExecuteFlag) {
8789       CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
8790                                      (program, location, count, transpose, v));
8791    }
8792 }
8793 
8794 static void GLAPIENTRY
save_ProgramUniformMatrix3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8795 save_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count,
8796                              GLboolean transpose, const GLfloat *v)
8797 {
8798    GET_CURRENT_CONTEXT(ctx);
8799    Node *n;
8800    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8801    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33F,
8802                          4 + POINTER_DWORDS);
8803    if (n) {
8804       n[1].ui = program;
8805       n[2].i = location;
8806       n[3].i = count;
8807       n[4].b = transpose;
8808       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLfloat)));
8809    }
8810    if (ctx->ExecuteFlag) {
8811       CALL_ProgramUniformMatrix3fv(ctx->Exec,
8812                                    (program, location, count, transpose, v));
8813    }
8814 }
8815 
8816 static void GLAPIENTRY
save_ProgramUniformMatrix3x4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8817 save_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count,
8818                                GLboolean transpose, const GLfloat *v)
8819 {
8820    GET_CURRENT_CONTEXT(ctx);
8821    Node *n;
8822    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8823    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34F,
8824                          4 + POINTER_DWORDS);
8825    if (n) {
8826       n[1].ui = program;
8827       n[2].i = location;
8828       n[3].i = count;
8829       n[4].b = transpose;
8830       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLfloat)));
8831    }
8832    if (ctx->ExecuteFlag) {
8833       CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
8834                                      (program, location, count, transpose, v));
8835    }
8836 }
8837 
8838 static void GLAPIENTRY
save_ProgramUniformMatrix4x2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8839 save_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count,
8840                                GLboolean transpose, const GLfloat *v)
8841 {
8842    GET_CURRENT_CONTEXT(ctx);
8843    Node *n;
8844    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8845    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42F,
8846                          4 + POINTER_DWORDS);
8847    if (n) {
8848       n[1].ui = program;
8849       n[2].i = location;
8850       n[3].i = count;
8851       n[4].b = transpose;
8852       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLfloat)));
8853    }
8854    if (ctx->ExecuteFlag) {
8855       CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
8856                                      (program, location, count, transpose, v));
8857    }
8858 }
8859 
8860 static void GLAPIENTRY
save_ProgramUniformMatrix4x3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8861 save_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count,
8862                                GLboolean transpose, const GLfloat *v)
8863 {
8864    GET_CURRENT_CONTEXT(ctx);
8865    Node *n;
8866    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8867    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43F,
8868                          4 + POINTER_DWORDS);
8869    if (n) {
8870       n[1].ui = program;
8871       n[2].i = location;
8872       n[3].i = count;
8873       n[4].b = transpose;
8874       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLfloat)));
8875    }
8876    if (ctx->ExecuteFlag) {
8877       CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
8878                                      (program, location, count, transpose, v));
8879    }
8880 }
8881 
8882 static void GLAPIENTRY
save_ProgramUniformMatrix4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8883 save_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count,
8884                              GLboolean transpose, const GLfloat *v)
8885 {
8886    GET_CURRENT_CONTEXT(ctx);
8887    Node *n;
8888    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8889    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44F,
8890                          4 + POINTER_DWORDS);
8891    if (n) {
8892       n[1].ui = program;
8893       n[2].i = location;
8894       n[3].i = count;
8895       n[4].b = transpose;
8896       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLfloat)));
8897    }
8898    if (ctx->ExecuteFlag) {
8899       CALL_ProgramUniformMatrix4fv(ctx->Exec,
8900                                    (program, location, count, transpose, v));
8901    }
8902 }
8903 
8904 static void GLAPIENTRY
save_ProgramUniformMatrix2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8905 save_ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count,
8906                              GLboolean transpose, const GLdouble *v)
8907 {
8908    GET_CURRENT_CONTEXT(ctx);
8909    Node *n;
8910    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8911    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22D,
8912                          4 + POINTER_DWORDS);
8913    if (n) {
8914       n[1].ui = program;
8915       n[2].i = location;
8916       n[3].i = count;
8917       n[4].b = transpose;
8918       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLdouble)));
8919    }
8920    if (ctx->ExecuteFlag) {
8921       CALL_ProgramUniformMatrix2dv(ctx->Exec,
8922                                    (program, location, count, transpose, v));
8923    }
8924 }
8925 
8926 static void GLAPIENTRY
save_ProgramUniformMatrix2x3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8927 save_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count,
8928                                GLboolean transpose, const GLdouble *v)
8929 {
8930    GET_CURRENT_CONTEXT(ctx);
8931    Node *n;
8932    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8933    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23D,
8934                          4 + POINTER_DWORDS);
8935    if (n) {
8936       n[1].ui = program;
8937       n[2].i = location;
8938       n[3].i = count;
8939       n[4].b = transpose;
8940       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLdouble)));
8941    }
8942    if (ctx->ExecuteFlag) {
8943       CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
8944                                      (program, location, count, transpose, v));
8945    }
8946 }
8947 
8948 static void GLAPIENTRY
save_ProgramUniformMatrix2x4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8949 save_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count,
8950                                GLboolean transpose, const GLdouble *v)
8951 {
8952    GET_CURRENT_CONTEXT(ctx);
8953    Node *n;
8954    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8955    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24D,
8956                          4 + POINTER_DWORDS);
8957    if (n) {
8958       n[1].ui = program;
8959       n[2].i = location;
8960       n[3].i = count;
8961       n[4].b = transpose;
8962       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLdouble)));
8963    }
8964    if (ctx->ExecuteFlag) {
8965       CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
8966                                      (program, location, count, transpose, v));
8967    }
8968 }
8969 
8970 static void GLAPIENTRY
save_ProgramUniformMatrix3x2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8971 save_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count,
8972                                GLboolean transpose, const GLdouble *v)
8973 {
8974    GET_CURRENT_CONTEXT(ctx);
8975    Node *n;
8976    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8977    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32D,
8978                          4 + POINTER_DWORDS);
8979    if (n) {
8980       n[1].ui = program;
8981       n[2].i = location;
8982       n[3].i = count;
8983       n[4].b = transpose;
8984       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLdouble)));
8985    }
8986    if (ctx->ExecuteFlag) {
8987       CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
8988                                      (program, location, count, transpose, v));
8989    }
8990 }
8991 
8992 static void GLAPIENTRY
save_ProgramUniformMatrix3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8993 save_ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count,
8994                              GLboolean transpose, const GLdouble *v)
8995 {
8996    GET_CURRENT_CONTEXT(ctx);
8997    Node *n;
8998    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8999    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33D,
9000                          4 + POINTER_DWORDS);
9001    if (n) {
9002       n[1].ui = program;
9003       n[2].i = location;
9004       n[3].i = count;
9005       n[4].b = transpose;
9006       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLdouble)));
9007    }
9008    if (ctx->ExecuteFlag) {
9009       CALL_ProgramUniformMatrix3dv(ctx->Exec,
9010                                    (program, location, count, transpose, v));
9011    }
9012 }
9013 
9014 static void GLAPIENTRY
save_ProgramUniformMatrix3x4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)9015 save_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count,
9016                                GLboolean transpose, const GLdouble *v)
9017 {
9018    GET_CURRENT_CONTEXT(ctx);
9019    Node *n;
9020    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9021    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34D,
9022                          4 + POINTER_DWORDS);
9023    if (n) {
9024       n[1].ui = program;
9025       n[2].i = location;
9026       n[3].i = count;
9027       n[4].b = transpose;
9028       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLdouble)));
9029    }
9030    if (ctx->ExecuteFlag) {
9031       CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
9032                                      (program, location, count, transpose, v));
9033    }
9034 }
9035 
9036 static void GLAPIENTRY
save_ProgramUniformMatrix4x2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)9037 save_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count,
9038                                GLboolean transpose, const GLdouble *v)
9039 {
9040    GET_CURRENT_CONTEXT(ctx);
9041    Node *n;
9042    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9043    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42D,
9044                          4 + POINTER_DWORDS);
9045    if (n) {
9046       n[1].ui = program;
9047       n[2].i = location;
9048       n[3].i = count;
9049       n[4].b = transpose;
9050       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLdouble)));
9051    }
9052    if (ctx->ExecuteFlag) {
9053       CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
9054                                      (program, location, count, transpose, v));
9055    }
9056 }
9057 
9058 static void GLAPIENTRY
save_ProgramUniformMatrix4x3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)9059 save_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
9060                                GLboolean transpose, const GLdouble *v)
9061 {
9062    GET_CURRENT_CONTEXT(ctx);
9063    Node *n;
9064    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9065    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43D,
9066                          4 + POINTER_DWORDS);
9067    if (n) {
9068       n[1].ui = program;
9069       n[2].i = location;
9070       n[3].i = count;
9071       n[4].b = transpose;
9072       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLdouble)));
9073    }
9074    if (ctx->ExecuteFlag) {
9075       CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
9076                                      (program, location, count, transpose, v));
9077    }
9078 }
9079 
9080 static void GLAPIENTRY
save_ProgramUniformMatrix4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)9081 save_ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count,
9082                              GLboolean transpose, const GLdouble *v)
9083 {
9084    GET_CURRENT_CONTEXT(ctx);
9085    Node *n;
9086    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9087    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44D,
9088                          4 + POINTER_DWORDS);
9089    if (n) {
9090       n[1].ui = program;
9091       n[2].i = location;
9092       n[3].i = count;
9093       n[4].b = transpose;
9094       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLdouble)));
9095    }
9096    if (ctx->ExecuteFlag) {
9097       CALL_ProgramUniformMatrix4dv(ctx->Exec,
9098                                    (program, location, count, transpose, v));
9099    }
9100 }
9101 
9102 static void GLAPIENTRY
save_ClipControl(GLenum origin,GLenum depth)9103 save_ClipControl(GLenum origin, GLenum depth)
9104 {
9105    GET_CURRENT_CONTEXT(ctx);
9106    Node *n;
9107    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9108    n = alloc_instruction(ctx, OPCODE_CLIP_CONTROL, 2);
9109    if (n) {
9110       n[1].e = origin;
9111       n[2].e = depth;
9112    }
9113    if (ctx->ExecuteFlag) {
9114       CALL_ClipControl(ctx->Exec, (origin, depth));
9115    }
9116 }
9117 
9118 static void GLAPIENTRY
save_ClampColorARB(GLenum target,GLenum clamp)9119 save_ClampColorARB(GLenum target, GLenum clamp)
9120 {
9121    GET_CURRENT_CONTEXT(ctx);
9122    Node *n;
9123    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9124    n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2);
9125    if (n) {
9126       n[1].e = target;
9127       n[2].e = clamp;
9128    }
9129    if (ctx->ExecuteFlag) {
9130       CALL_ClampColor(ctx->Exec, (target, clamp));
9131    }
9132 }
9133 
9134 /** GL_EXT_texture_integer */
9135 static void GLAPIENTRY
save_ClearColorIi(GLint red,GLint green,GLint blue,GLint alpha)9136 save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha)
9137 {
9138    GET_CURRENT_CONTEXT(ctx);
9139    Node *n;
9140    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9141    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4);
9142    if (n) {
9143       n[1].i = red;
9144       n[2].i = green;
9145       n[3].i = blue;
9146       n[4].i = alpha;
9147    }
9148    if (ctx->ExecuteFlag) {
9149       CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha));
9150    }
9151 }
9152 
9153 /** GL_EXT_texture_integer */
9154 static void GLAPIENTRY
save_ClearColorIui(GLuint red,GLuint green,GLuint blue,GLuint alpha)9155 save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
9156 {
9157    GET_CURRENT_CONTEXT(ctx);
9158    Node *n;
9159    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9160    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4);
9161    if (n) {
9162       n[1].ui = red;
9163       n[2].ui = green;
9164       n[3].ui = blue;
9165       n[4].ui = alpha;
9166    }
9167    if (ctx->ExecuteFlag) {
9168       CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha));
9169    }
9170 }
9171 
9172 /** GL_EXT_texture_integer */
9173 static void GLAPIENTRY
save_TexParameterIiv(GLenum target,GLenum pname,const GLint * params)9174 save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
9175 {
9176    GET_CURRENT_CONTEXT(ctx);
9177    Node *n;
9178    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9179    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6);
9180    if (n) {
9181       n[1].e = target;
9182       n[2].e = pname;
9183       n[3].i = params[0];
9184       n[4].i = params[1];
9185       n[5].i = params[2];
9186       n[6].i = params[3];
9187    }
9188    if (ctx->ExecuteFlag) {
9189       CALL_TexParameterIiv(ctx->Exec, (target, pname, params));
9190    }
9191 }
9192 
9193 /** GL_EXT_texture_integer */
9194 static void GLAPIENTRY
save_TexParameterIuiv(GLenum target,GLenum pname,const GLuint * params)9195 save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
9196 {
9197    GET_CURRENT_CONTEXT(ctx);
9198    Node *n;
9199    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9200    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6);
9201    if (n) {
9202       n[1].e = target;
9203       n[2].e = pname;
9204       n[3].ui = params[0];
9205       n[4].ui = params[1];
9206       n[5].ui = params[2];
9207       n[6].ui = params[3];
9208    }
9209    if (ctx->ExecuteFlag) {
9210       CALL_TexParameterIuiv(ctx->Exec, (target, pname, params));
9211    }
9212 }
9213 
9214 /* GL_ARB_instanced_arrays */
9215 static void GLAPIENTRY
save_VertexAttribDivisor(GLuint index,GLuint divisor)9216 save_VertexAttribDivisor(GLuint index, GLuint divisor)
9217 {
9218    GET_CURRENT_CONTEXT(ctx);
9219    Node *n;
9220    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9221    n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2);
9222    if (n) {
9223       n[1].ui = index;
9224       n[2].ui = divisor;
9225    }
9226    if (ctx->ExecuteFlag) {
9227       CALL_VertexAttribDivisor(ctx->Exec, (index, divisor));
9228    }
9229 }
9230 
9231 
9232 /* GL_NV_texture_barrier */
9233 static void GLAPIENTRY
save_TextureBarrierNV(void)9234 save_TextureBarrierNV(void)
9235 {
9236    GET_CURRENT_CONTEXT(ctx);
9237    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9238    alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0);
9239    if (ctx->ExecuteFlag) {
9240       CALL_TextureBarrierNV(ctx->Exec, ());
9241    }
9242 }
9243 
9244 
9245 /* GL_ARB_sampler_objects */
9246 static void GLAPIENTRY
save_BindSampler(GLuint unit,GLuint sampler)9247 save_BindSampler(GLuint unit, GLuint sampler)
9248 {
9249    Node *n;
9250    GET_CURRENT_CONTEXT(ctx);
9251    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9252    n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2);
9253    if (n) {
9254       n[1].ui = unit;
9255       n[2].ui = sampler;
9256    }
9257    if (ctx->ExecuteFlag) {
9258       CALL_BindSampler(ctx->Exec, (unit, sampler));
9259    }
9260 }
9261 
9262 static void GLAPIENTRY
save_SamplerParameteriv(GLuint sampler,GLenum pname,const GLint * params)9263 save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
9264 {
9265    Node *n;
9266    GET_CURRENT_CONTEXT(ctx);
9267    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9268    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6);
9269    if (n) {
9270       n[1].ui = sampler;
9271       n[2].e = pname;
9272       n[3].i = params[0];
9273       if (pname == GL_TEXTURE_BORDER_COLOR) {
9274          n[4].i = params[1];
9275          n[5].i = params[2];
9276          n[6].i = params[3];
9277       }
9278       else {
9279          n[4].i = n[5].i = n[6].i = 0;
9280       }
9281    }
9282    if (ctx->ExecuteFlag) {
9283       CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params));
9284    }
9285 }
9286 
9287 static void GLAPIENTRY
save_SamplerParameteri(GLuint sampler,GLenum pname,GLint param)9288 save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
9289 {
9290    GLint parray[4];
9291    parray[0] = param;
9292    parray[1] = parray[2] = parray[3] = 0;
9293    save_SamplerParameteriv(sampler, pname, parray);
9294 }
9295 
9296 static void GLAPIENTRY
save_SamplerParameterfv(GLuint sampler,GLenum pname,const GLfloat * params)9297 save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
9298 {
9299    Node *n;
9300    GET_CURRENT_CONTEXT(ctx);
9301    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9302    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6);
9303    if (n) {
9304       n[1].ui = sampler;
9305       n[2].e = pname;
9306       n[3].f = params[0];
9307       if (pname == GL_TEXTURE_BORDER_COLOR) {
9308          n[4].f = params[1];
9309          n[5].f = params[2];
9310          n[6].f = params[3];
9311       }
9312       else {
9313          n[4].f = n[5].f = n[6].f = 0.0F;
9314       }
9315    }
9316    if (ctx->ExecuteFlag) {
9317       CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params));
9318    }
9319 }
9320 
9321 static void GLAPIENTRY
save_SamplerParameterf(GLuint sampler,GLenum pname,GLfloat param)9322 save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
9323 {
9324    GLfloat parray[4];
9325    parray[0] = param;
9326    parray[1] = parray[2] = parray[3] = 0.0F;
9327    save_SamplerParameterfv(sampler, pname, parray);
9328 }
9329 
9330 static void GLAPIENTRY
save_SamplerParameterIiv(GLuint sampler,GLenum pname,const GLint * params)9331 save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
9332 {
9333    Node *n;
9334    GET_CURRENT_CONTEXT(ctx);
9335    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9336    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6);
9337    if (n) {
9338       n[1].ui = sampler;
9339       n[2].e = pname;
9340       n[3].i = params[0];
9341       if (pname == GL_TEXTURE_BORDER_COLOR) {
9342          n[4].i = params[1];
9343          n[5].i = params[2];
9344          n[6].i = params[3];
9345       }
9346       else {
9347          n[4].i = n[5].i = n[6].i = 0;
9348       }
9349    }
9350    if (ctx->ExecuteFlag) {
9351       CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params));
9352    }
9353 }
9354 
9355 static void GLAPIENTRY
save_SamplerParameterIuiv(GLuint sampler,GLenum pname,const GLuint * params)9356 save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
9357 {
9358    Node *n;
9359    GET_CURRENT_CONTEXT(ctx);
9360    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9361    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6);
9362    if (n) {
9363       n[1].ui = sampler;
9364       n[2].e = pname;
9365       n[3].ui = params[0];
9366       if (pname == GL_TEXTURE_BORDER_COLOR) {
9367          n[4].ui = params[1];
9368          n[5].ui = params[2];
9369          n[6].ui = params[3];
9370       }
9371       else {
9372          n[4].ui = n[5].ui = n[6].ui = 0;
9373       }
9374    }
9375    if (ctx->ExecuteFlag) {
9376       CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params));
9377    }
9378 }
9379 
9380 static void GLAPIENTRY
save_WaitSync(GLsync sync,GLbitfield flags,GLuint64 timeout)9381 save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
9382 {
9383    Node *n;
9384    GET_CURRENT_CONTEXT(ctx);
9385    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9386    n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4);
9387    if (n) {
9388       union uint64_pair p;
9389       p.uint64 = timeout;
9390       n[1].bf = flags;
9391       n[2].ui = p.uint32[0];
9392       n[3].ui = p.uint32[1];
9393       save_pointer(&n[4], sync);
9394    }
9395    if (ctx->ExecuteFlag) {
9396       CALL_WaitSync(ctx->Exec, (sync, flags, timeout));
9397    }
9398 }
9399 
9400 
9401 /** GL_NV_conditional_render */
9402 static void GLAPIENTRY
save_BeginConditionalRender(GLuint queryId,GLenum mode)9403 save_BeginConditionalRender(GLuint queryId, GLenum mode)
9404 {
9405    GET_CURRENT_CONTEXT(ctx);
9406    Node *n;
9407    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9408    n = alloc_instruction(ctx, OPCODE_BEGIN_CONDITIONAL_RENDER, 2);
9409    if (n) {
9410       n[1].i = queryId;
9411       n[2].e = mode;
9412    }
9413    if (ctx->ExecuteFlag) {
9414       CALL_BeginConditionalRender(ctx->Exec, (queryId, mode));
9415    }
9416 }
9417 
9418 static void GLAPIENTRY
save_EndConditionalRender(void)9419 save_EndConditionalRender(void)
9420 {
9421    GET_CURRENT_CONTEXT(ctx);
9422    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9423    alloc_instruction(ctx, OPCODE_END_CONDITIONAL_RENDER, 0);
9424    if (ctx->ExecuteFlag) {
9425       CALL_EndConditionalRender(ctx->Exec, ());
9426    }
9427 }
9428 
9429 static void GLAPIENTRY
save_UniformBlockBinding(GLuint prog,GLuint index,GLuint binding)9430 save_UniformBlockBinding(GLuint prog, GLuint index, GLuint binding)
9431 {
9432    GET_CURRENT_CONTEXT(ctx);
9433    Node *n;
9434    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9435    n = alloc_instruction(ctx, OPCODE_UNIFORM_BLOCK_BINDING, 3);
9436    if (n) {
9437       n[1].ui = prog;
9438       n[2].ui = index;
9439       n[3].ui = binding;
9440    }
9441    if (ctx->ExecuteFlag) {
9442       CALL_UniformBlockBinding(ctx->Exec, (prog, index, binding));
9443    }
9444 }
9445 
9446 static void GLAPIENTRY
save_UniformSubroutinesuiv(GLenum shadertype,GLsizei count,const GLuint * indices)9447 save_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
9448                            const GLuint *indices)
9449 {
9450    GET_CURRENT_CONTEXT(ctx);
9451    Node *n;
9452    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9453    n = alloc_instruction(ctx, OPCODE_UNIFORM_SUBROUTINES, 2 + POINTER_DWORDS);
9454    if (n) {
9455       GLint *indices_copy = NULL;
9456 
9457       if (count > 0)
9458          indices_copy = memdup(indices, sizeof(GLuint) * 4 * count);
9459       n[1].e = shadertype;
9460       n[2].si = count;
9461       save_pointer(&n[3], indices_copy);
9462    }
9463    if (ctx->ExecuteFlag) {
9464       CALL_UniformSubroutinesuiv(ctx->Exec, (shadertype, count, indices));
9465    }
9466 }
9467 
9468 /** GL_EXT_window_rectangles */
9469 static void GLAPIENTRY
save_WindowRectanglesEXT(GLenum mode,GLsizei count,const GLint * box)9470 save_WindowRectanglesEXT(GLenum mode, GLsizei count, const GLint *box)
9471 {
9472    GET_CURRENT_CONTEXT(ctx);
9473    Node *n;
9474    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9475    n = alloc_instruction(ctx, OPCODE_WINDOW_RECTANGLES, 2 + POINTER_DWORDS);
9476    if (n) {
9477       GLint *box_copy = NULL;
9478 
9479       if (count > 0)
9480          box_copy = memdup(box, sizeof(GLint) * 4 * count);
9481       n[1].e = mode;
9482       n[2].si = count;
9483       save_pointer(&n[3], box_copy);
9484    }
9485    if (ctx->ExecuteFlag) {
9486       CALL_WindowRectanglesEXT(ctx->Exec, (mode, count, box));
9487    }
9488 }
9489 
9490 
9491 /** GL_NV_conservative_raster */
9492 static void GLAPIENTRY
save_SubpixelPrecisionBiasNV(GLuint xbits,GLuint ybits)9493 save_SubpixelPrecisionBiasNV(GLuint xbits, GLuint ybits)
9494 {
9495    GET_CURRENT_CONTEXT(ctx);
9496    Node *n;
9497    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9498    n = alloc_instruction(ctx, OPCODE_SUBPIXEL_PRECISION_BIAS, 2);
9499    if (n) {
9500       n[1].ui = xbits;
9501       n[2].ui = ybits;
9502    }
9503    if (ctx->ExecuteFlag) {
9504       CALL_SubpixelPrecisionBiasNV(ctx->Exec, (xbits, ybits));
9505    }
9506 }
9507 
9508 /** GL_NV_conservative_raster_dilate */
9509 static void GLAPIENTRY
save_ConservativeRasterParameterfNV(GLenum pname,GLfloat param)9510 save_ConservativeRasterParameterfNV(GLenum pname, GLfloat param)
9511 {
9512    GET_CURRENT_CONTEXT(ctx);
9513    Node *n;
9514    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9515    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_F, 2);
9516    if (n) {
9517       n[1].e = pname;
9518       n[2].f = param;
9519    }
9520    if (ctx->ExecuteFlag) {
9521       CALL_ConservativeRasterParameterfNV(ctx->Exec, (pname, param));
9522    }
9523 }
9524 
9525 /** GL_NV_conservative_raster_pre_snap_triangles */
9526 static void GLAPIENTRY
save_ConservativeRasterParameteriNV(GLenum pname,GLint param)9527 save_ConservativeRasterParameteriNV(GLenum pname, GLint param)
9528 {
9529    GET_CURRENT_CONTEXT(ctx);
9530    Node *n;
9531    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9532    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_I, 2);
9533    if (n) {
9534       n[1].e = pname;
9535       n[2].i = param;
9536    }
9537    if (ctx->ExecuteFlag) {
9538       CALL_ConservativeRasterParameteriNV(ctx->Exec, (pname, param));
9539    }
9540 }
9541 
9542 /** GL_EXT_direct_state_access */
9543 
9544 static void GLAPIENTRY
save_MatrixLoadfEXT(GLenum matrixMode,const GLfloat * m)9545 save_MatrixLoadfEXT(GLenum matrixMode, const GLfloat *m)
9546 {
9547    GET_CURRENT_CONTEXT(ctx);
9548    Node *n;
9549    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9550    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD, 17);
9551    if (n) {
9552       n[1].e = matrixMode;
9553       for (unsigned i = 0; i < 16; i++) {
9554          n[2 + i].f = m[i];
9555       }
9556    }
9557    if (ctx->ExecuteFlag) {
9558       CALL_MatrixLoadfEXT(ctx->Exec, (matrixMode, m));
9559    }
9560 }
9561 
9562 static void GLAPIENTRY
save_MatrixLoaddEXT(GLenum matrixMode,const GLdouble * m)9563 save_MatrixLoaddEXT(GLenum matrixMode, const GLdouble *m)
9564 {
9565    GLfloat f[16];
9566    for (unsigned i = 0; i < 16; i++) {
9567       f[i] = (GLfloat) m[i];
9568    }
9569    save_MatrixLoadfEXT(matrixMode, f);
9570 }
9571 
9572 static void GLAPIENTRY
save_MatrixMultfEXT(GLenum matrixMode,const GLfloat * m)9573 save_MatrixMultfEXT(GLenum matrixMode, const GLfloat * m)
9574 {
9575    GET_CURRENT_CONTEXT(ctx);
9576    Node *n;
9577    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9578    n = alloc_instruction(ctx, OPCODE_MATRIX_MULT, 17);
9579    if (n) {
9580       n[1].e = matrixMode;
9581       for (unsigned i = 0; i < 16; i++) {
9582          n[2 + i].f = m[i];
9583       }
9584    }
9585    if (ctx->ExecuteFlag) {
9586       CALL_MatrixMultfEXT(ctx->Exec, (matrixMode, m));
9587    }
9588 }
9589 
9590 static void GLAPIENTRY
save_MatrixMultdEXT(GLenum matrixMode,const GLdouble * m)9591 save_MatrixMultdEXT(GLenum matrixMode, const GLdouble * m)
9592 {
9593    GLfloat f[16];
9594    for (unsigned i = 0; i < 16; i++) {
9595       f[i] = (GLfloat) m[i];
9596    }
9597    save_MatrixMultfEXT(matrixMode, f);
9598 }
9599 
9600 static void GLAPIENTRY
save_MatrixRotatefEXT(GLenum matrixMode,GLfloat angle,GLfloat x,GLfloat y,GLfloat z)9601 save_MatrixRotatefEXT(GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
9602 {
9603    GET_CURRENT_CONTEXT(ctx);
9604    Node *n;
9605    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9606    n = alloc_instruction(ctx, OPCODE_MATRIX_ROTATE, 5);
9607    if (n) {
9608       n[1].e = matrixMode;
9609       n[2].f = angle;
9610       n[3].f = x;
9611       n[4].f = y;
9612       n[5].f = z;
9613    }
9614    if (ctx->ExecuteFlag) {
9615       CALL_MatrixRotatefEXT(ctx->Exec, (matrixMode, angle, x, y, z));
9616    }
9617 }
9618 
9619 static void GLAPIENTRY
save_MatrixRotatedEXT(GLenum matrixMode,GLdouble angle,GLdouble x,GLdouble y,GLdouble z)9620 save_MatrixRotatedEXT(GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
9621 {
9622    save_MatrixRotatefEXT(matrixMode, (GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9623 }
9624 
9625 static void GLAPIENTRY
save_MatrixScalefEXT(GLenum matrixMode,GLfloat x,GLfloat y,GLfloat z)9626 save_MatrixScalefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9627 {
9628    GET_CURRENT_CONTEXT(ctx);
9629    Node *n;
9630    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9631    n = alloc_instruction(ctx, OPCODE_MATRIX_SCALE, 4);
9632    if (n) {
9633       n[1].e = matrixMode;
9634       n[2].f = x;
9635       n[3].f = y;
9636       n[4].f = z;
9637    }
9638    if (ctx->ExecuteFlag) {
9639       CALL_MatrixScalefEXT(ctx->Exec, (matrixMode, x, y, z));
9640    }
9641 }
9642 
9643 static void GLAPIENTRY
save_MatrixScaledEXT(GLenum matrixMode,GLdouble x,GLdouble y,GLdouble z)9644 save_MatrixScaledEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9645 {
9646    save_MatrixScalefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9647 }
9648 
9649 static void GLAPIENTRY
save_MatrixTranslatefEXT(GLenum matrixMode,GLfloat x,GLfloat y,GLfloat z)9650 save_MatrixTranslatefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9651 {
9652    GET_CURRENT_CONTEXT(ctx);
9653    Node *n;
9654    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9655    n = alloc_instruction(ctx, OPCODE_MATRIX_TRANSLATE, 4);
9656    if (n) {
9657       n[1].e = matrixMode;
9658       n[2].f = x;
9659       n[3].f = y;
9660       n[4].f = z;
9661    }
9662    if (ctx->ExecuteFlag) {
9663       CALL_MatrixTranslatefEXT(ctx->Exec, (matrixMode, x, y, z));
9664    }
9665 }
9666 
9667 static void GLAPIENTRY
save_MatrixTranslatedEXT(GLenum matrixMode,GLdouble x,GLdouble y,GLdouble z)9668 save_MatrixTranslatedEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9669 {
9670    save_MatrixTranslatefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9671 }
9672 
9673 static void GLAPIENTRY
save_MatrixLoadIdentityEXT(GLenum matrixMode)9674 save_MatrixLoadIdentityEXT(GLenum matrixMode)
9675 {
9676    GET_CURRENT_CONTEXT(ctx);
9677    Node *n;
9678    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9679    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD_IDENTITY, 1);
9680    if (n) {
9681       n[1].e = matrixMode;
9682    }
9683    if (ctx->ExecuteFlag) {
9684       CALL_MatrixLoadIdentityEXT(ctx->Exec, (matrixMode));
9685    }
9686 }
9687 
9688 static void GLAPIENTRY
save_MatrixOrthoEXT(GLenum matrixMode,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)9689 save_MatrixOrthoEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9690                     GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9691 {
9692    GET_CURRENT_CONTEXT(ctx);
9693    Node *n;
9694    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9695    n = alloc_instruction(ctx, OPCODE_MATRIX_ORTHO, 7);
9696    if (n) {
9697       n[1].e = matrixMode;
9698       n[2].f = (GLfloat) left;
9699       n[3].f = (GLfloat) right;
9700       n[4].f = (GLfloat) bottom;
9701       n[5].f = (GLfloat) top;
9702       n[6].f = (GLfloat) nearval;
9703       n[7].f = (GLfloat) farval;
9704    }
9705    if (ctx->ExecuteFlag) {
9706       CALL_MatrixOrthoEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9707    }
9708 }
9709 
9710 
9711 static void GLAPIENTRY
save_MatrixFrustumEXT(GLenum matrixMode,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)9712 save_MatrixFrustumEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9713                       GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9714 {
9715    GET_CURRENT_CONTEXT(ctx);
9716    Node *n;
9717    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9718    n = alloc_instruction(ctx, OPCODE_MATRIX_FRUSTUM, 7);
9719    if (n) {
9720       n[1].e = matrixMode;
9721       n[2].f = (GLfloat) left;
9722       n[3].f = (GLfloat) right;
9723       n[4].f = (GLfloat) bottom;
9724       n[5].f = (GLfloat) top;
9725       n[6].f = (GLfloat) nearval;
9726       n[7].f = (GLfloat) farval;
9727    }
9728    if (ctx->ExecuteFlag) {
9729       CALL_MatrixFrustumEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9730    }
9731 }
9732 
9733 static void GLAPIENTRY
save_MatrixPushEXT(GLenum matrixMode)9734 save_MatrixPushEXT(GLenum matrixMode)
9735 {
9736    GET_CURRENT_CONTEXT(ctx);
9737    Node* n;
9738    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9739    n = alloc_instruction(ctx, OPCODE_MATRIX_PUSH, 1);
9740    if (n) {
9741       n[1].e = matrixMode;
9742    }
9743    if (ctx->ExecuteFlag) {
9744       CALL_MatrixPushEXT(ctx->Exec, (matrixMode));
9745    }
9746 }
9747 
9748 static void GLAPIENTRY
save_MatrixPopEXT(GLenum matrixMode)9749 save_MatrixPopEXT(GLenum matrixMode)
9750 {
9751    GET_CURRENT_CONTEXT(ctx);
9752    Node* n;
9753    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9754    n = alloc_instruction(ctx, OPCODE_MATRIX_POP, 1);
9755    if (n) {
9756       n[1].e = matrixMode;
9757    }
9758    if (ctx->ExecuteFlag) {
9759       CALL_MatrixPopEXT(ctx->Exec, (matrixMode));
9760    }
9761 }
9762 
9763 static void GLAPIENTRY
save_MatrixLoadTransposefEXT(GLenum matrixMode,const GLfloat m[16])9764 save_MatrixLoadTransposefEXT(GLenum matrixMode, const GLfloat m[16])
9765 {
9766    GLfloat tm[16];
9767    _math_transposef(tm, m);
9768    save_MatrixLoadfEXT(matrixMode, tm);
9769 }
9770 
9771 static void GLAPIENTRY
save_MatrixLoadTransposedEXT(GLenum matrixMode,const GLdouble m[16])9772 save_MatrixLoadTransposedEXT(GLenum matrixMode, const GLdouble m[16])
9773 {
9774    GLfloat tm[16];
9775    _math_transposefd(tm, m);
9776    save_MatrixLoadfEXT(matrixMode, tm);
9777 }
9778 
9779 static void GLAPIENTRY
save_MatrixMultTransposefEXT(GLenum matrixMode,const GLfloat m[16])9780 save_MatrixMultTransposefEXT(GLenum matrixMode, const GLfloat m[16])
9781 {
9782    GLfloat tm[16];
9783    _math_transposef(tm, m);
9784    save_MatrixMultfEXT(matrixMode, tm);
9785 }
9786 
9787 static void GLAPIENTRY
save_MatrixMultTransposedEXT(GLenum matrixMode,const GLdouble m[16])9788 save_MatrixMultTransposedEXT(GLenum matrixMode, const GLdouble m[16])
9789 {
9790    GLfloat tm[16];
9791    _math_transposefd(tm, m);
9792    save_MatrixMultfEXT(matrixMode, tm);
9793 }
9794 
9795 static void GLAPIENTRY
save_TextureParameterfvEXT(GLuint texture,GLenum target,GLenum pname,const GLfloat * params)9796 save_TextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname,
9797                            const GLfloat *params)
9798 {
9799    GET_CURRENT_CONTEXT(ctx);
9800    Node *n;
9801    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9802    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_F, 7);
9803    if (n) {
9804       n[1].ui = texture;
9805       n[2].e = target;
9806       n[3].e = pname;
9807       n[4].f = params[0];
9808       n[5].f = params[1];
9809       n[6].f = params[2];
9810       n[7].f = params[3];
9811    }
9812    if (ctx->ExecuteFlag) {
9813       CALL_TextureParameterfvEXT(ctx->Exec, (texture, target, pname, params));
9814    }
9815 }
9816 
9817 
9818 static void GLAPIENTRY
save_TextureParameterfEXT(GLuint texture,GLenum target,GLenum pname,GLfloat param)9819 save_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
9820 {
9821    GLfloat parray[4];
9822    parray[0] = param;
9823    parray[1] = parray[2] = parray[3] = 0.0F;
9824    save_TextureParameterfvEXT(texture, target, pname, parray);
9825 }
9826 
9827 static void GLAPIENTRY
save_TextureParameterivEXT(GLuint texture,GLenum target,GLenum pname,const GLint * params)9828 save_TextureParameterivEXT(GLuint texture, GLenum target, GLenum pname, const GLint *params)
9829 {
9830    GET_CURRENT_CONTEXT(ctx);
9831    Node *n;
9832    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9833    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_I, 7);
9834    if (n) {
9835       n[1].ui = texture;
9836       n[2].e = target;
9837       n[3].e = pname;
9838       n[4].i = params[0];
9839       n[5].i = params[1];
9840       n[6].i = params[2];
9841       n[7].i = params[3];
9842    }
9843    if (ctx->ExecuteFlag) {
9844       CALL_TextureParameterivEXT(ctx->Exec, (texture, target, pname, params));
9845    }
9846 }
9847 
9848 static void GLAPIENTRY
save_TextureParameteriEXT(GLuint texture,GLenum target,GLenum pname,GLint param)9849 save_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
9850 {
9851    GLint fparam[4];
9852    fparam[0] = param;
9853    fparam[1] = fparam[2] = fparam[3] = 0;
9854    save_TextureParameterivEXT(texture, target, pname, fparam);
9855 }
9856 
9857 static void GLAPIENTRY
save_TextureParameterIivEXT(GLuint texture,GLenum target,GLenum pname,const GLint * params)9858 save_TextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, const GLint* params)
9859 {
9860    GET_CURRENT_CONTEXT(ctx);
9861    Node *n;
9862    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9863    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_II, 7);
9864    if (n) {
9865       n[1].ui = texture;
9866       n[2].e = target;
9867       n[3].e = pname;
9868       n[4].i = params[0];
9869       n[5].i = params[1];
9870       n[6].i = params[2];
9871       n[7].i = params[3];
9872    }
9873    if (ctx->ExecuteFlag) {
9874       CALL_TextureParameterIivEXT(ctx->Exec, (texture, target, pname, params));
9875    }
9876 }
9877 
9878 static void GLAPIENTRY
save_TextureParameterIuivEXT(GLuint texture,GLenum target,GLenum pname,const GLuint * params)9879 save_TextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname, const GLuint* params)
9880 {
9881    GET_CURRENT_CONTEXT(ctx);
9882    Node *n;
9883    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9884    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_IUI, 7);
9885    if (n) {
9886       n[1].ui = texture;
9887       n[2].e = target;
9888       n[3].e = pname;
9889       n[4].ui = params[0];
9890       n[5].ui = params[1];
9891       n[6].ui = params[2];
9892       n[7].ui = params[3];
9893    }
9894    if (ctx->ExecuteFlag) {
9895       CALL_TextureParameterIuivEXT(ctx->Exec, (texture, target, pname, params));
9896    }
9897 }
9898 
9899 
9900 static void GLAPIENTRY
save_TextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)9901 save_TextureImage1DEXT(GLuint texture, GLenum target,
9902                        GLint level, GLint components,
9903                        GLsizei width, GLint border,
9904                        GLenum format, GLenum type, const GLvoid * pixels)
9905 {
9906    GET_CURRENT_CONTEXT(ctx);
9907    if (target == GL_PROXY_TEXTURE_1D) {
9908       /* don't compile, execute immediately */
9909       CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9910                                          border, format, type, pixels));
9911    }
9912    else {
9913       Node *n;
9914       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9915       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE1D, 8 + POINTER_DWORDS);
9916       if (n) {
9917          n[1].ui = texture;
9918          n[2].e = target;
9919          n[3].i = level;
9920          n[4].i = components;
9921          n[5].i = (GLint) width;
9922          n[6].i = border;
9923          n[7].e = format;
9924          n[8].e = type;
9925          save_pointer(&n[9],
9926                       unpack_image(ctx, 1, width, 1, 1, format, type,
9927                                    pixels, &ctx->Unpack));
9928       }
9929       if (ctx->ExecuteFlag) {
9930          CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9931                                             border, format, type, pixels));
9932       }
9933    }
9934 }
9935 
9936 
9937 static void GLAPIENTRY
save_TextureImage2DEXT(GLuint texture,GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)9938 save_TextureImage2DEXT(GLuint texture, GLenum target,
9939                        GLint level, GLint components,
9940                        GLsizei width, GLsizei height, GLint border,
9941                        GLenum format, GLenum type, const GLvoid * pixels)
9942 {
9943    GET_CURRENT_CONTEXT(ctx);
9944    if (target == GL_PROXY_TEXTURE_2D) {
9945       /* don't compile, execute immediately */
9946       CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9947                                          height, border, format, type, pixels));
9948    }
9949    else {
9950       Node *n;
9951       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9952       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE2D, 9 + POINTER_DWORDS);
9953       if (n) {
9954          n[1].ui = texture;
9955          n[2].e = target;
9956          n[3].i = level;
9957          n[4].i = components;
9958          n[5].i = (GLint) width;
9959          n[6].i = (GLint) height;
9960          n[7].i = border;
9961          n[8].e = format;
9962          n[9].e = type;
9963          save_pointer(&n[10],
9964                       unpack_image(ctx, 2, width, height, 1, format, type,
9965                                    pixels, &ctx->Unpack));
9966       }
9967       if (ctx->ExecuteFlag) {
9968          CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9969                                             height, border, format, type, pixels));
9970       }
9971    }
9972 }
9973 
9974 
9975 static void GLAPIENTRY
save_TextureImage3DEXT(GLuint texture,GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * pixels)9976 save_TextureImage3DEXT(GLuint texture, GLenum target,
9977                        GLint level, GLint internalFormat,
9978                        GLsizei width, GLsizei height, GLsizei depth,
9979                        GLint border,
9980                        GLenum format, GLenum type, const GLvoid * pixels)
9981 {
9982    GET_CURRENT_CONTEXT(ctx);
9983    if (target == GL_PROXY_TEXTURE_3D) {
9984       /* don't compile, execute immediately */
9985       CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat, width,
9986                                          height, depth, border, format, type,
9987                                          pixels));
9988    }
9989    else {
9990       Node *n;
9991       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9992       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE3D, 10 + POINTER_DWORDS);
9993       if (n) {
9994          n[1].ui = texture;
9995          n[2].e = target;
9996          n[3].i = level;
9997          n[4].i = (GLint) internalFormat;
9998          n[5].i = (GLint) width;
9999          n[6].i = (GLint) height;
10000          n[7].i = (GLint) depth;
10001          n[8].i = border;
10002          n[9].e = format;
10003          n[10].e = type;
10004          save_pointer(&n[11],
10005                       unpack_image(ctx, 3, width, height, depth, format, type,
10006                                    pixels, &ctx->Unpack));
10007       }
10008       if (ctx->ExecuteFlag) {
10009          CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat,
10010                                             width, height, depth, border, format,
10011                                             type, pixels));
10012       }
10013    }
10014 }
10015 
10016 
10017 static void GLAPIENTRY
save_TextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)10018 save_TextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10019                    GLsizei width, GLenum format, GLenum type,
10020                    const GLvoid * pixels)
10021 {
10022    GET_CURRENT_CONTEXT(ctx);
10023    Node *n;
10024 
10025    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10026 
10027    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE1D, 7 + POINTER_DWORDS);
10028    if (n) {
10029       n[1].ui = texture;
10030       n[2].e = target;
10031       n[3].i = level;
10032       n[4].i = xoffset;
10033       n[5].i = (GLint) width;
10034       n[6].e = format;
10035       n[7].e = type;
10036       save_pointer(&n[8],
10037                    unpack_image(ctx, 1, width, 1, 1, format, type,
10038                                 pixels, &ctx->Unpack));
10039    }
10040    if (ctx->ExecuteFlag) {
10041       CALL_TextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset, width,
10042                                             format, type, pixels));
10043    }
10044 }
10045 
10046 
10047 static void GLAPIENTRY
save_TextureSubImage2DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)10048 save_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
10049                           GLint xoffset, GLint yoffset,
10050                           GLsizei width, GLsizei height,
10051                           GLenum format, GLenum type, const GLvoid * pixels)
10052 {
10053    GET_CURRENT_CONTEXT(ctx);
10054    Node *n;
10055 
10056    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10057 
10058    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE2D, 9 + POINTER_DWORDS);
10059    if (n) {
10060       n[1].ui = texture;
10061       n[2].e = target;
10062       n[3].i = level;
10063       n[4].i = xoffset;
10064       n[5].i = yoffset;
10065       n[6].i = (GLint) width;
10066       n[7].i = (GLint) height;
10067       n[8].e = format;
10068       n[9].e = type;
10069       save_pointer(&n[10],
10070                    unpack_image(ctx, 2, width, height, 1, format, type,
10071                                 pixels, &ctx->Unpack));
10072    }
10073    if (ctx->ExecuteFlag) {
10074       CALL_TextureSubImage2DEXT(ctx->Exec, (texture, target, level, xoffset, yoffset,
10075                                             width, height, format, type, pixels));
10076    }
10077 }
10078 
10079 
10080 static void GLAPIENTRY
save_TextureSubImage3DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * pixels)10081 save_TextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
10082                           GLint xoffset, GLint yoffset, GLint zoffset,
10083                           GLsizei width, GLsizei height, GLsizei depth,
10084                           GLenum format, GLenum type, const GLvoid * pixels)
10085 {
10086    GET_CURRENT_CONTEXT(ctx);
10087    Node *n;
10088 
10089    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10090 
10091    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE3D, 11 + POINTER_DWORDS);
10092    if (n) {
10093       n[1].ui = texture;
10094       n[2].e = target;
10095       n[3].i = level;
10096       n[4].i = xoffset;
10097       n[5].i = yoffset;
10098       n[6].i = zoffset;
10099       n[7].i = (GLint) width;
10100       n[8].i = (GLint) height;
10101       n[9].i = (GLint) depth;
10102       n[10].e = format;
10103       n[11].e = type;
10104       save_pointer(&n[12],
10105                    unpack_image(ctx, 3, width, height, depth, format, type,
10106                                 pixels, &ctx->Unpack));
10107    }
10108    if (ctx->ExecuteFlag) {
10109       CALL_TextureSubImage3DEXT(ctx->Exec, (texture, target, level,
10110                                             xoffset, yoffset, zoffset,
10111                                             width, height, depth, format, type,
10112                                             pixels));
10113    }
10114 }
10115 
10116 static void GLAPIENTRY
save_CopyTextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)10117 save_CopyTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
10118                            GLenum internalformat, GLint x, GLint y,
10119                            GLsizei width, GLint border)
10120 {
10121    GET_CURRENT_CONTEXT(ctx);
10122    Node *n;
10123    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10124    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE1D, 8);
10125    if (n) {
10126       n[1].ui = texture;
10127       n[2].e = target;
10128       n[3].i = level;
10129       n[4].e = internalformat;
10130       n[5].i = x;
10131       n[6].i = y;
10132       n[7].i = width;
10133       n[8].i = border;
10134    }
10135    if (ctx->ExecuteFlag) {
10136       CALL_CopyTextureImage1DEXT(ctx->Exec, (texture, target, level,
10137                                              internalformat, x, y,
10138                                              width, border));
10139    }
10140 }
10141 
10142 static void GLAPIENTRY
save_CopyTextureImage2DEXT(GLuint texture,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)10143 save_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
10144                            GLenum internalformat,
10145                            GLint x, GLint y, GLsizei width,
10146                            GLsizei height, GLint border)
10147 {
10148    GET_CURRENT_CONTEXT(ctx);
10149    Node *n;
10150    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10151    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE2D, 9);
10152    if (n) {
10153       n[1].ui = texture;
10154       n[2].e = target;
10155       n[3].i = level;
10156       n[4].e = internalformat;
10157       n[5].i = x;
10158       n[6].i = y;
10159       n[7].i = width;
10160       n[8].i = height;
10161       n[9].i = border;
10162    }
10163    if (ctx->ExecuteFlag) {
10164       CALL_CopyTextureImage2DEXT(ctx->Exec, (texture, target, level,
10165                                              internalformat, x, y,
10166                                              width, height, border));
10167    }
10168 }
10169 
10170 static void GLAPIENTRY
save_CopyTextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)10171 save_CopyTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level,
10172                               GLint xoffset, GLint x, GLint y, GLsizei width)
10173 {
10174    GET_CURRENT_CONTEXT(ctx);
10175    Node *n;
10176    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10177    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE1D, 7);
10178    if (n) {
10179       n[1].ui = texture;
10180       n[2].e = target;
10181       n[3].i = level;
10182       n[4].i = xoffset;
10183       n[5].i = x;
10184       n[6].i = y;
10185       n[7].i = width;
10186    }
10187    if (ctx->ExecuteFlag) {
10188       CALL_CopyTextureSubImage1DEXT(ctx->Exec,
10189                              (texture, target, level, xoffset, x, y, width));
10190    }
10191 }
10192 
10193 static void GLAPIENTRY
save_CopyTextureSubImage2DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)10194 save_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
10195                               GLint xoffset, GLint yoffset,
10196                               GLint x, GLint y, GLsizei width, GLint height)
10197 {
10198    GET_CURRENT_CONTEXT(ctx);
10199    Node *n;
10200    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10201    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE2D, 9);
10202    if (n) {
10203       n[1].ui = texture;
10204       n[2].e = target;
10205       n[3].i = level;
10206       n[4].i = xoffset;
10207       n[5].i = yoffset;
10208       n[6].i = x;
10209       n[7].i = y;
10210       n[8].i = width;
10211       n[9].i = height;
10212    }
10213    if (ctx->ExecuteFlag) {
10214       CALL_CopyTextureSubImage2DEXT(ctx->Exec, (texture, target, level,
10215                                                 xoffset, yoffset,
10216                                                 x, y, width, height));
10217    }
10218 }
10219 
10220 
10221 static void GLAPIENTRY
save_CopyTextureSubImage3DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLint height)10222 save_CopyTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
10223                               GLint xoffset, GLint yoffset, GLint zoffset,
10224                               GLint x, GLint y, GLsizei width, GLint height)
10225 {
10226    GET_CURRENT_CONTEXT(ctx);
10227    Node *n;
10228    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10229    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE3D, 10);
10230    if (n) {
10231       n[1].ui = texture;
10232       n[2].e = target;
10233       n[3].i = level;
10234       n[4].i = xoffset;
10235       n[5].i = yoffset;
10236       n[6].i = zoffset;
10237       n[7].i = x;
10238       n[8].i = y;
10239       n[9].i = width;
10240       n[10].i = height;
10241    }
10242    if (ctx->ExecuteFlag) {
10243       CALL_CopyTextureSubImage3DEXT(ctx->Exec, (texture, target, level,
10244                                                 xoffset, yoffset, zoffset,
10245                                                 x, y, width, height));
10246    }
10247 }
10248 
10249 
10250 static void GLAPIENTRY
save_BindMultiTextureEXT(GLenum texunit,GLenum target,GLuint texture)10251 save_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture)
10252 {
10253    GET_CURRENT_CONTEXT(ctx);
10254    Node *n;
10255    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10256    n = alloc_instruction(ctx, OPCODE_BIND_MULTITEXTURE, 3);
10257    if (n) {
10258       n[1].e = texunit;
10259       n[2].e = target;
10260       n[3].ui = texture;
10261    }
10262    if (ctx->ExecuteFlag) {
10263       CALL_BindMultiTextureEXT(ctx->Exec, (texunit, target, texture));
10264    }
10265 }
10266 
10267 
10268 static void GLAPIENTRY
save_MultiTexParameterfvEXT(GLenum texunit,GLenum target,GLenum pname,const GLfloat * params)10269 save_MultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname,
10270                            const GLfloat *params)
10271 {
10272    GET_CURRENT_CONTEXT(ctx);
10273    Node *n;
10274    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10275    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_F, 7);
10276    if (n) {
10277       n[1].e = texunit;
10278       n[2].e = target;
10279       n[3].e = pname;
10280       n[4].f = params[0];
10281       n[5].f = params[1];
10282       n[6].f = params[2];
10283       n[7].f = params[3];
10284    }
10285    if (ctx->ExecuteFlag) {
10286       CALL_MultiTexParameterfvEXT(ctx->Exec, (texunit, target, pname, params));
10287    }
10288 }
10289 
10290 
10291 static void GLAPIENTRY
save_MultiTexParameterfEXT(GLenum texunit,GLenum target,GLenum pname,GLfloat param)10292 save_MultiTexParameterfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
10293 {
10294    GLfloat parray[4];
10295    parray[0] = param;
10296    parray[1] = parray[2] = parray[3] = 0.0F;
10297    save_MultiTexParameterfvEXT(texunit, target, pname, parray);
10298 }
10299 
10300 static void GLAPIENTRY
save_MultiTexParameterivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * params)10301 save_MultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
10302 {
10303    GET_CURRENT_CONTEXT(ctx);
10304    Node *n;
10305    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10306    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_I, 7);
10307    if (n) {
10308       n[1].e = texunit;
10309       n[2].e = target;
10310       n[3].e = pname;
10311       n[4].i = params[0];
10312       n[5].i = params[1];
10313       n[6].i = params[2];
10314       n[7].i = params[3];
10315    }
10316    if (ctx->ExecuteFlag) {
10317       CALL_MultiTexParameterivEXT(ctx->Exec, (texunit, target, pname, params));
10318    }
10319 }
10320 
10321 static void GLAPIENTRY
save_MultiTexParameterIivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * params)10322 save_MultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
10323 {
10324    GET_CURRENT_CONTEXT(ctx);
10325    Node *n;
10326    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10327    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_II, 7);
10328    if (n) {
10329       n[1].e = texunit;
10330       n[2].e = target;
10331       n[3].e = pname;
10332       n[4].i = params[0];
10333       n[5].i = params[1];
10334       n[6].i = params[2];
10335       n[7].i = params[3];
10336    }
10337    if (ctx->ExecuteFlag) {
10338       CALL_MultiTexParameterIivEXT(ctx->Exec, (texunit, target, pname, params));
10339    }
10340 }
10341 
10342 static void GLAPIENTRY
save_MultiTexParameterIuivEXT(GLenum texunit,GLenum target,GLenum pname,const GLuint * params)10343 save_MultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname, const GLuint *params)
10344 {
10345    GET_CURRENT_CONTEXT(ctx);
10346    Node *n;
10347    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10348    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_IUI, 7);
10349    if (n) {
10350       n[1].e = texunit;
10351       n[2].e = target;
10352       n[3].e = pname;
10353       n[4].ui = params[0];
10354       n[5].ui = params[1];
10355       n[6].ui = params[2];
10356       n[7].ui = params[3];
10357    }
10358    if (ctx->ExecuteFlag) {
10359       CALL_MultiTexParameterIuivEXT(ctx->Exec, (texunit, target, pname, params));
10360    }
10361 }
10362 
10363 static void GLAPIENTRY
save_MultiTexParameteriEXT(GLenum texunit,GLenum target,GLenum pname,GLint param)10364 save_MultiTexParameteriEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
10365 {
10366    GLint fparam[4];
10367    fparam[0] = param;
10368    fparam[1] = fparam[2] = fparam[3] = 0;
10369    save_MultiTexParameterivEXT(texunit, target, pname, fparam);
10370 }
10371 
10372 
10373 static void GLAPIENTRY
save_MultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)10374 save_MultiTexImage1DEXT(GLenum texunit, GLenum target,
10375                         GLint level, GLint components,
10376                         GLsizei width, GLint border,
10377                         GLenum format, GLenum type, const GLvoid * pixels)
10378 {
10379    GET_CURRENT_CONTEXT(ctx);
10380    if (target == GL_PROXY_TEXTURE_1D) {
10381       /* don't compile, execute immediately */
10382       CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
10383                                          border, format, type, pixels));
10384    }
10385    else {
10386       Node *n;
10387       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10388       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE1D, 8 + POINTER_DWORDS);
10389       if (n) {
10390          n[1].e = texunit;
10391          n[2].e = target;
10392          n[3].i = level;
10393          n[4].i = components;
10394          n[5].i = (GLint) width;
10395          n[6].i = border;
10396          n[7].e = format;
10397          n[8].e = type;
10398          save_pointer(&n[9],
10399                       unpack_image(ctx, 1, width, 1, 1, format, type,
10400                                    pixels, &ctx->Unpack));
10401       }
10402       if (ctx->ExecuteFlag) {
10403          CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
10404                                             border, format, type, pixels));
10405       }
10406    }
10407 }
10408 
10409 
10410 static void GLAPIENTRY
save_MultiTexImage2DEXT(GLenum texunit,GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)10411 save_MultiTexImage2DEXT(GLenum texunit, GLenum target,
10412                        GLint level, GLint components,
10413                        GLsizei width, GLsizei height, GLint border,
10414                        GLenum format, GLenum type, const GLvoid * pixels)
10415 {
10416    GET_CURRENT_CONTEXT(ctx);
10417    if (target == GL_PROXY_TEXTURE_2D) {
10418       /* don't compile, execute immediately */
10419       CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
10420                                          height, border, format, type, pixels));
10421    }
10422    else {
10423       Node *n;
10424       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10425       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE2D, 9 + POINTER_DWORDS);
10426       if (n) {
10427          n[1].e = texunit;
10428          n[2].e = target;
10429          n[3].i = level;
10430          n[4].i = components;
10431          n[5].i = (GLint) width;
10432          n[6].i = (GLint) height;
10433          n[7].i = border;
10434          n[8].e = format;
10435          n[9].e = type;
10436          save_pointer(&n[10],
10437                       unpack_image(ctx, 2, width, height, 1, format, type,
10438                                    pixels, &ctx->Unpack));
10439       }
10440       if (ctx->ExecuteFlag) {
10441          CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
10442                                             height, border, format, type, pixels));
10443       }
10444    }
10445 }
10446 
10447 
10448 static void GLAPIENTRY
save_MultiTexImage3DEXT(GLenum texunit,GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * pixels)10449 save_MultiTexImage3DEXT(GLenum texunit, GLenum target,
10450                        GLint level, GLint internalFormat,
10451                        GLsizei width, GLsizei height, GLsizei depth,
10452                        GLint border,
10453                        GLenum format, GLenum type, const GLvoid * pixels)
10454 {
10455    GET_CURRENT_CONTEXT(ctx);
10456    if (target == GL_PROXY_TEXTURE_3D) {
10457       /* don't compile, execute immediately */
10458       CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat, width,
10459                                          height, depth, border, format, type,
10460                                          pixels));
10461    }
10462    else {
10463       Node *n;
10464       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10465       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE3D, 10 + POINTER_DWORDS);
10466       if (n) {
10467          n[1].e = texunit;
10468          n[2].e = target;
10469          n[3].i = level;
10470          n[4].i = (GLint) internalFormat;
10471          n[5].i = (GLint) width;
10472          n[6].i = (GLint) height;
10473          n[7].i = (GLint) depth;
10474          n[8].i = border;
10475          n[9].e = format;
10476          n[10].e = type;
10477          save_pointer(&n[11],
10478                       unpack_image(ctx, 3, width, height, depth, format, type,
10479                                    pixels, &ctx->Unpack));
10480       }
10481       if (ctx->ExecuteFlag) {
10482          CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat,
10483                                             width, height, depth, border, format,
10484                                             type, pixels));
10485       }
10486    }
10487 }
10488 
10489 
10490 static void GLAPIENTRY
save_MultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)10491 save_MultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10492                    GLsizei width, GLenum format, GLenum type,
10493                    const GLvoid * pixels)
10494 {
10495    GET_CURRENT_CONTEXT(ctx);
10496    Node *n;
10497 
10498    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10499 
10500    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE1D, 7 + POINTER_DWORDS);
10501    if (n) {
10502       n[1].e = texunit;
10503       n[2].e = target;
10504       n[3].i = level;
10505       n[4].i = xoffset;
10506       n[5].i = (GLint) width;
10507       n[6].e = format;
10508       n[7].e = type;
10509       save_pointer(&n[8],
10510                    unpack_image(ctx, 1, width, 1, 1, format, type,
10511                                 pixels, &ctx->Unpack));
10512    }
10513    if (ctx->ExecuteFlag) {
10514       CALL_MultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset, width,
10515                                             format, type, pixels));
10516    }
10517 }
10518 
10519 
10520 static void GLAPIENTRY
save_MultiTexSubImage2DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)10521 save_MultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
10522                           GLint xoffset, GLint yoffset,
10523                           GLsizei width, GLsizei height,
10524                           GLenum format, GLenum type, const GLvoid * pixels)
10525 {
10526    GET_CURRENT_CONTEXT(ctx);
10527    Node *n;
10528 
10529    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10530 
10531    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE2D, 9 + POINTER_DWORDS);
10532    if (n) {
10533       n[1].e = texunit;
10534       n[2].e = target;
10535       n[3].i = level;
10536       n[4].i = xoffset;
10537       n[5].i = yoffset;
10538       n[6].i = (GLint) width;
10539       n[7].i = (GLint) height;
10540       n[8].e = format;
10541       n[9].e = type;
10542       save_pointer(&n[10],
10543                    unpack_image(ctx, 2, width, height, 1, format, type,
10544                                 pixels, &ctx->Unpack));
10545    }
10546    if (ctx->ExecuteFlag) {
10547       CALL_MultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level, xoffset, yoffset,
10548                                             width, height, format, type, pixels));
10549    }
10550 }
10551 
10552 
10553 static void GLAPIENTRY
save_MultiTexSubImage3DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * pixels)10554 save_MultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
10555                           GLint xoffset, GLint yoffset, GLint zoffset,
10556                           GLsizei width, GLsizei height, GLsizei depth,
10557                           GLenum format, GLenum type, const GLvoid * pixels)
10558 {
10559    GET_CURRENT_CONTEXT(ctx);
10560    Node *n;
10561 
10562    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10563 
10564    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE3D, 11 + POINTER_DWORDS);
10565    if (n) {
10566       n[1].e = texunit;
10567       n[2].e = target;
10568       n[3].i = level;
10569       n[4].i = xoffset;
10570       n[5].i = yoffset;
10571       n[6].i = zoffset;
10572       n[7].i = (GLint) width;
10573       n[8].i = (GLint) height;
10574       n[9].i = (GLint) depth;
10575       n[10].e = format;
10576       n[11].e = type;
10577       save_pointer(&n[12],
10578                    unpack_image(ctx, 3, width, height, depth, format, type,
10579                                 pixels, &ctx->Unpack));
10580    }
10581    if (ctx->ExecuteFlag) {
10582       CALL_MultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10583                                             xoffset, yoffset, zoffset,
10584                                             width, height, depth, format, type,
10585                                             pixels));
10586    }
10587 }
10588 
10589 
10590 static void GLAPIENTRY
save_CopyMultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)10591 save_CopyMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
10592                            GLenum internalformat, GLint x, GLint y,
10593                            GLsizei width, GLint border)
10594 {
10595    GET_CURRENT_CONTEXT(ctx);
10596    Node *n;
10597    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10598    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE1D, 8);
10599    if (n) {
10600       n[1].e = texunit;
10601       n[2].e = target;
10602       n[3].i = level;
10603       n[4].e = internalformat;
10604       n[5].i = x;
10605       n[6].i = y;
10606       n[7].i = width;
10607       n[8].i = border;
10608    }
10609    if (ctx->ExecuteFlag) {
10610       CALL_CopyMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
10611                                              internalformat, x, y,
10612                                              width, border));
10613    }
10614 }
10615 
10616 
10617 static void GLAPIENTRY
save_CopyMultiTexImage2DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)10618 save_CopyMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
10619                            GLenum internalformat,
10620                            GLint x, GLint y, GLsizei width,
10621                            GLsizei height, GLint border)
10622 {
10623    GET_CURRENT_CONTEXT(ctx);
10624    Node *n;
10625    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10626    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE2D, 9);
10627    if (n) {
10628       n[1].e = texunit;
10629       n[2].e = target;
10630       n[3].i = level;
10631       n[4].e = internalformat;
10632       n[5].i = x;
10633       n[6].i = y;
10634       n[7].i = width;
10635       n[8].i = height;
10636       n[9].i = border;
10637    }
10638    if (ctx->ExecuteFlag) {
10639       CALL_CopyMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
10640                                              internalformat, x, y,
10641                                              width, height, border));
10642    }
10643 }
10644 
10645 
10646 static void GLAPIENTRY
save_CopyMultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)10647 save_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level,
10648                               GLint xoffset, GLint x, GLint y, GLsizei width)
10649 {
10650    GET_CURRENT_CONTEXT(ctx);
10651    Node *n;
10652    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10653    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE1D, 7);
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 = x;
10660       n[6].i = y;
10661       n[7].i = width;
10662    }
10663    if (ctx->ExecuteFlag) {
10664       CALL_CopyMultiTexSubImage1DEXT(ctx->Exec,
10665                              (texunit, target, level, xoffset, x, y, width));
10666    }
10667 }
10668 
10669 
10670 static void GLAPIENTRY
save_CopyMultiTexSubImage2DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)10671 save_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
10672                               GLint xoffset, GLint yoffset,
10673                               GLint x, GLint y, GLsizei width, GLint height)
10674 {
10675    GET_CURRENT_CONTEXT(ctx);
10676    Node *n;
10677    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10678    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE2D, 9);
10679    if (n) {
10680       n[1].e = texunit;
10681       n[2].e = target;
10682       n[3].i = level;
10683       n[4].i = xoffset;
10684       n[5].i = yoffset;
10685       n[6].i = x;
10686       n[7].i = y;
10687       n[8].i = width;
10688       n[9].i = height;
10689    }
10690    if (ctx->ExecuteFlag) {
10691       CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level,
10692                                                 xoffset, yoffset,
10693                                                 x, y, width, height));
10694    }
10695 }
10696 
10697 
10698 static void GLAPIENTRY
save_CopyMultiTexSubImage3DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLint height)10699 save_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
10700                               GLint xoffset, GLint yoffset, GLint zoffset,
10701                               GLint x, GLint y, GLsizei width, GLint height)
10702 {
10703    GET_CURRENT_CONTEXT(ctx);
10704    Node *n;
10705    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10706    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE3D, 10);
10707    if (n) {
10708       n[1].e = texunit;
10709       n[2].e = target;
10710       n[3].i = level;
10711       n[4].i = xoffset;
10712       n[5].i = yoffset;
10713       n[6].i = zoffset;
10714       n[7].i = x;
10715       n[8].i = y;
10716       n[9].i = width;
10717       n[10].i = height;
10718    }
10719    if (ctx->ExecuteFlag) {
10720       CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10721                                                 xoffset, yoffset, zoffset,
10722                                                 x, y, width, height));
10723    }
10724 }
10725 
10726 
10727 static void GLAPIENTRY
save_MultiTexEnvfvEXT(GLenum texunit,GLenum target,GLenum pname,const GLfloat * params)10728 save_MultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
10729 {
10730    GET_CURRENT_CONTEXT(ctx);
10731    Node *n;
10732    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10733    n = alloc_instruction(ctx, OPCODE_MULTITEXENV, 7);
10734    if (n) {
10735       n[1].e = texunit;
10736       n[2].e = target;
10737       n[3].e = pname;
10738       if (pname == GL_TEXTURE_ENV_COLOR) {
10739          n[4].f = params[0];
10740          n[5].f = params[1];
10741          n[6].f = params[2];
10742          n[7].f = params[3];
10743       }
10744       else {
10745          n[4].f = params[0];
10746          n[5].f = n[6].f = n[7].f = 0.0F;
10747       }
10748    }
10749    if (ctx->ExecuteFlag) {
10750       CALL_MultiTexEnvfvEXT(ctx->Exec, (texunit, target, pname, params));
10751    }
10752 }
10753 
10754 
10755 static void GLAPIENTRY
save_MultiTexEnvfEXT(GLenum texunit,GLenum target,GLenum pname,GLfloat param)10756 save_MultiTexEnvfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
10757 {
10758    GLfloat parray[4];
10759    parray[0] = (GLfloat) param;
10760    parray[1] = parray[2] = parray[3] = 0.0F;
10761    save_MultiTexEnvfvEXT(texunit, target, pname, parray);
10762 }
10763 
10764 
10765 static void GLAPIENTRY
save_MultiTexEnviEXT(GLenum texunit,GLenum target,GLenum pname,GLint param)10766 save_MultiTexEnviEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
10767 {
10768    GLfloat p[4];
10769    p[0] = (GLfloat) param;
10770    p[1] = p[2] = p[3] = 0.0F;
10771    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10772 }
10773 
10774 
10775 static void GLAPIENTRY
save_MultiTexEnvivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * param)10776 save_MultiTexEnvivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint * param)
10777 {
10778    GLfloat p[4];
10779    if (pname == GL_TEXTURE_ENV_COLOR) {
10780       p[0] = INT_TO_FLOAT(param[0]);
10781       p[1] = INT_TO_FLOAT(param[1]);
10782       p[2] = INT_TO_FLOAT(param[2]);
10783       p[3] = INT_TO_FLOAT(param[3]);
10784    }
10785    else {
10786       p[0] = (GLfloat) param[0];
10787       p[1] = p[2] = p[3] = 0.0F;
10788    }
10789    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10790 }
10791 
10792 
10793 static void GLAPIENTRY
save_CompressedTextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)10794 save_CompressedTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
10795                                  GLenum internalFormat, GLsizei width,
10796                                  GLint border, GLsizei imageSize,
10797                                  const GLvoid * data)
10798 {
10799    GET_CURRENT_CONTEXT(ctx);
10800    if (target == GL_PROXY_TEXTURE_1D) {
10801       /* don't compile, execute immediately */
10802       CALL_CompressedTextureImage1DEXT(ctx->Exec, (texture, target, level,
10803                                                    internalFormat, width,
10804                                                    border, imageSize,
10805                                                    data));
10806    }
10807    else {
10808       Node *n;
10809       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10810 
10811       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
10812                             7 + POINTER_DWORDS);
10813       if (n) {
10814          n[1].ui = texture;
10815          n[2].e = target;
10816          n[3].i = level;
10817          n[4].e = internalFormat;
10818          n[5].i = (GLint) width;
10819          n[6].i = border;
10820          n[7].i = imageSize;
10821          save_pointer(&n[8],
10822                       copy_data(data, imageSize, "glCompressedTextureImage1DEXT"));
10823       }
10824       if (ctx->ExecuteFlag) {
10825          CALL_CompressedTextureImage1DEXT(ctx->Exec,
10826                                           (texture, target, level, internalFormat,
10827                                            width, border, imageSize, data));
10828       }
10829    }
10830 }
10831 
10832 
10833 static void GLAPIENTRY
save_CompressedTextureImage2DEXT(GLuint texture,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)10834 save_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
10835                                  GLenum internalFormat, GLsizei width,
10836                                  GLsizei height, GLint border, GLsizei imageSize,
10837                                  const GLvoid * data)
10838 {
10839    GET_CURRENT_CONTEXT(ctx);
10840    if (target == GL_PROXY_TEXTURE_2D) {
10841       /* don't compile, execute immediately */
10842       CALL_CompressedTextureImage2DEXT(ctx->Exec, (texture, target, level,
10843                                                    internalFormat, width, height,
10844                                                    border, imageSize, data));
10845    }
10846    else {
10847       Node *n;
10848       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10849 
10850       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
10851                             8 + POINTER_DWORDS);
10852       if (n) {
10853          n[1].ui = texture;
10854          n[2].e = target;
10855          n[3].i = level;
10856          n[4].e = internalFormat;
10857          n[5].i = (GLint) width;
10858          n[6].i = (GLint) height;
10859          n[7].i = border;
10860          n[8].i = imageSize;
10861          save_pointer(&n[9],
10862                       copy_data(data, imageSize, "glCompressedTextureImage2DEXT"));
10863       }
10864       if (ctx->ExecuteFlag) {
10865          CALL_CompressedTextureImage2DEXT(ctx->Exec,
10866                                           (texture, target, level, internalFormat,
10867                                            width, height, border, imageSize, data));
10868       }
10869    }
10870 }
10871 
10872 
10873 static void GLAPIENTRY
save_CompressedTextureImage3DEXT(GLuint texture,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)10874 save_CompressedTextureImage3DEXT(GLuint texture, GLenum target, GLint level,
10875                                  GLenum internalFormat, GLsizei width,
10876                                  GLsizei height, GLsizei depth, GLint border,
10877                                  GLsizei imageSize, const GLvoid * data)
10878 {
10879    GET_CURRENT_CONTEXT(ctx);
10880    if (target == GL_PROXY_TEXTURE_3D) {
10881       /* don't compile, execute immediately */
10882       CALL_CompressedTextureImage3DEXT(ctx->Exec, (texture, target, level,
10883                                                    internalFormat, width,
10884                                                    height, depth, border,
10885                                                    imageSize, data));
10886    }
10887    else {
10888       Node *n;
10889       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10890 
10891       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
10892                             9 + POINTER_DWORDS);
10893       if (n) {
10894          n[1].ui = texture;
10895          n[2].e = target;
10896          n[3].i = level;
10897          n[4].e = internalFormat;
10898          n[5].i = (GLint) width;
10899          n[6].i = (GLint) height;
10900          n[7].i = (GLint) depth;
10901          n[8].i = border;
10902          n[9].i = imageSize;
10903          save_pointer(&n[10],
10904                       copy_data(data, imageSize, "glCompressedTextureImage3DEXT"));
10905       }
10906       if (ctx->ExecuteFlag) {
10907          CALL_CompressedTextureImage3DEXT(ctx->Exec,
10908                                           (texture, target, level, internalFormat,
10909                                            width, height, depth, border, imageSize,
10910                                            data));
10911       }
10912    }
10913 }
10914 
10915 
10916 static void GLAPIENTRY
save_CompressedTextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)10917 save_CompressedTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10918                                     GLsizei width, GLenum format,
10919                                     GLsizei imageSize, const GLvoid * data)
10920 {
10921    Node *n;
10922    GET_CURRENT_CONTEXT(ctx);
10923    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10924 
10925    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
10926                          7 + POINTER_DWORDS);
10927    if (n) {
10928       n[1].ui = texture;
10929       n[2].e = target;
10930       n[3].i = level;
10931       n[4].i = xoffset;
10932       n[5].i = (GLint) width;
10933       n[6].e = format;
10934       n[7].i = imageSize;
10935       save_pointer(&n[8],
10936                    copy_data(data, imageSize, "glCompressedTextureSubImage1DEXT"));
10937    }
10938    if (ctx->ExecuteFlag) {
10939       CALL_CompressedTextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset,
10940                                                       width, format, imageSize, data));
10941    }
10942 }
10943 
10944 
10945 static void GLAPIENTRY
save_CompressedTextureSubImage2DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)10946 save_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10947                                     GLint yoffset, GLsizei width, GLsizei height,
10948                                     GLenum format, GLsizei imageSize,
10949                                     const GLvoid * data)
10950 {
10951    Node *n;
10952    GET_CURRENT_CONTEXT(ctx);
10953    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10954 
10955    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
10956                          9 + POINTER_DWORDS);
10957    if (n) {
10958       n[1].ui = texture;
10959       n[2].e = target;
10960       n[3].i = level;
10961       n[4].i = xoffset;
10962       n[5].i = yoffset;
10963       n[6].i = (GLint) width;
10964       n[7].i = (GLint) height;
10965       n[8].e = format;
10966       n[9].i = imageSize;
10967       save_pointer(&n[10],
10968                    copy_data(data, imageSize, "glCompressedTextureSubImage2DEXT"));
10969    }
10970    if (ctx->ExecuteFlag) {
10971       CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
10972                                           (texture, target, level, xoffset, yoffset,
10973                                            width, height, format, imageSize, data));
10974    }
10975 }
10976 
10977 
10978 static void GLAPIENTRY
save_CompressedTextureSubImage3DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const GLvoid * data)10979 save_CompressedTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10980                                     GLint yoffset, GLint zoffset, GLsizei width,
10981                                     GLsizei height, GLsizei depth, GLenum format,
10982                                     GLsizei imageSize, const GLvoid * data)
10983 {
10984    Node *n;
10985    GET_CURRENT_CONTEXT(ctx);
10986    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10987 
10988    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
10989                          11 + POINTER_DWORDS);
10990    if (n) {
10991       n[1].ui = texture;
10992       n[2].e = target;
10993       n[3].i = level;
10994       n[4].i = xoffset;
10995       n[5].i = yoffset;
10996       n[6].i = zoffset;
10997       n[7].i = (GLint) width;
10998       n[8].i = (GLint) height;
10999       n[9].i = (GLint) depth;
11000       n[10].e = format;
11001       n[11].i = imageSize;
11002       save_pointer(&n[12],
11003                    copy_data(data, imageSize, "glCompressedTextureSubImage3DEXT"));
11004    }
11005    if (ctx->ExecuteFlag) {
11006       CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
11007                                           (texture, target, level, xoffset, yoffset,
11008                                            zoffset, width, height, depth, format,
11009                                            imageSize, data));
11010    }
11011 }
11012 
11013 
11014 static void GLAPIENTRY
save_CompressedMultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)11015 save_CompressedMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
11016                                   GLenum internalFormat, GLsizei width,
11017                                   GLint border, GLsizei imageSize,
11018                                   const GLvoid * data)
11019 {
11020    GET_CURRENT_CONTEXT(ctx);
11021    if (target == GL_PROXY_TEXTURE_1D) {
11022       /* don't compile, execute immediately */
11023       CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
11024                                                    internalFormat, width,
11025                                                    border, imageSize,
11026                                                    data));
11027    }
11028    else {
11029       Node *n;
11030       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11031 
11032       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
11033                             7 + POINTER_DWORDS);
11034       if (n) {
11035          n[1].e = texunit;
11036          n[2].e = target;
11037          n[3].i = level;
11038          n[4].e = internalFormat;
11039          n[5].i = (GLint) width;
11040          n[6].i = border;
11041          n[7].i = imageSize;
11042          save_pointer(&n[8],
11043                       copy_data(data, imageSize, "glCompressedMultiTexImage1DEXT"));
11044       }
11045       if (ctx->ExecuteFlag) {
11046          CALL_CompressedMultiTexImage1DEXT(ctx->Exec,
11047                                            (texunit, target, level, internalFormat,
11048                                             width, border, imageSize, data));
11049       }
11050    }
11051 }
11052 
11053 
11054 static void GLAPIENTRY
save_CompressedMultiTexImage2DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)11055 save_CompressedMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
11056                                   GLenum internalFormat, GLsizei width,
11057                                   GLsizei height, GLint border, GLsizei imageSize,
11058                                   const GLvoid * data)
11059 {
11060    GET_CURRENT_CONTEXT(ctx);
11061    if (target == GL_PROXY_TEXTURE_2D) {
11062       /* don't compile, execute immediately */
11063       CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
11064                                                    internalFormat, width, height,
11065                                                    border, imageSize, data));
11066    }
11067    else {
11068       Node *n;
11069       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11070 
11071       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
11072                             8 + POINTER_DWORDS);
11073       if (n) {
11074          n[1].e = texunit;
11075          n[2].e = target;
11076          n[3].i = level;
11077          n[4].e = internalFormat;
11078          n[5].i = (GLint) width;
11079          n[6].i = (GLint) height;
11080          n[7].i = border;
11081          n[8].i = imageSize;
11082          save_pointer(&n[9],
11083                       copy_data(data, imageSize, "glCompressedMultiTexImage2DEXT"));
11084       }
11085       if (ctx->ExecuteFlag) {
11086          CALL_CompressedMultiTexImage2DEXT(ctx->Exec,
11087                                            (texunit, target, level, internalFormat,
11088                                             width, height, border, imageSize, data));
11089       }
11090    }
11091 }
11092 
11093 
11094 static void GLAPIENTRY
save_CompressedMultiTexImage3DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)11095 save_CompressedMultiTexImage3DEXT(GLenum texunit, GLenum target, GLint level,
11096                                   GLenum internalFormat, GLsizei width,
11097                                   GLsizei height, GLsizei depth, GLint border,
11098                                   GLsizei imageSize, const GLvoid * data)
11099 {
11100    GET_CURRENT_CONTEXT(ctx);
11101    if (target == GL_PROXY_TEXTURE_3D) {
11102       /* don't compile, execute immediately */
11103       CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (texunit, target, level,
11104                                                    internalFormat, width,
11105                                                    height, depth, border,
11106                                                    imageSize, data));
11107    }
11108    else {
11109       Node *n;
11110       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11111 
11112       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
11113                             9 + POINTER_DWORDS);
11114       if (n) {
11115          n[1].e = texunit;
11116          n[2].e = target;
11117          n[3].i = level;
11118          n[4].e = internalFormat;
11119          n[5].i = (GLint) width;
11120          n[6].i = (GLint) height;
11121          n[7].i = (GLint) depth;
11122          n[8].i = border;
11123          n[9].i = imageSize;
11124          save_pointer(&n[10],
11125                       copy_data(data, imageSize, "glCompressedMultiTexImage3DEXT"));
11126       }
11127       if (ctx->ExecuteFlag) {
11128          CALL_CompressedMultiTexImage3DEXT(ctx->Exec,
11129                                            (texunit, target, level, internalFormat,
11130                                             width, height, depth, border, imageSize,
11131                                             data));
11132       }
11133    }
11134 }
11135 
11136 
11137 static void GLAPIENTRY
save_CompressedMultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)11138 save_CompressedMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
11139                                      GLsizei width, GLenum format,
11140                                      GLsizei imageSize, const GLvoid * data)
11141 {
11142    Node *n;
11143    GET_CURRENT_CONTEXT(ctx);
11144    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11145 
11146    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
11147                          7 + POINTER_DWORDS);
11148    if (n) {
11149       n[1].e = texunit;
11150       n[2].e = target;
11151       n[3].i = level;
11152       n[4].i = xoffset;
11153       n[5].i = (GLint) width;
11154       n[6].e = format;
11155       n[7].i = imageSize;
11156       save_pointer(&n[8],
11157                    copy_data(data, imageSize, "glCompressedMultiTexSubImage1DEXT"));
11158    }
11159    if (ctx->ExecuteFlag) {
11160       CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset,
11161                                                        width, format, imageSize, data));
11162    }
11163 }
11164 
11165 
11166 static void GLAPIENTRY
save_CompressedMultiTexSubImage2DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)11167 save_CompressedMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
11168                                      GLint yoffset, GLsizei width, GLsizei height,
11169                                      GLenum format, GLsizei imageSize,
11170                                      const GLvoid * data)
11171 {
11172    Node *n;
11173    GET_CURRENT_CONTEXT(ctx);
11174    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11175 
11176    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
11177                          9 + POINTER_DWORDS);
11178    if (n) {
11179       n[1].e = texunit;
11180       n[2].e = target;
11181       n[3].i = level;
11182       n[4].i = xoffset;
11183       n[5].i = yoffset;
11184       n[6].i = (GLint) width;
11185       n[7].i = (GLint) height;
11186       n[8].e = format;
11187       n[9].i = imageSize;
11188       save_pointer(&n[10],
11189                    copy_data(data, imageSize, "glCompressedMultiTexSubImage2DEXT"));
11190    }
11191    if (ctx->ExecuteFlag) {
11192       CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
11193                                            (texunit, target, level, xoffset, yoffset,
11194                                             width, height, format, imageSize, data));
11195    }
11196 }
11197 
11198 
11199 static void GLAPIENTRY
save_CompressedMultiTexSubImage3DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const GLvoid * data)11200 save_CompressedMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
11201                                      GLint yoffset, GLint zoffset, GLsizei width,
11202                                      GLsizei height, GLsizei depth, GLenum format,
11203                                      GLsizei imageSize, const GLvoid * data)
11204 {
11205    Node *n;
11206    GET_CURRENT_CONTEXT(ctx);
11207    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11208 
11209    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
11210                          11 + POINTER_DWORDS);
11211    if (n) {
11212       n[1].e = texunit;
11213       n[2].e = target;
11214       n[3].i = level;
11215       n[4].i = xoffset;
11216       n[5].i = yoffset;
11217       n[6].i = zoffset;
11218       n[7].i = (GLint) width;
11219       n[8].i = (GLint) height;
11220       n[9].i = (GLint) depth;
11221       n[10].e = format;
11222       n[11].i = imageSize;
11223       save_pointer(&n[12],
11224                    copy_data(data, imageSize, "glCompressedMultiTexSubImage3DEXT"));
11225    }
11226    if (ctx->ExecuteFlag) {
11227       CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
11228                                            (texunit, target, level, xoffset, yoffset,
11229                                             zoffset, width, height, depth, format,
11230                                             imageSize, data));
11231    }
11232 }
11233 
11234 
11235 static void GLAPIENTRY
save_NamedProgramStringEXT(GLuint program,GLenum target,GLenum format,GLsizei len,const GLvoid * string)11236 save_NamedProgramStringEXT(GLuint program, GLenum target, GLenum format, GLsizei len,
11237                            const GLvoid * string)
11238 {
11239    GET_CURRENT_CONTEXT(ctx);
11240    Node *n;
11241 
11242    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11243 
11244    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_STRING, 4 + POINTER_DWORDS);
11245    if (n) {
11246       GLubyte *programCopy = malloc(len);
11247       if (!programCopy) {
11248          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNamedProgramStringEXT");
11249          return;
11250       }
11251       memcpy(programCopy, string, len);
11252       n[1].ui = program;
11253       n[2].e = target;
11254       n[3].e = format;
11255       n[4].i = len;
11256       save_pointer(&n[5], programCopy);
11257    }
11258    if (ctx->ExecuteFlag) {
11259       CALL_NamedProgramStringEXT(ctx->Exec, (program, target, format, len, string));
11260    }
11261 }
11262 
11263 
11264 static void GLAPIENTRY
save_NamedProgramLocalParameter4fEXT(GLuint program,GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)11265 save_NamedProgramLocalParameter4fEXT(GLuint program, GLenum target, GLuint index,
11266                                      GLfloat x, GLfloat y, GLfloat z, GLfloat w)
11267 {
11268    GET_CURRENT_CONTEXT(ctx);
11269    Node *n;
11270    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11271    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER, 7);
11272    if (n) {
11273       n[1].ui = program;
11274       n[2].e = target;
11275       n[3].ui = index;
11276       n[4].f = x;
11277       n[5].f = y;
11278       n[6].f = z;
11279       n[7].f = w;
11280    }
11281    if (ctx->ExecuteFlag) {
11282       CALL_NamedProgramLocalParameter4fEXT(ctx->Exec, (program, target, index, x, y, z, w));
11283    }
11284 }
11285 
11286 
11287 static void GLAPIENTRY
save_NamedProgramLocalParameter4fvEXT(GLuint program,GLenum target,GLuint index,const GLfloat * params)11288 save_NamedProgramLocalParameter4fvEXT(GLuint program, GLenum target, GLuint index,
11289                                       const GLfloat *params)
11290 {
11291    save_NamedProgramLocalParameter4fEXT(program, target, index, params[0],
11292                                         params[1], params[2], params[3]);
11293 }
11294 
11295 
11296 static void GLAPIENTRY
save_NamedProgramLocalParameter4dEXT(GLuint program,GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)11297 save_NamedProgramLocalParameter4dEXT(GLuint program, GLenum target, GLuint index,
11298                                     GLdouble x, GLdouble y,
11299                                     GLdouble z, GLdouble w)
11300 {
11301       save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) x,
11302                                            (GLfloat) y, (GLfloat) z, (GLfloat) w);
11303 }
11304 
11305 
11306 static void GLAPIENTRY
save_NamedProgramLocalParameter4dvEXT(GLuint program,GLenum target,GLuint index,const GLdouble * params)11307 save_NamedProgramLocalParameter4dvEXT(GLuint program, GLenum target, GLuint index,
11308                                       const GLdouble *params)
11309 {
11310    save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) params[0],
11311                                         (GLfloat) params[1], (GLfloat) params[2],
11312                                         (GLfloat) params[3]);
11313 }
11314 
11315 
11316 /**
11317  * Save an error-generating command into display list.
11318  *
11319  * KW: Will appear in the list before the vertex buffer containing the
11320  * command that provoked the error.  I don't see this as a problem.
11321  */
11322 static void
save_error(struct gl_context * ctx,GLenum error,const char * s)11323 save_error(struct gl_context *ctx, GLenum error, const char *s)
11324 {
11325    Node *n;
11326    n = alloc_instruction(ctx, OPCODE_ERROR, 1 + POINTER_DWORDS);
11327    if (n) {
11328       n[1].e = error;
11329       save_pointer(&n[2], (void *) s);
11330       /* note: the data/string here doesn't have to be freed in
11331        * _mesa_delete_list() since the string is never dynamically
11332        * allocated.
11333        */
11334    }
11335 }
11336 
11337 
11338 /**
11339  * Compile an error into current display list.
11340  */
11341 void
_mesa_compile_error(struct gl_context * ctx,GLenum error,const char * s)11342 _mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s)
11343 {
11344    if (ctx->CompileFlag)
11345       save_error(ctx, error, s);
11346    if (ctx->ExecuteFlag)
11347       _mesa_error(ctx, error, "%s", s);
11348 }
11349 
11350 
11351 /**
11352  * Test if ID names a display list.
11353  */
11354 static GLboolean
islist(struct gl_context * ctx,GLuint list)11355 islist(struct gl_context *ctx, GLuint list)
11356 {
11357    if (list > 0 && _mesa_lookup_list(ctx, list)) {
11358       return GL_TRUE;
11359    }
11360    else {
11361       return GL_FALSE;
11362    }
11363 }
11364 
11365 
11366 
11367 /**********************************************************************/
11368 /*                     Display list execution                         */
11369 /**********************************************************************/
11370 
11371 
11372 /*
11373  * Execute a display list.  Note that the ListBase offset must have already
11374  * been added before calling this function.  I.e. the list argument is
11375  * the absolute list number, not relative to ListBase.
11376  * \param list - display list number
11377  */
11378 static void
execute_list(struct gl_context * ctx,GLuint list)11379 execute_list(struct gl_context *ctx, GLuint list)
11380 {
11381    struct gl_display_list *dlist;
11382    Node *n;
11383    GLboolean done;
11384 
11385    if (list == 0 || !islist(ctx, list))
11386       return;
11387 
11388    if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
11389       /* raise an error? */
11390       return;
11391    }
11392 
11393    dlist = _mesa_lookup_list(ctx, list);
11394    if (!dlist)
11395       return;
11396 
11397    ctx->ListState.CallDepth++;
11398 
11399    vbo_save_BeginCallList(ctx, dlist);
11400 
11401    n = dlist->Head;
11402 
11403    done = GL_FALSE;
11404    while (!done) {
11405       const OpCode opcode = n[0].opcode;
11406 
11407       if (is_ext_opcode(opcode)) {
11408          n += ext_opcode_execute(ctx, n);
11409       }
11410       else {
11411          switch (opcode) {
11412          case OPCODE_ERROR:
11413             _mesa_error(ctx, n[1].e, "%s", (const char *) get_pointer(&n[2]));
11414             break;
11415          case OPCODE_ACCUM:
11416             CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
11417             break;
11418          case OPCODE_ALPHA_FUNC:
11419             CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
11420             break;
11421          case OPCODE_BIND_TEXTURE:
11422             CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
11423             break;
11424          case OPCODE_BITMAP:
11425             {
11426                const struct gl_pixelstore_attrib save = ctx->Unpack;
11427                ctx->Unpack = ctx->DefaultPacking;
11428                CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i,
11429                                        n[3].f, n[4].f, n[5].f, n[6].f,
11430                                        get_pointer(&n[7])));
11431                ctx->Unpack = save;      /* restore */
11432             }
11433             break;
11434          case OPCODE_BLEND_COLOR:
11435             CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11436             break;
11437          case OPCODE_BLEND_EQUATION:
11438             CALL_BlendEquation(ctx->Exec, (n[1].e));
11439             break;
11440          case OPCODE_BLEND_EQUATION_SEPARATE:
11441             CALL_BlendEquationSeparate(ctx->Exec, (n[1].e, n[2].e));
11442             break;
11443          case OPCODE_BLEND_FUNC_SEPARATE:
11444             CALL_BlendFuncSeparate(ctx->Exec,
11445                                       (n[1].e, n[2].e, n[3].e, n[4].e));
11446             break;
11447 
11448          case OPCODE_BLEND_FUNC_I:
11449             /* GL_ARB_draw_buffers_blend */
11450             CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e));
11451             break;
11452          case OPCODE_BLEND_FUNC_SEPARATE_I:
11453             /* GL_ARB_draw_buffers_blend */
11454             CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e,
11455                                                    n[4].e, n[5].e));
11456             break;
11457          case OPCODE_BLEND_EQUATION_I:
11458             /* GL_ARB_draw_buffers_blend */
11459             CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e));
11460             break;
11461          case OPCODE_BLEND_EQUATION_SEPARATE_I:
11462             /* GL_ARB_draw_buffers_blend */
11463             CALL_BlendEquationSeparateiARB(ctx->Exec,
11464                                            (n[1].ui, n[2].e, n[3].e));
11465             break;
11466 
11467          case OPCODE_CALL_LIST:
11468             /* Generated by glCallList(), don't add ListBase */
11469             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
11470                execute_list(ctx, n[1].ui);
11471             }
11472             break;
11473          case OPCODE_CALL_LISTS:
11474             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
11475                CALL_CallLists(ctx->Exec, (n[1].i, n[2].e, get_pointer(&n[3])));
11476             }
11477             break;
11478          case OPCODE_CLEAR:
11479             CALL_Clear(ctx->Exec, (n[1].bf));
11480             break;
11481          case OPCODE_CLEAR_BUFFER_IV:
11482             {
11483                GLint value[4];
11484                value[0] = n[3].i;
11485                value[1] = n[4].i;
11486                value[2] = n[5].i;
11487                value[3] = n[6].i;
11488                CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));
11489             }
11490             break;
11491          case OPCODE_CLEAR_BUFFER_UIV:
11492             {
11493                GLuint value[4];
11494                value[0] = n[3].ui;
11495                value[1] = n[4].ui;
11496                value[2] = n[5].ui;
11497                value[3] = n[6].ui;
11498                CALL_ClearBufferuiv(ctx->Exec, (n[1].e, n[2].i, value));
11499             }
11500             break;
11501          case OPCODE_CLEAR_BUFFER_FV:
11502             {
11503                GLfloat value[4];
11504                value[0] = n[3].f;
11505                value[1] = n[4].f;
11506                value[2] = n[5].f;
11507                value[3] = n[6].f;
11508                CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));
11509             }
11510             break;
11511          case OPCODE_CLEAR_BUFFER_FI:
11512             CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));
11513             break;
11514          case OPCODE_CLEAR_COLOR:
11515             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11516             break;
11517          case OPCODE_CLEAR_ACCUM:
11518             CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11519             break;
11520          case OPCODE_CLEAR_DEPTH:
11521             CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
11522             break;
11523          case OPCODE_CLEAR_INDEX:
11524             CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
11525             break;
11526          case OPCODE_CLEAR_STENCIL:
11527             CALL_ClearStencil(ctx->Exec, (n[1].i));
11528             break;
11529          case OPCODE_CLIP_PLANE:
11530             {
11531                GLdouble eq[4];
11532                eq[0] = n[2].f;
11533                eq[1] = n[3].f;
11534                eq[2] = n[4].f;
11535                eq[3] = n[5].f;
11536                CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
11537             }
11538             break;
11539          case OPCODE_COLOR_MASK:
11540             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
11541             break;
11542          case OPCODE_COLOR_MASK_INDEXED:
11543             CALL_ColorMaski(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
11544                                                  n[4].b, n[5].b));
11545             break;
11546          case OPCODE_COLOR_MATERIAL:
11547             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
11548             break;
11549          case OPCODE_COPY_PIXELS:
11550             CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
11551                                         (GLsizei) n[3].i, (GLsizei) n[4].i,
11552                                         n[5].e));
11553             break;
11554          case OPCODE_COPY_TEX_IMAGE1D:
11555             CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11556                                             n[5].i, n[6].i, n[7].i));
11557             break;
11558          case OPCODE_COPY_TEX_IMAGE2D:
11559             CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11560                                             n[5].i, n[6].i, n[7].i, n[8].i));
11561             break;
11562          case OPCODE_COPY_TEX_SUB_IMAGE1D:
11563             CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11564                                                n[4].i, n[5].i, n[6].i));
11565             break;
11566          case OPCODE_COPY_TEX_SUB_IMAGE2D:
11567             CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11568                                                n[4].i, n[5].i, n[6].i, n[7].i,
11569                                                n[8].i));
11570             break;
11571          case OPCODE_COPY_TEX_SUB_IMAGE3D:
11572             CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11573                                                n[4].i, n[5].i, n[6].i, n[7].i,
11574                                                n[8].i, n[9].i));
11575             break;
11576          case OPCODE_CULL_FACE:
11577             CALL_CullFace(ctx->Exec, (n[1].e));
11578             break;
11579          case OPCODE_DEPTH_FUNC:
11580             CALL_DepthFunc(ctx->Exec, (n[1].e));
11581             break;
11582          case OPCODE_DEPTH_MASK:
11583             CALL_DepthMask(ctx->Exec, (n[1].b));
11584             break;
11585          case OPCODE_DEPTH_RANGE:
11586             CALL_DepthRange(ctx->Exec,
11587                             ((GLclampd) n[1].f, (GLclampd) n[2].f));
11588             break;
11589          case OPCODE_DISABLE:
11590             CALL_Disable(ctx->Exec, (n[1].e));
11591             break;
11592          case OPCODE_DISABLE_INDEXED:
11593             CALL_Disablei(ctx->Exec, (n[1].ui, n[2].e));
11594             break;
11595          case OPCODE_DRAW_BUFFER:
11596             CALL_DrawBuffer(ctx->Exec, (n[1].e));
11597             break;
11598          case OPCODE_DRAW_PIXELS:
11599             {
11600                const struct gl_pixelstore_attrib save = ctx->Unpack;
11601                ctx->Unpack = ctx->DefaultPacking;
11602                CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
11603                                            get_pointer(&n[5])));
11604                ctx->Unpack = save;      /* restore */
11605             }
11606             break;
11607          case OPCODE_ENABLE:
11608             CALL_Enable(ctx->Exec, (n[1].e));
11609             break;
11610          case OPCODE_ENABLE_INDEXED:
11611             CALL_Enablei(ctx->Exec, (n[1].ui, n[2].e));
11612             break;
11613          case OPCODE_EVALMESH1:
11614             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
11615             break;
11616          case OPCODE_EVALMESH2:
11617             CALL_EvalMesh2(ctx->Exec,
11618                            (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
11619             break;
11620          case OPCODE_FOG:
11621             {
11622                GLfloat p[4];
11623                p[0] = n[2].f;
11624                p[1] = n[3].f;
11625                p[2] = n[4].f;
11626                p[3] = n[5].f;
11627                CALL_Fogfv(ctx->Exec, (n[1].e, p));
11628             }
11629             break;
11630          case OPCODE_FRONT_FACE:
11631             CALL_FrontFace(ctx->Exec, (n[1].e));
11632             break;
11633          case OPCODE_FRUSTUM:
11634             CALL_Frustum(ctx->Exec,
11635                          (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11636             break;
11637          case OPCODE_HINT:
11638             CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
11639             break;
11640          case OPCODE_INDEX_MASK:
11641             CALL_IndexMask(ctx->Exec, (n[1].ui));
11642             break;
11643          case OPCODE_INIT_NAMES:
11644             CALL_InitNames(ctx->Exec, ());
11645             break;
11646          case OPCODE_LIGHT:
11647             {
11648                GLfloat p[4];
11649                p[0] = n[3].f;
11650                p[1] = n[4].f;
11651                p[2] = n[5].f;
11652                p[3] = n[6].f;
11653                CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
11654             }
11655             break;
11656          case OPCODE_LIGHT_MODEL:
11657             {
11658                GLfloat p[4];
11659                p[0] = n[2].f;
11660                p[1] = n[3].f;
11661                p[2] = n[4].f;
11662                p[3] = n[5].f;
11663                CALL_LightModelfv(ctx->Exec, (n[1].e, p));
11664             }
11665             break;
11666          case OPCODE_LINE_STIPPLE:
11667             CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
11668             break;
11669          case OPCODE_LINE_WIDTH:
11670             CALL_LineWidth(ctx->Exec, (n[1].f));
11671             break;
11672          case OPCODE_LIST_BASE:
11673             CALL_ListBase(ctx->Exec, (n[1].ui));
11674             break;
11675          case OPCODE_LOAD_IDENTITY:
11676             CALL_LoadIdentity(ctx->Exec, ());
11677             break;
11678          case OPCODE_LOAD_MATRIX:
11679             STATIC_ASSERT(sizeof(Node) == sizeof(GLfloat));
11680             CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
11681             break;
11682          case OPCODE_LOAD_NAME:
11683             CALL_LoadName(ctx->Exec, (n[1].ui));
11684             break;
11685          case OPCODE_LOGIC_OP:
11686             CALL_LogicOp(ctx->Exec, (n[1].e));
11687             break;
11688          case OPCODE_MAP1:
11689             {
11690                GLenum target = n[1].e;
11691                GLint ustride = _mesa_evaluator_components(target);
11692                GLint uorder = n[5].i;
11693                GLfloat u1 = n[2].f;
11694                GLfloat u2 = n[3].f;
11695                CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
11696                                       (GLfloat *) get_pointer(&n[6])));
11697             }
11698             break;
11699          case OPCODE_MAP2:
11700             {
11701                GLenum target = n[1].e;
11702                GLfloat u1 = n[2].f;
11703                GLfloat u2 = n[3].f;
11704                GLfloat v1 = n[4].f;
11705                GLfloat v2 = n[5].f;
11706                GLint ustride = n[6].i;
11707                GLint vstride = n[7].i;
11708                GLint uorder = n[8].i;
11709                GLint vorder = n[9].i;
11710                CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
11711                                       v1, v2, vstride, vorder,
11712                                       (GLfloat *) get_pointer(&n[10])));
11713             }
11714             break;
11715          case OPCODE_MAPGRID1:
11716             CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
11717             break;
11718          case OPCODE_MAPGRID2:
11719             CALL_MapGrid2f(ctx->Exec,
11720                            (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
11721             break;
11722          case OPCODE_MATRIX_MODE:
11723             CALL_MatrixMode(ctx->Exec, (n[1].e));
11724             break;
11725          case OPCODE_MULT_MATRIX:
11726             CALL_MultMatrixf(ctx->Exec, (&n[1].f));
11727             break;
11728          case OPCODE_ORTHO:
11729             CALL_Ortho(ctx->Exec,
11730                        (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11731             break;
11732          case OPCODE_PASSTHROUGH:
11733             CALL_PassThrough(ctx->Exec, (n[1].f));
11734             break;
11735          case OPCODE_PATCH_PARAMETER_I:
11736             CALL_PatchParameteri(ctx->Exec, (n[1].e, n[2].i));
11737             break;
11738          case OPCODE_PATCH_PARAMETER_FV_INNER:
11739             {
11740                GLfloat params[2];
11741                params[0] = n[2].f;
11742                params[1] = n[3].f;
11743                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11744             }
11745             break;
11746          case OPCODE_PATCH_PARAMETER_FV_OUTER:
11747             {
11748                GLfloat params[4];
11749                params[0] = n[2].f;
11750                params[1] = n[3].f;
11751                params[2] = n[4].f;
11752                params[3] = n[5].f;
11753                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11754             }
11755             break;
11756          case OPCODE_PIXEL_MAP:
11757             CALL_PixelMapfv(ctx->Exec,
11758                             (n[1].e, n[2].i, get_pointer(&n[3])));
11759             break;
11760          case OPCODE_PIXEL_TRANSFER:
11761             CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
11762             break;
11763          case OPCODE_PIXEL_ZOOM:
11764             CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
11765             break;
11766          case OPCODE_POINT_SIZE:
11767             CALL_PointSize(ctx->Exec, (n[1].f));
11768             break;
11769          case OPCODE_POINT_PARAMETERS:
11770             {
11771                GLfloat params[3];
11772                params[0] = n[2].f;
11773                params[1] = n[3].f;
11774                params[2] = n[4].f;
11775                CALL_PointParameterfv(ctx->Exec, (n[1].e, params));
11776             }
11777             break;
11778          case OPCODE_POLYGON_MODE:
11779             CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
11780             break;
11781          case OPCODE_POLYGON_STIPPLE:
11782             {
11783                const struct gl_pixelstore_attrib save = ctx->Unpack;
11784                ctx->Unpack = ctx->DefaultPacking;
11785                CALL_PolygonStipple(ctx->Exec, (get_pointer(&n[1])));
11786                ctx->Unpack = save;      /* restore */
11787             }
11788             break;
11789          case OPCODE_POLYGON_OFFSET:
11790             CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
11791             break;
11792          case OPCODE_POLYGON_OFFSET_CLAMP:
11793             CALL_PolygonOffsetClampEXT(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11794             break;
11795          case OPCODE_POP_ATTRIB:
11796             CALL_PopAttrib(ctx->Exec, ());
11797             break;
11798          case OPCODE_POP_MATRIX:
11799             CALL_PopMatrix(ctx->Exec, ());
11800             break;
11801          case OPCODE_POP_NAME:
11802             CALL_PopName(ctx->Exec, ());
11803             break;
11804          case OPCODE_PRIORITIZE_TEXTURE:
11805             CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
11806             break;
11807          case OPCODE_PUSH_ATTRIB:
11808             CALL_PushAttrib(ctx->Exec, (n[1].bf));
11809             break;
11810          case OPCODE_PUSH_MATRIX:
11811             CALL_PushMatrix(ctx->Exec, ());
11812             break;
11813          case OPCODE_PUSH_NAME:
11814             CALL_PushName(ctx->Exec, (n[1].ui));
11815             break;
11816          case OPCODE_RASTER_POS:
11817             CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11818             break;
11819          case OPCODE_READ_BUFFER:
11820             CALL_ReadBuffer(ctx->Exec, (n[1].e));
11821             break;
11822          case OPCODE_ROTATE:
11823             CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11824             break;
11825          case OPCODE_SCALE:
11826             CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11827             break;
11828          case OPCODE_SCISSOR:
11829             CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
11830             break;
11831          case OPCODE_SHADE_MODEL:
11832             CALL_ShadeModel(ctx->Exec, (n[1].e));
11833             break;
11834          case OPCODE_PROVOKING_VERTEX:
11835             CALL_ProvokingVertex(ctx->Exec, (n[1].e));
11836             break;
11837          case OPCODE_STENCIL_FUNC:
11838             CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
11839             break;
11840          case OPCODE_STENCIL_MASK:
11841             CALL_StencilMask(ctx->Exec, (n[1].ui));
11842             break;
11843          case OPCODE_STENCIL_OP:
11844             CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
11845             break;
11846          case OPCODE_STENCIL_FUNC_SEPARATE:
11847             CALL_StencilFuncSeparate(ctx->Exec,
11848                                      (n[1].e, n[2].e, n[3].i, n[4].ui));
11849             break;
11850          case OPCODE_STENCIL_MASK_SEPARATE:
11851             CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
11852             break;
11853          case OPCODE_STENCIL_OP_SEPARATE:
11854             CALL_StencilOpSeparate(ctx->Exec,
11855                                    (n[1].e, n[2].e, n[3].e, n[4].e));
11856             break;
11857          case OPCODE_TEXENV:
11858             {
11859                GLfloat params[4];
11860                params[0] = n[3].f;
11861                params[1] = n[4].f;
11862                params[2] = n[5].f;
11863                params[3] = n[6].f;
11864                CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
11865             }
11866             break;
11867          case OPCODE_TEXGEN:
11868             {
11869                GLfloat params[4];
11870                params[0] = n[3].f;
11871                params[1] = n[4].f;
11872                params[2] = n[5].f;
11873                params[3] = n[6].f;
11874                CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
11875             }
11876             break;
11877          case OPCODE_TEXPARAMETER:
11878             {
11879                GLfloat params[4];
11880                params[0] = n[3].f;
11881                params[1] = n[4].f;
11882                params[2] = n[5].f;
11883                params[3] = n[6].f;
11884                CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
11885             }
11886             break;
11887          case OPCODE_TEX_IMAGE1D:
11888             {
11889                const struct gl_pixelstore_attrib save = ctx->Unpack;
11890                ctx->Unpack = ctx->DefaultPacking;
11891                CALL_TexImage1D(ctx->Exec, (n[1].e,      /* target */
11892                                            n[2].i,      /* level */
11893                                            n[3].i,      /* components */
11894                                            n[4].i,      /* width */
11895                                            n[5].e,      /* border */
11896                                            n[6].e,      /* format */
11897                                            n[7].e,      /* type */
11898                                            get_pointer(&n[8])));
11899                ctx->Unpack = save;      /* restore */
11900             }
11901             break;
11902          case OPCODE_TEX_IMAGE2D:
11903             {
11904                const struct gl_pixelstore_attrib save = ctx->Unpack;
11905                ctx->Unpack = ctx->DefaultPacking;
11906                CALL_TexImage2D(ctx->Exec, (n[1].e,      /* target */
11907                                            n[2].i,      /* level */
11908                                            n[3].i,      /* components */
11909                                            n[4].i,      /* width */
11910                                            n[5].i,      /* height */
11911                                            n[6].e,      /* border */
11912                                            n[7].e,      /* format */
11913                                            n[8].e,      /* type */
11914                                            get_pointer(&n[9])));
11915                ctx->Unpack = save;      /* restore */
11916             }
11917             break;
11918          case OPCODE_TEX_IMAGE3D:
11919             {
11920                const struct gl_pixelstore_attrib save = ctx->Unpack;
11921                ctx->Unpack = ctx->DefaultPacking;
11922                CALL_TexImage3D(ctx->Exec, (n[1].e,      /* target */
11923                                            n[2].i,      /* level */
11924                                            n[3].i,      /* components */
11925                                            n[4].i,      /* width */
11926                                            n[5].i,      /* height */
11927                                            n[6].i,      /* depth  */
11928                                            n[7].e,      /* border */
11929                                            n[8].e,      /* format */
11930                                            n[9].e,      /* type */
11931                                            get_pointer(&n[10])));
11932                ctx->Unpack = save;      /* restore */
11933             }
11934             break;
11935          case OPCODE_TEX_SUB_IMAGE1D:
11936             {
11937                const struct gl_pixelstore_attrib save = ctx->Unpack;
11938                ctx->Unpack = ctx->DefaultPacking;
11939                CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11940                                               n[4].i, n[5].e,
11941                                               n[6].e, get_pointer(&n[7])));
11942                ctx->Unpack = save;      /* restore */
11943             }
11944             break;
11945          case OPCODE_TEX_SUB_IMAGE2D:
11946             {
11947                const struct gl_pixelstore_attrib save = ctx->Unpack;
11948                ctx->Unpack = ctx->DefaultPacking;
11949                CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11950                                               n[4].i, n[5].e,
11951                                               n[6].i, n[7].e, n[8].e,
11952                                               get_pointer(&n[9])));
11953                ctx->Unpack = save;      /* restore */
11954             }
11955             break;
11956          case OPCODE_TEX_SUB_IMAGE3D:
11957             {
11958                const struct gl_pixelstore_attrib save = ctx->Unpack;
11959                ctx->Unpack = ctx->DefaultPacking;
11960                CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11961                                               n[4].i, n[5].i, n[6].i, n[7].i,
11962                                               n[8].i, n[9].e, n[10].e,
11963                                               get_pointer(&n[11])));
11964                ctx->Unpack = save;      /* restore */
11965             }
11966             break;
11967          case OPCODE_TRANSLATE:
11968             CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11969             break;
11970          case OPCODE_VIEWPORT:
11971             CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
11972                                       (GLsizei) n[3].i, (GLsizei) n[4].i));
11973             break;
11974          case OPCODE_WINDOW_POS:
11975             CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11976             break;
11977          case OPCODE_VIEWPORT_ARRAY_V:
11978             CALL_ViewportArrayv(ctx->Exec, (n[1].ui, n[2].si,
11979                                             get_pointer(&n[3])));
11980             break;
11981          case OPCODE_VIEWPORT_INDEXED_F:
11982             CALL_ViewportIndexedf(ctx->Exec, (n[1].ui, n[2].f, n[3].f, n[4].f,
11983                                               n[5].f));
11984             break;
11985          case OPCODE_VIEWPORT_INDEXED_FV: {
11986             GLfloat v[4];
11987             v[0] = n[2].f;
11988             v[1] = n[3].f;
11989             v[2] = n[4].f;
11990             v[3] = n[5].f;
11991             CALL_ViewportIndexedfv(ctx->Exec, (n[1].ui, v));
11992             break;
11993          }
11994          case OPCODE_SCISSOR_ARRAY_V:
11995             CALL_ScissorArrayv(ctx->Exec, (n[1].ui, n[2].si,
11996                                            get_pointer(&n[3])));
11997             break;
11998          case OPCODE_SCISSOR_INDEXED:
11999             CALL_ScissorIndexed(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].si,
12000                                             n[5].si));
12001             break;
12002          case OPCODE_SCISSOR_INDEXED_V: {
12003             GLint v[4];
12004             v[0] = n[2].i;
12005             v[1] = n[3].i;
12006             v[2] = n[4].si;
12007             v[3] = n[5].si;
12008             CALL_ScissorIndexedv(ctx->Exec, (n[1].ui, v));
12009             break;
12010          }
12011          case OPCODE_DEPTH_ARRAY_V:
12012             CALL_DepthRangeArrayv(ctx->Exec, (n[1].ui, n[2].si,
12013                                               get_pointer(&n[3])));
12014             break;
12015          case OPCODE_DEPTH_INDEXED:
12016             CALL_DepthRangeIndexed(ctx->Exec, (n[1].ui, n[2].f, n[3].f));
12017             break;
12018          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
12019             CALL_ActiveTexture(ctx->Exec, (n[1].e));
12020             break;
12021          case OPCODE_COMPRESSED_TEX_IMAGE_1D:  /* GL_ARB_texture_compression */
12022             CALL_CompressedTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
12023                                                   n[4].i, n[5].i, n[6].i,
12024                                                   get_pointer(&n[7])));
12025             break;
12026          case OPCODE_COMPRESSED_TEX_IMAGE_2D:  /* GL_ARB_texture_compression */
12027             CALL_CompressedTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
12028                                                   n[4].i, n[5].i, n[6].i,
12029                                                   n[7].i, get_pointer(&n[8])));
12030             break;
12031          case OPCODE_COMPRESSED_TEX_IMAGE_3D:  /* GL_ARB_texture_compression */
12032             CALL_CompressedTexImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
12033                                                   n[4].i, n[5].i, n[6].i,
12034                                                   n[7].i, n[8].i,
12035                                                   get_pointer(&n[9])));
12036             break;
12037          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:      /* GL_ARB_texture_compress */
12038             CALL_CompressedTexSubImage1D(ctx->Exec,
12039                                             (n[1].e, n[2].i, n[3].i, n[4].i,
12040                                              n[5].e, n[6].i,
12041                                              get_pointer(&n[7])));
12042             break;
12043          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:      /* GL_ARB_texture_compress */
12044             CALL_CompressedTexSubImage2D(ctx->Exec,
12045                                             (n[1].e, n[2].i, n[3].i, n[4].i,
12046                                              n[5].i, n[6].i, n[7].e, n[8].i,
12047                                              get_pointer(&n[9])));
12048             break;
12049          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:      /* GL_ARB_texture_compress */
12050             CALL_CompressedTexSubImage3D(ctx->Exec,
12051                                             (n[1].e, n[2].i, n[3].i, n[4].i,
12052                                              n[5].i, n[6].i, n[7].i, n[8].i,
12053                                              n[9].e, n[10].i,
12054                                              get_pointer(&n[11])));
12055             break;
12056          case OPCODE_SAMPLE_COVERAGE:  /* GL_ARB_multisample */
12057             CALL_SampleCoverage(ctx->Exec, (n[1].f, n[2].b));
12058             break;
12059          case OPCODE_WINDOW_POS_ARB:   /* GL_ARB_window_pos */
12060             CALL_WindowPos3f(ctx->Exec, (n[1].f, n[2].f, n[3].f));
12061             break;
12062          case OPCODE_BIND_PROGRAM_ARB:  /* GL_ARB_vertex_program */
12063             CALL_BindProgramARB(ctx->Exec, (n[1].e, n[2].ui));
12064             break;
12065          case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
12066             CALL_ProgramLocalParameter4fARB(ctx->Exec,
12067                                             (n[1].e, n[2].ui, n[3].f, n[4].f,
12068                                              n[5].f, n[6].f));
12069             break;
12070          case OPCODE_ACTIVE_STENCIL_FACE_EXT:
12071             CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
12072             break;
12073          case OPCODE_DEPTH_BOUNDS_EXT:
12074             CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
12075             break;
12076          case OPCODE_PROGRAM_STRING_ARB:
12077             CALL_ProgramStringARB(ctx->Exec,
12078                                   (n[1].e, n[2].e, n[3].i,
12079                                    get_pointer(&n[4])));
12080             break;
12081          case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
12082             CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
12083                                                       n[4].f, n[5].f,
12084                                                       n[6].f));
12085             break;
12086          case OPCODE_BEGIN_QUERY_ARB:
12087             CALL_BeginQuery(ctx->Exec, (n[1].e, n[2].ui));
12088             break;
12089          case OPCODE_END_QUERY_ARB:
12090             CALL_EndQuery(ctx->Exec, (n[1].e));
12091             break;
12092          case OPCODE_QUERY_COUNTER:
12093             CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e));
12094             break;
12095          case OPCODE_BEGIN_QUERY_INDEXED:
12096             CALL_BeginQueryIndexed(ctx->Exec, (n[1].e, n[2].ui, n[3].ui));
12097             break;
12098          case OPCODE_END_QUERY_INDEXED:
12099             CALL_EndQueryIndexed(ctx->Exec, (n[1].e, n[2].ui));
12100             break;
12101          case OPCODE_DRAW_BUFFERS_ARB:
12102             {
12103                GLenum buffers[MAX_DRAW_BUFFERS];
12104                GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
12105                for (i = 0; i < count; i++)
12106                   buffers[i] = n[2 + i].e;
12107                CALL_DrawBuffers(ctx->Exec, (n[1].i, buffers));
12108             }
12109             break;
12110          case OPCODE_BLIT_FRAMEBUFFER:
12111             CALL_BlitFramebuffer(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
12112                                                 n[5].i, n[6].i, n[7].i, n[8].i,
12113                                                 n[9].i, n[10].e));
12114             break;
12115          case OPCODE_PRIMITIVE_RESTART_NV:
12116             CALL_PrimitiveRestartNV(ctx->Exec, ());
12117             break;
12118 
12119          case OPCODE_USE_PROGRAM:
12120             CALL_UseProgram(ctx->Exec, (n[1].ui));
12121             break;
12122          case OPCODE_UNIFORM_1F:
12123             CALL_Uniform1f(ctx->Exec, (n[1].i, n[2].f));
12124             break;
12125          case OPCODE_UNIFORM_2F:
12126             CALL_Uniform2f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
12127             break;
12128          case OPCODE_UNIFORM_3F:
12129             CALL_Uniform3f(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f));
12130             break;
12131          case OPCODE_UNIFORM_4F:
12132             CALL_Uniform4f(ctx->Exec,
12133                               (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f));
12134             break;
12135          case OPCODE_UNIFORM_1FV:
12136             CALL_Uniform1fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12137             break;
12138          case OPCODE_UNIFORM_2FV:
12139             CALL_Uniform2fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12140             break;
12141          case OPCODE_UNIFORM_3FV:
12142             CALL_Uniform3fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12143             break;
12144          case OPCODE_UNIFORM_4FV:
12145             CALL_Uniform4fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12146             break;
12147          case OPCODE_UNIFORM_1D: {
12148             union float64_pair x;
12149 
12150             x.uint32[0] = n[2].ui;
12151             x.uint32[1] = n[3].ui;
12152 
12153             CALL_Uniform1d(ctx->Exec, (n[1].i, x.d));
12154             break;
12155          }
12156          case OPCODE_UNIFORM_2D: {
12157             union float64_pair x;
12158             union float64_pair y;
12159 
12160             x.uint32[0] = n[2].ui;
12161             x.uint32[1] = n[3].ui;
12162             y.uint32[0] = n[4].ui;
12163             y.uint32[1] = n[5].ui;
12164 
12165             CALL_Uniform2d(ctx->Exec, (n[1].i, x.d, y.d));
12166             break;
12167          }
12168          case OPCODE_UNIFORM_3D: {
12169             union float64_pair x;
12170             union float64_pair y;
12171             union float64_pair z;
12172 
12173             x.uint32[0] = n[2].ui;
12174             x.uint32[1] = n[3].ui;
12175             y.uint32[0] = n[4].ui;
12176             y.uint32[1] = n[5].ui;
12177             z.uint32[0] = n[6].ui;
12178             z.uint32[1] = n[7].ui;
12179 
12180             CALL_Uniform3d(ctx->Exec, (n[1].i, x.d, y.d, z.d));
12181             break;
12182          }
12183          case OPCODE_UNIFORM_4D: {
12184             union float64_pair x;
12185             union float64_pair y;
12186             union float64_pair z;
12187             union float64_pair w;
12188 
12189             x.uint32[0] = n[2].ui;
12190             x.uint32[1] = n[3].ui;
12191             y.uint32[0] = n[4].ui;
12192             y.uint32[1] = n[5].ui;
12193             z.uint32[0] = n[6].ui;
12194             z.uint32[1] = n[7].ui;
12195             w.uint32[0] = n[8].ui;
12196             w.uint32[1] = n[9].ui;
12197 
12198             CALL_Uniform4d(ctx->Exec, (n[1].i, x.d, y.d, z.d, w.d));
12199             break;
12200          }
12201          case OPCODE_UNIFORM_1DV:
12202             CALL_Uniform1dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12203             break;
12204          case OPCODE_UNIFORM_2DV:
12205             CALL_Uniform2dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12206             break;
12207          case OPCODE_UNIFORM_3DV:
12208             CALL_Uniform3dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12209             break;
12210          case OPCODE_UNIFORM_4DV:
12211             CALL_Uniform4dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12212             break;
12213          case OPCODE_UNIFORM_1I:
12214             CALL_Uniform1i(ctx->Exec, (n[1].i, n[2].i));
12215             break;
12216          case OPCODE_UNIFORM_2I:
12217             CALL_Uniform2i(ctx->Exec, (n[1].i, n[2].i, n[3].i));
12218             break;
12219          case OPCODE_UNIFORM_3I:
12220             CALL_Uniform3i(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12221             break;
12222          case OPCODE_UNIFORM_4I:
12223             CALL_Uniform4i(ctx->Exec,
12224                               (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
12225             break;
12226          case OPCODE_UNIFORM_1IV:
12227             CALL_Uniform1iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12228             break;
12229          case OPCODE_UNIFORM_2IV:
12230             CALL_Uniform2iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12231             break;
12232          case OPCODE_UNIFORM_3IV:
12233             CALL_Uniform3iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12234             break;
12235          case OPCODE_UNIFORM_4IV:
12236             CALL_Uniform4iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12237             break;
12238          case OPCODE_UNIFORM_1UI:
12239             CALL_Uniform1ui(ctx->Exec, (n[1].i, n[2].i));
12240             break;
12241          case OPCODE_UNIFORM_2UI:
12242             CALL_Uniform2ui(ctx->Exec, (n[1].i, n[2].i, n[3].i));
12243             break;
12244          case OPCODE_UNIFORM_3UI:
12245             CALL_Uniform3ui(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12246             break;
12247          case OPCODE_UNIFORM_4UI:
12248             CALL_Uniform4ui(ctx->Exec,
12249                             (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
12250             break;
12251          case OPCODE_UNIFORM_1UIV:
12252             CALL_Uniform1uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12253             break;
12254          case OPCODE_UNIFORM_2UIV:
12255             CALL_Uniform2uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12256             break;
12257          case OPCODE_UNIFORM_3UIV:
12258             CALL_Uniform3uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12259             break;
12260          case OPCODE_UNIFORM_4UIV:
12261             CALL_Uniform4uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12262             break;
12263          case OPCODE_UNIFORM_MATRIX22:
12264             CALL_UniformMatrix2fv(ctx->Exec,
12265                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12266             break;
12267          case OPCODE_UNIFORM_MATRIX33:
12268             CALL_UniformMatrix3fv(ctx->Exec,
12269                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12270             break;
12271          case OPCODE_UNIFORM_MATRIX44:
12272             CALL_UniformMatrix4fv(ctx->Exec,
12273                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12274             break;
12275          case OPCODE_UNIFORM_MATRIX23:
12276             CALL_UniformMatrix2x3fv(ctx->Exec,
12277                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12278             break;
12279          case OPCODE_UNIFORM_MATRIX32:
12280             CALL_UniformMatrix3x2fv(ctx->Exec,
12281                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12282             break;
12283          case OPCODE_UNIFORM_MATRIX24:
12284             CALL_UniformMatrix2x4fv(ctx->Exec,
12285                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12286             break;
12287          case OPCODE_UNIFORM_MATRIX42:
12288             CALL_UniformMatrix4x2fv(ctx->Exec,
12289                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12290             break;
12291          case OPCODE_UNIFORM_MATRIX34:
12292             CALL_UniformMatrix3x4fv(ctx->Exec,
12293                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12294             break;
12295          case OPCODE_UNIFORM_MATRIX43:
12296             CALL_UniformMatrix4x3fv(ctx->Exec,
12297                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12298             break;
12299          case OPCODE_UNIFORM_MATRIX22D:
12300             CALL_UniformMatrix2dv(ctx->Exec,
12301                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12302             break;
12303          case OPCODE_UNIFORM_MATRIX33D:
12304             CALL_UniformMatrix3dv(ctx->Exec,
12305                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12306             break;
12307          case OPCODE_UNIFORM_MATRIX44D:
12308             CALL_UniformMatrix4dv(ctx->Exec,
12309                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12310             break;
12311          case OPCODE_UNIFORM_MATRIX23D:
12312             CALL_UniformMatrix2x3dv(ctx->Exec,
12313                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12314             break;
12315          case OPCODE_UNIFORM_MATRIX32D:
12316             CALL_UniformMatrix3x2dv(ctx->Exec,
12317                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12318             break;
12319          case OPCODE_UNIFORM_MATRIX24D:
12320             CALL_UniformMatrix2x4dv(ctx->Exec,
12321                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12322             break;
12323          case OPCODE_UNIFORM_MATRIX42D:
12324             CALL_UniformMatrix4x2dv(ctx->Exec,
12325                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12326             break;
12327          case OPCODE_UNIFORM_MATRIX34D:
12328             CALL_UniformMatrix3x4dv(ctx->Exec,
12329                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12330             break;
12331          case OPCODE_UNIFORM_MATRIX43D:
12332             CALL_UniformMatrix4x3dv(ctx->Exec,
12333                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12334             break;
12335 
12336          case OPCODE_UNIFORM_1I64: {
12337             union int64_pair x;
12338 
12339             x.int32[0] = n[2].i;
12340             x.int32[1] = n[3].i;
12341 
12342             CALL_Uniform1i64ARB(ctx->Exec, (n[1].i, x.int64));
12343             break;
12344          }
12345          case OPCODE_UNIFORM_2I64: {
12346             union int64_pair x;
12347             union int64_pair y;
12348 
12349             x.int32[0] = n[2].i;
12350             x.int32[1] = n[3].i;
12351             y.int32[0] = n[4].i;
12352             y.int32[1] = n[5].i;
12353 
12354             CALL_Uniform2i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64));
12355             break;
12356          }
12357          case OPCODE_UNIFORM_3I64: {
12358             union int64_pair x;
12359             union int64_pair y;
12360             union int64_pair z;
12361 
12362             x.int32[0] = n[2].i;
12363             x.int32[1] = n[3].i;
12364             y.int32[0] = n[4].i;
12365             y.int32[1] = n[5].i;
12366             z.int32[0] = n[6].i;
12367             z.int32[1] = n[7].i;
12368 
12369 
12370             CALL_Uniform3i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64));
12371             break;
12372          }
12373          case OPCODE_UNIFORM_4I64: {
12374             union int64_pair x;
12375             union int64_pair y;
12376             union int64_pair z;
12377             union int64_pair w;
12378 
12379             x.int32[0] = n[2].i;
12380             x.int32[1] = n[3].i;
12381             y.int32[0] = n[4].i;
12382             y.int32[1] = n[5].i;
12383             z.int32[0] = n[6].i;
12384             z.int32[1] = n[7].i;
12385             w.int32[0] = n[8].i;
12386             w.int32[1] = n[9].i;
12387 
12388             CALL_Uniform4i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64, w.int64));
12389             break;
12390          }
12391          case OPCODE_UNIFORM_1I64V:
12392             CALL_Uniform1i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12393             break;
12394          case OPCODE_UNIFORM_2I64V:
12395             CALL_Uniform2i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12396             break;
12397          case OPCODE_UNIFORM_3I64V:
12398             CALL_Uniform3i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12399             break;
12400          case OPCODE_UNIFORM_4I64V:
12401             CALL_Uniform4i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12402             break;
12403          case OPCODE_UNIFORM_1UI64: {
12404             union uint64_pair x;
12405 
12406             x.uint32[0] = n[2].ui;
12407             x.uint32[1] = n[3].ui;
12408 
12409             CALL_Uniform1ui64ARB(ctx->Exec, (n[1].i, x.uint64));
12410             break;
12411          }
12412          case OPCODE_UNIFORM_2UI64: {
12413             union uint64_pair x;
12414             union uint64_pair y;
12415 
12416             x.uint32[0] = n[2].ui;
12417             x.uint32[1] = n[3].ui;
12418             y.uint32[0] = n[4].ui;
12419             y.uint32[1] = n[5].ui;
12420 
12421             CALL_Uniform2ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64));
12422             break;
12423          }
12424          case OPCODE_UNIFORM_3UI64: {
12425             union uint64_pair x;
12426             union uint64_pair y;
12427             union uint64_pair z;
12428 
12429             x.uint32[0] = n[2].ui;
12430             x.uint32[1] = n[3].ui;
12431             y.uint32[0] = n[4].ui;
12432             y.uint32[1] = n[5].ui;
12433             z.uint32[0] = n[6].ui;
12434             z.uint32[1] = n[7].ui;
12435 
12436 
12437             CALL_Uniform3ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
12438                                  z.uint64));
12439             break;
12440          }
12441          case OPCODE_UNIFORM_4UI64: {
12442             union uint64_pair x;
12443             union uint64_pair y;
12444             union uint64_pair z;
12445             union uint64_pair w;
12446 
12447             x.uint32[0] = n[2].ui;
12448             x.uint32[1] = n[3].ui;
12449             y.uint32[0] = n[4].ui;
12450             y.uint32[1] = n[5].ui;
12451             z.uint32[0] = n[6].ui;
12452             z.uint32[1] = n[7].ui;
12453             w.uint32[0] = n[8].ui;
12454             w.uint32[1] = n[9].ui;
12455 
12456             CALL_Uniform4ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
12457                                  z.uint64, w.uint64));
12458             break;
12459          }
12460          case OPCODE_UNIFORM_1UI64V:
12461             CALL_Uniform1ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12462                                   get_pointer(&n[3])));
12463             break;
12464          case OPCODE_UNIFORM_2UI64V:
12465             CALL_Uniform2ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12466                                   get_pointer(&n[3])));
12467             break;
12468          case OPCODE_UNIFORM_3UI64V:
12469             CALL_Uniform3ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12470                                   get_pointer(&n[3])));
12471             break;
12472          case OPCODE_UNIFORM_4UI64V:
12473             CALL_Uniform4ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12474                                   get_pointer(&n[3])));
12475             break;
12476 
12477          case OPCODE_PROGRAM_UNIFORM_1I64: {
12478             union int64_pair x;
12479 
12480             x.int32[0] = n[3].i;
12481             x.int32[1] = n[4].i;
12482 
12483             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64));
12484             break;
12485          }
12486          case OPCODE_PROGRAM_UNIFORM_2I64: {
12487             union int64_pair x;
12488             union int64_pair y;
12489 
12490             x.int32[0] = n[3].i;
12491             x.int32[1] = n[4].i;
12492             y.int32[0] = n[5].i;
12493             y.int32[1] = n[6].i;
12494 
12495             CALL_ProgramUniform2i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12496                                        y.int64));
12497             break;
12498          }
12499          case OPCODE_PROGRAM_UNIFORM_3I64: {
12500             union int64_pair x;
12501             union int64_pair y;
12502             union int64_pair z;
12503 
12504             x.int32[0] = n[3].i;
12505             x.int32[1] = n[4].i;
12506             y.int32[0] = n[5].i;
12507             y.int32[1] = n[6].i;
12508             z.int32[0] = n[7].i;
12509             z.int32[1] = n[8].i;
12510 
12511             CALL_ProgramUniform3i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12512                                        y.int64, z.int64));
12513             break;
12514          }
12515          case OPCODE_PROGRAM_UNIFORM_4I64: {
12516             union int64_pair x;
12517             union int64_pair y;
12518             union int64_pair z;
12519             union int64_pair w;
12520 
12521             x.int32[0] = n[3].i;
12522             x.int32[1] = n[4].i;
12523             y.int32[0] = n[5].i;
12524             y.int32[1] = n[6].i;
12525             z.int32[0] = n[7].i;
12526             z.int32[1] = n[8].i;
12527             w.int32[0] = n[9].i;
12528             w.int32[1] = n[10].i;
12529 
12530             CALL_ProgramUniform4i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12531                                        y.int64, z.int64, w.int64));
12532             break;
12533          }
12534          case OPCODE_PROGRAM_UNIFORM_1I64V:
12535             CALL_ProgramUniform1i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12536                                         get_pointer(&n[4])));
12537             break;
12538          case OPCODE_PROGRAM_UNIFORM_2I64V:
12539             CALL_ProgramUniform2i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12540                                         get_pointer(&n[4])));
12541             break;
12542          case OPCODE_PROGRAM_UNIFORM_3I64V:
12543             CALL_ProgramUniform3i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12544                                         get_pointer(&n[4])));
12545             break;
12546          case OPCODE_PROGRAM_UNIFORM_4I64V:
12547             CALL_ProgramUniform4i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12548                                         get_pointer(&n[4])));
12549             break;
12550          case OPCODE_PROGRAM_UNIFORM_1UI64: {
12551             union uint64_pair x;
12552 
12553             x.uint32[0] = n[3].ui;
12554             x.uint32[1] = n[4].ui;
12555 
12556             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64));
12557             break;
12558          }
12559          case OPCODE_PROGRAM_UNIFORM_2UI64: {
12560             union uint64_pair x;
12561             union uint64_pair y;
12562 
12563             x.uint32[0] = n[3].ui;
12564             x.uint32[1] = n[4].ui;
12565             y.uint32[0] = n[5].ui;
12566             y.uint32[1] = n[6].ui;
12567 
12568             CALL_ProgramUniform2ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12569                                         y.uint64));
12570             break;
12571          }
12572          case OPCODE_PROGRAM_UNIFORM_3UI64: {
12573             union uint64_pair x;
12574             union uint64_pair y;
12575             union uint64_pair z;
12576 
12577             x.uint32[0] = n[3].ui;
12578             x.uint32[1] = n[4].ui;
12579             y.uint32[0] = n[5].ui;
12580             y.uint32[1] = n[6].ui;
12581             z.uint32[0] = n[7].ui;
12582             z.uint32[1] = n[8].ui;
12583 
12584             CALL_ProgramUniform3ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12585                                         y.uint64, z.uint64));
12586             break;
12587          }
12588          case OPCODE_PROGRAM_UNIFORM_4UI64: {
12589             union uint64_pair x;
12590             union uint64_pair y;
12591             union uint64_pair z;
12592             union uint64_pair w;
12593 
12594             x.uint32[0] = n[3].ui;
12595             x.uint32[1] = n[4].ui;
12596             y.uint32[0] = n[5].ui;
12597             y.uint32[1] = n[6].ui;
12598             z.uint32[0] = n[7].ui;
12599             z.uint32[1] = n[8].ui;
12600             w.uint32[0] = n[9].ui;
12601             w.uint32[1] = n[10].ui;
12602 
12603             CALL_ProgramUniform4ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12604                                         y.uint64, z.uint64, w.uint64));
12605             break;
12606          }
12607          case OPCODE_PROGRAM_UNIFORM_1UI64V:
12608             CALL_ProgramUniform1ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12609                                          get_pointer(&n[4])));
12610             break;
12611          case OPCODE_PROGRAM_UNIFORM_2UI64V:
12612             CALL_ProgramUniform2ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12613                                          get_pointer(&n[4])));
12614             break;
12615          case OPCODE_PROGRAM_UNIFORM_3UI64V:
12616             CALL_ProgramUniform3ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12617                                          get_pointer(&n[4])));
12618             break;
12619          case OPCODE_PROGRAM_UNIFORM_4UI64V:
12620             CALL_ProgramUniform4ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12621                                          get_pointer(&n[4])));
12622             break;
12623 
12624          case OPCODE_USE_PROGRAM_STAGES:
12625             CALL_UseProgramStages(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12626             break;
12627          case OPCODE_PROGRAM_UNIFORM_1F:
12628             CALL_ProgramUniform1f(ctx->Exec, (n[1].ui, n[2].i, n[3].f));
12629             break;
12630          case OPCODE_PROGRAM_UNIFORM_2F:
12631             CALL_ProgramUniform2f(ctx->Exec, (n[1].ui, n[2].i, n[3].f, n[4].f));
12632             break;
12633          case OPCODE_PROGRAM_UNIFORM_3F:
12634             CALL_ProgramUniform3f(ctx->Exec, (n[1].ui, n[2].i,
12635                                               n[3].f, n[4].f, n[5].f));
12636             break;
12637          case OPCODE_PROGRAM_UNIFORM_4F:
12638             CALL_ProgramUniform4f(ctx->Exec, (n[1].ui, n[2].i,
12639                                               n[3].f, n[4].f, n[5].f, n[6].f));
12640             break;
12641          case OPCODE_PROGRAM_UNIFORM_1FV:
12642             CALL_ProgramUniform1fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12643                                                get_pointer(&n[4])));
12644             break;
12645          case OPCODE_PROGRAM_UNIFORM_2FV:
12646             CALL_ProgramUniform2fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12647                                                get_pointer(&n[4])));
12648             break;
12649          case OPCODE_PROGRAM_UNIFORM_3FV:
12650             CALL_ProgramUniform3fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12651                                                get_pointer(&n[4])));
12652             break;
12653          case OPCODE_PROGRAM_UNIFORM_4FV:
12654             CALL_ProgramUniform4fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12655                                                get_pointer(&n[4])));
12656             break;
12657          case OPCODE_PROGRAM_UNIFORM_1D: {
12658             union float64_pair x;
12659 
12660             x.uint32[0] = n[3].ui;
12661             x.uint32[1] = n[4].ui;
12662 
12663             CALL_ProgramUniform1d(ctx->Exec, (n[1].ui, n[2].i, x.d));
12664             break;
12665          }
12666          case OPCODE_PROGRAM_UNIFORM_2D: {
12667             union float64_pair x;
12668             union float64_pair y;
12669 
12670             x.uint32[0] = n[3].ui;
12671             x.uint32[1] = n[4].ui;
12672             y.uint32[0] = n[5].ui;
12673             y.uint32[1] = n[6].ui;
12674 
12675             CALL_ProgramUniform2d(ctx->Exec, (n[1].ui, n[2].i, x.d, y.d));
12676             break;
12677          }
12678          case OPCODE_PROGRAM_UNIFORM_3D: {
12679             union float64_pair x;
12680             union float64_pair y;
12681             union float64_pair z;
12682 
12683             x.uint32[0] = n[3].ui;
12684             x.uint32[1] = n[4].ui;
12685             y.uint32[0] = n[5].ui;
12686             y.uint32[1] = n[6].ui;
12687             z.uint32[0] = n[7].ui;
12688             z.uint32[1] = n[8].ui;
12689 
12690             CALL_ProgramUniform3d(ctx->Exec, (n[1].ui, n[2].i,
12691                                               x.d, y.d, z.d));
12692             break;
12693          }
12694          case OPCODE_PROGRAM_UNIFORM_4D: {
12695             union float64_pair x;
12696             union float64_pair y;
12697             union float64_pair z;
12698             union float64_pair w;
12699 
12700             x.uint32[0] = n[3].ui;
12701             x.uint32[1] = n[4].ui;
12702             y.uint32[0] = n[5].ui;
12703             y.uint32[1] = n[6].ui;
12704             z.uint32[0] = n[7].ui;
12705             z.uint32[1] = n[8].ui;
12706             w.uint32[0] = n[9].ui;
12707             w.uint32[1] = n[10].ui;
12708 
12709             CALL_ProgramUniform4d(ctx->Exec, (n[1].ui, n[2].i,
12710                                               x.d, y.d, z.d, w.d));
12711             break;
12712          }
12713          case OPCODE_PROGRAM_UNIFORM_1DV:
12714             CALL_ProgramUniform1dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12715                                                get_pointer(&n[4])));
12716             break;
12717          case OPCODE_PROGRAM_UNIFORM_2DV:
12718             CALL_ProgramUniform2dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12719                                                get_pointer(&n[4])));
12720             break;
12721          case OPCODE_PROGRAM_UNIFORM_3DV:
12722             CALL_ProgramUniform3dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12723                                                get_pointer(&n[4])));
12724             break;
12725          case OPCODE_PROGRAM_UNIFORM_4DV:
12726             CALL_ProgramUniform4dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12727                                                get_pointer(&n[4])));
12728             break;
12729          case OPCODE_PROGRAM_UNIFORM_1I:
12730             CALL_ProgramUniform1i(ctx->Exec, (n[1].ui, n[2].i, n[3].i));
12731             break;
12732          case OPCODE_PROGRAM_UNIFORM_2I:
12733             CALL_ProgramUniform2i(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].i));
12734             break;
12735          case OPCODE_PROGRAM_UNIFORM_3I:
12736             CALL_ProgramUniform3i(ctx->Exec, (n[1].ui, n[2].i,
12737                                               n[3].i, n[4].i, n[5].i));
12738             break;
12739          case OPCODE_PROGRAM_UNIFORM_4I:
12740             CALL_ProgramUniform4i(ctx->Exec, (n[1].ui, n[2].i,
12741                                               n[3].i, n[4].i, n[5].i, n[6].i));
12742             break;
12743          case OPCODE_PROGRAM_UNIFORM_1IV:
12744             CALL_ProgramUniform1iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12745                                                get_pointer(&n[4])));
12746             break;
12747          case OPCODE_PROGRAM_UNIFORM_2IV:
12748             CALL_ProgramUniform2iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12749                                                get_pointer(&n[4])));
12750             break;
12751          case OPCODE_PROGRAM_UNIFORM_3IV:
12752             CALL_ProgramUniform3iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12753                                                get_pointer(&n[4])));
12754             break;
12755          case OPCODE_PROGRAM_UNIFORM_4IV:
12756             CALL_ProgramUniform4iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12757                                                get_pointer(&n[4])));
12758             break;
12759          case OPCODE_PROGRAM_UNIFORM_1UI:
12760             CALL_ProgramUniform1ui(ctx->Exec, (n[1].ui, n[2].i, n[3].ui));
12761             break;
12762          case OPCODE_PROGRAM_UNIFORM_2UI:
12763             CALL_ProgramUniform2ui(ctx->Exec, (n[1].ui, n[2].i,
12764                                                n[3].ui, n[4].ui));
12765             break;
12766          case OPCODE_PROGRAM_UNIFORM_3UI:
12767             CALL_ProgramUniform3ui(ctx->Exec, (n[1].ui, n[2].i,
12768                                                n[3].ui, n[4].ui, n[5].ui));
12769             break;
12770          case OPCODE_PROGRAM_UNIFORM_4UI:
12771             CALL_ProgramUniform4ui(ctx->Exec, (n[1].ui, n[2].i,
12772                                                n[3].ui,
12773                                                n[4].ui, n[5].ui, n[6].ui));
12774             break;
12775          case OPCODE_PROGRAM_UNIFORM_1UIV:
12776             CALL_ProgramUniform1uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12777                                                 get_pointer(&n[4])));
12778             break;
12779          case OPCODE_PROGRAM_UNIFORM_2UIV:
12780             CALL_ProgramUniform2uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12781                                                 get_pointer(&n[4])));
12782             break;
12783          case OPCODE_PROGRAM_UNIFORM_3UIV:
12784             CALL_ProgramUniform3uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12785                                                 get_pointer(&n[4])));
12786             break;
12787          case OPCODE_PROGRAM_UNIFORM_4UIV:
12788             CALL_ProgramUniform4uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12789                                                 get_pointer(&n[4])));
12790             break;
12791          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
12792             CALL_ProgramUniformMatrix2fv(ctx->Exec,
12793                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12794                                           get_pointer(&n[5])));
12795             break;
12796          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
12797             CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
12798                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12799                                             get_pointer(&n[5])));
12800             break;
12801          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
12802             CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
12803                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12804                                             get_pointer(&n[5])));
12805             break;
12806          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
12807             CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
12808                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12809                                             get_pointer(&n[5])));
12810             break;
12811          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
12812             CALL_ProgramUniformMatrix3fv(ctx->Exec,
12813                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12814                                           get_pointer(&n[5])));
12815             break;
12816          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
12817             CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
12818                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12819                                             get_pointer(&n[5])));
12820             break;
12821          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
12822             CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
12823                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12824                                             get_pointer(&n[5])));
12825             break;
12826          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
12827             CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
12828                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12829                                             get_pointer(&n[5])));
12830             break;
12831          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
12832             CALL_ProgramUniformMatrix4fv(ctx->Exec,
12833                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12834                                           get_pointer(&n[5])));
12835             break;
12836          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
12837             CALL_ProgramUniformMatrix2dv(ctx->Exec,
12838                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12839                                           get_pointer(&n[5])));
12840             break;
12841          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
12842             CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
12843                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12844                                             get_pointer(&n[5])));
12845             break;
12846          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
12847             CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
12848                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12849                                             get_pointer(&n[5])));
12850             break;
12851          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
12852             CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
12853                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12854                                             get_pointer(&n[5])));
12855             break;
12856          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
12857             CALL_ProgramUniformMatrix3dv(ctx->Exec,
12858                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12859                                           get_pointer(&n[5])));
12860             break;
12861          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
12862             CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
12863                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12864                                             get_pointer(&n[5])));
12865             break;
12866          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
12867             CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
12868                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12869                                             get_pointer(&n[5])));
12870             break;
12871          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
12872             CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
12873                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12874                                             get_pointer(&n[5])));
12875             break;
12876          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
12877             CALL_ProgramUniformMatrix4dv(ctx->Exec,
12878                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12879                                           get_pointer(&n[5])));
12880             break;
12881 
12882          case OPCODE_CLIP_CONTROL:
12883             CALL_ClipControl(ctx->Exec, (n[1].e, n[2].e));
12884             break;
12885 
12886          case OPCODE_CLAMP_COLOR:
12887             CALL_ClampColor(ctx->Exec, (n[1].e, n[2].e));
12888             break;
12889 
12890          case OPCODE_BIND_FRAGMENT_SHADER_ATI:
12891             CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
12892             break;
12893          case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
12894             CALL_SetFragmentShaderConstantATI(ctx->Exec, (n[1].ui, &n[2].f));
12895             break;
12896          case OPCODE_ATTR_1F_NV:
12897             CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
12898             break;
12899          case OPCODE_ATTR_2F_NV:
12900             CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
12901             break;
12902          case OPCODE_ATTR_3F_NV:
12903             CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
12904             break;
12905          case OPCODE_ATTR_4F_NV:
12906             CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
12907             break;
12908          case OPCODE_ATTR_1F_ARB:
12909             CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
12910             break;
12911          case OPCODE_ATTR_2F_ARB:
12912             CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
12913             break;
12914          case OPCODE_ATTR_3F_ARB:
12915             CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
12916             break;
12917          case OPCODE_ATTR_4F_ARB:
12918             CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
12919             break;
12920          case OPCODE_ATTR_1I:
12921             CALL_VertexAttribI1iEXT(ctx->Exec, (n[1].e, n[2].i));
12922             break;
12923          case OPCODE_ATTR_2I:
12924             CALL_VertexAttribI2ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12925             break;
12926          case OPCODE_ATTR_3I:
12927             CALL_VertexAttribI3ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12928             break;
12929          case OPCODE_ATTR_4I:
12930             CALL_VertexAttribI4ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12931             break;
12932          case OPCODE_ATTR_1D: {
12933             GLdouble *d = (GLdouble *) &n[2];
12934             CALL_VertexAttribL1d(ctx->Exec, (n[1].ui, *d));
12935             break;
12936          }
12937          case OPCODE_ATTR_2D: {
12938             GLdouble *d = (GLdouble *) &n[2];
12939             CALL_VertexAttribL2dv(ctx->Exec, (n[1].ui, d));
12940             break;
12941          }
12942          case OPCODE_ATTR_3D: {
12943             GLdouble *d = (GLdouble *) &n[2];
12944             CALL_VertexAttribL3dv(ctx->Exec, (n[1].ui, d));
12945             break;
12946          }
12947          case OPCODE_ATTR_4D: {
12948             GLdouble *d = (GLdouble *) &n[2];
12949             CALL_VertexAttribL4dv(ctx->Exec, (n[1].ui, d));
12950             break;
12951          }
12952          case OPCODE_ATTR_1UI64: {
12953             uint64_t *ui64 = (uint64_t *) &n[2];
12954             CALL_VertexAttribL1ui64ARB(ctx->Exec, (n[1].ui, *ui64));
12955             break;
12956          }
12957          case OPCODE_MATERIAL:
12958             CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
12959             break;
12960          case OPCODE_BEGIN:
12961             CALL_Begin(ctx->Exec, (n[1].e));
12962             break;
12963          case OPCODE_END:
12964             CALL_End(ctx->Exec, ());
12965             break;
12966          case OPCODE_RECTF:
12967             CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
12968             break;
12969          case OPCODE_EVAL_C1:
12970             CALL_EvalCoord1f(ctx->Exec, (n[1].f));
12971             break;
12972          case OPCODE_EVAL_C2:
12973             CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
12974             break;
12975          case OPCODE_EVAL_P1:
12976             CALL_EvalPoint1(ctx->Exec, (n[1].i));
12977             break;
12978          case OPCODE_EVAL_P2:
12979             CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
12980             break;
12981 
12982          /* GL_EXT_texture_integer */
12983          case OPCODE_CLEARCOLOR_I:
12984             CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12985             break;
12986          case OPCODE_CLEARCOLOR_UI:
12987             CALL_ClearColorIuiEXT(ctx->Exec,
12988                                   (n[1].ui, n[2].ui, n[3].ui, n[4].ui));
12989             break;
12990          case OPCODE_TEXPARAMETER_I:
12991             {
12992                GLint params[4];
12993                params[0] = n[3].i;
12994                params[1] = n[4].i;
12995                params[2] = n[5].i;
12996                params[3] = n[6].i;
12997                CALL_TexParameterIiv(ctx->Exec, (n[1].e, n[2].e, params));
12998             }
12999             break;
13000          case OPCODE_TEXPARAMETER_UI:
13001             {
13002                GLuint params[4];
13003                params[0] = n[3].ui;
13004                params[1] = n[4].ui;
13005                params[2] = n[5].ui;
13006                params[3] = n[6].ui;
13007                CALL_TexParameterIuiv(ctx->Exec, (n[1].e, n[2].e, params));
13008             }
13009             break;
13010 
13011          case OPCODE_VERTEX_ATTRIB_DIVISOR:
13012             /* GL_ARB_instanced_arrays */
13013             CALL_VertexAttribDivisor(ctx->Exec, (n[1].ui, n[2].ui));
13014             break;
13015 
13016          case OPCODE_TEXTURE_BARRIER_NV:
13017             CALL_TextureBarrierNV(ctx->Exec, ());
13018             break;
13019 
13020          /* GL_EXT/ARB_transform_feedback */
13021          case OPCODE_BEGIN_TRANSFORM_FEEDBACK:
13022             CALL_BeginTransformFeedback(ctx->Exec, (n[1].e));
13023             break;
13024          case OPCODE_END_TRANSFORM_FEEDBACK:
13025             CALL_EndTransformFeedback(ctx->Exec, ());
13026             break;
13027          case OPCODE_BIND_TRANSFORM_FEEDBACK:
13028             CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
13029             break;
13030          case OPCODE_PAUSE_TRANSFORM_FEEDBACK:
13031             CALL_PauseTransformFeedback(ctx->Exec, ());
13032             break;
13033          case OPCODE_RESUME_TRANSFORM_FEEDBACK:
13034             CALL_ResumeTransformFeedback(ctx->Exec, ());
13035             break;
13036          case OPCODE_DRAW_TRANSFORM_FEEDBACK:
13037             CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
13038             break;
13039          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM:
13040             CALL_DrawTransformFeedbackStream(ctx->Exec,
13041                                              (n[1].e, n[2].ui, n[3].ui));
13042             break;
13043          case OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED:
13044             CALL_DrawTransformFeedbackInstanced(ctx->Exec,
13045                                                 (n[1].e, n[2].ui, n[3].si));
13046             break;
13047          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED:
13048             CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec,
13049                                        (n[1].e, n[2].ui, n[3].ui, n[4].si));
13050             break;
13051 
13052 
13053          case OPCODE_BIND_SAMPLER:
13054             CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui));
13055             break;
13056          case OPCODE_SAMPLER_PARAMETERIV:
13057             {
13058                GLint params[4];
13059                params[0] = n[3].i;
13060                params[1] = n[4].i;
13061                params[2] = n[5].i;
13062                params[3] = n[6].i;
13063                CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params));
13064             }
13065             break;
13066          case OPCODE_SAMPLER_PARAMETERFV:
13067             {
13068                GLfloat params[4];
13069                params[0] = n[3].f;
13070                params[1] = n[4].f;
13071                params[2] = n[5].f;
13072                params[3] = n[6].f;
13073                CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params));
13074             }
13075             break;
13076          case OPCODE_SAMPLER_PARAMETERIIV:
13077             {
13078                GLint params[4];
13079                params[0] = n[3].i;
13080                params[1] = n[4].i;
13081                params[2] = n[5].i;
13082                params[3] = n[6].i;
13083                CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params));
13084             }
13085             break;
13086          case OPCODE_SAMPLER_PARAMETERUIV:
13087             {
13088                GLuint params[4];
13089                params[0] = n[3].ui;
13090                params[1] = n[4].ui;
13091                params[2] = n[5].ui;
13092                params[3] = n[6].ui;
13093                CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params));
13094             }
13095             break;
13096 
13097          /* ARB_compute_shader */
13098          case OPCODE_DISPATCH_COMPUTE:
13099             CALL_DispatchCompute(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
13100             break;
13101 
13102          /* GL_ARB_sync */
13103          case OPCODE_WAIT_SYNC:
13104             {
13105                union uint64_pair p;
13106                p.uint32[0] = n[2].ui;
13107                p.uint32[1] = n[3].ui;
13108                CALL_WaitSync(ctx->Exec,
13109                              (get_pointer(&n[4]), n[1].bf, p.uint64));
13110             }
13111             break;
13112 
13113          /* GL_NV_conditional_render */
13114          case OPCODE_BEGIN_CONDITIONAL_RENDER:
13115             CALL_BeginConditionalRender(ctx->Exec, (n[1].i, n[2].e));
13116             break;
13117          case OPCODE_END_CONDITIONAL_RENDER:
13118             CALL_EndConditionalRender(ctx->Exec, ());
13119             break;
13120 
13121          case OPCODE_UNIFORM_BLOCK_BINDING:
13122             CALL_UniformBlockBinding(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
13123             break;
13124 
13125          case OPCODE_UNIFORM_SUBROUTINES:
13126             CALL_UniformSubroutinesuiv(ctx->Exec, (n[1].e, n[2].si,
13127                                                    get_pointer(&n[3])));
13128             break;
13129 
13130          /* GL_EXT_window_rectangles */
13131          case OPCODE_WINDOW_RECTANGLES:
13132             CALL_WindowRectanglesEXT(
13133                   ctx->Exec, (n[1].e, n[2].si, get_pointer(&n[3])));
13134             break;
13135 
13136          /* GL_NV_conservative_raster */
13137          case OPCODE_SUBPIXEL_PRECISION_BIAS:
13138             CALL_SubpixelPrecisionBiasNV(ctx->Exec, (n[1].ui, n[2].ui));
13139             break;
13140 
13141          /* GL_NV_conservative_raster_dilate */
13142          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_F:
13143             CALL_ConservativeRasterParameterfNV(ctx->Exec, (n[1].e, n[2].f));
13144             break;
13145 
13146          /* GL_NV_conservative_raster_pre_snap_triangles */
13147          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_I:
13148             CALL_ConservativeRasterParameteriNV(ctx->Exec, (n[1].e, n[2].i));
13149             break;
13150 
13151          /* GL_EXT_direct_state_access */
13152          case OPCODE_MATRIX_LOAD:
13153             CALL_MatrixLoadfEXT(ctx->Exec, (n[1].e, &n[2].f));
13154             break;
13155          case OPCODE_MATRIX_MULT:
13156             CALL_MatrixMultfEXT(ctx->Exec, (n[1].e, &n[2].f));
13157             break;
13158          case OPCODE_MATRIX_ROTATE:
13159             CALL_MatrixRotatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f, n[5].f));
13160             break;
13161          case OPCODE_MATRIX_SCALE:
13162             CALL_MatrixScalefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
13163             break;
13164          case OPCODE_MATRIX_TRANSLATE:
13165             CALL_MatrixTranslatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
13166             break;
13167          case OPCODE_MATRIX_LOAD_IDENTITY:
13168             CALL_MatrixLoadIdentityEXT(ctx->Exec, (n[1].e));
13169             break;
13170          case OPCODE_MATRIX_ORTHO:
13171             CALL_MatrixOrthoEXT(ctx->Exec, (n[1].e,
13172                                             n[2].f, n[3].f, n[4].f,
13173                                             n[5].f, n[6].f, n[7].f));
13174             break;
13175          case OPCODE_MATRIX_FRUSTUM:
13176             CALL_MatrixFrustumEXT(ctx->Exec, (n[1].e,
13177                                               n[2].f, n[3].f, n[4].f,
13178                                               n[5].f, n[6].f, n[7].f));
13179             break;
13180          case OPCODE_MATRIX_PUSH:
13181             CALL_MatrixPushEXT(ctx->Exec, (n[1].e));
13182             break;
13183          case OPCODE_MATRIX_POP:
13184             CALL_MatrixPopEXT(ctx->Exec, (n[1].e));
13185             break;
13186          case OPCODE_TEXTUREPARAMETER_F:
13187             {
13188                GLfloat params[4];
13189                params[0] = n[4].f;
13190                params[1] = n[5].f;
13191                params[2] = n[6].f;
13192                params[3] = n[7].f;
13193                CALL_TextureParameterfvEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13194             }
13195             break;
13196          case OPCODE_TEXTUREPARAMETER_I:
13197             {
13198                GLint params[4];
13199                params[0] = n[4].i;
13200                params[1] = n[5].i;
13201                params[2] = n[6].i;
13202                params[3] = n[7].i;
13203                CALL_TextureParameterivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13204             }
13205             break;
13206          case OPCODE_TEXTUREPARAMETER_II:
13207             {
13208                GLint params[4];
13209                params[0] = n[4].i;
13210                params[1] = n[5].i;
13211                params[2] = n[6].i;
13212                params[3] = n[7].i;
13213                CALL_TextureParameterIivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13214             }
13215             break;
13216          case OPCODE_TEXTUREPARAMETER_IUI:
13217             {
13218                GLuint params[4];
13219                params[0] = n[4].ui;
13220                params[1] = n[5].ui;
13221                params[2] = n[6].ui;
13222                params[3] = n[7].ui;
13223                CALL_TextureParameterIuivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13224             }
13225             break;
13226          case OPCODE_TEXTURE_IMAGE1D:
13227             {
13228                const struct gl_pixelstore_attrib save = ctx->Unpack;
13229                ctx->Unpack = ctx->DefaultPacking;
13230                CALL_TextureImage1DEXT(ctx->Exec, (n[1].ui, /* texture */
13231                                                   n[2].e,  /* target */
13232                                                   n[3].i,  /* level */
13233                                                   n[4].i,  /* components */
13234                                                   n[5].i,  /* width */
13235                                                   n[6].e,  /* border */
13236                                                   n[7].e,  /* format */
13237                                                   n[8].e,  /* type */
13238                                                   get_pointer(&n[9])));
13239                ctx->Unpack = save;      /* restore */
13240             }
13241             break;
13242          case OPCODE_TEXTURE_IMAGE2D:
13243             {
13244                const struct gl_pixelstore_attrib save = ctx->Unpack;
13245                ctx->Unpack = ctx->DefaultPacking;
13246                CALL_TextureImage2DEXT(ctx->Exec, (n[1].ui, /* texture */
13247                                                   n[2].e,  /* target */
13248                                                   n[3].i,  /* level */
13249                                                   n[4].i,  /* components */
13250                                                   n[5].i,  /* width */
13251                                                   n[6].i,  /* height */
13252                                                   n[7].e,  /* border */
13253                                                   n[8].e,  /* format */
13254                                                   n[9].e,  /* type */
13255                                                   get_pointer(&n[10])));
13256                ctx->Unpack = save;      /* restore */
13257             }
13258             break;
13259          case OPCODE_TEXTURE_IMAGE3D:
13260             {
13261                const struct gl_pixelstore_attrib save = ctx->Unpack;
13262                ctx->Unpack = ctx->DefaultPacking;
13263                CALL_TextureImage3DEXT(ctx->Exec, (n[1].ui, /* texture */
13264                                                   n[2].e,  /* target */
13265                                                   n[3].i,  /* level */
13266                                                   n[4].i,  /* components */
13267                                                   n[5].i,  /* width */
13268                                                   n[6].i,  /* height */
13269                                                   n[7].i,  /* depth  */
13270                                                   n[8].e,  /* border */
13271                                                   n[9].e,  /* format */
13272                                                   n[10].e, /* type */
13273                                                   get_pointer(&n[11])));
13274                ctx->Unpack = save;      /* restore */
13275             }
13276             break;
13277          case OPCODE_TEXTURE_SUB_IMAGE1D:
13278             {
13279                const struct gl_pixelstore_attrib save = ctx->Unpack;
13280                ctx->Unpack = ctx->DefaultPacking;
13281                CALL_TextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13282                                                      n[4].i, n[5].i, n[6].e,
13283                                                      n[7].e, get_pointer(&n[8])));
13284                ctx->Unpack = save;      /* restore */
13285             }
13286             break;
13287          case OPCODE_TEXTURE_SUB_IMAGE2D:
13288             {
13289                const struct gl_pixelstore_attrib save = ctx->Unpack;
13290                ctx->Unpack = ctx->DefaultPacking;
13291                CALL_TextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13292                                                      n[4].i, n[5].i, n[6].e,
13293                                                      n[7].i, n[8].e, n[9].e,
13294                                                      get_pointer(&n[10])));
13295                ctx->Unpack = save;
13296             }
13297             break;
13298          case OPCODE_TEXTURE_SUB_IMAGE3D:
13299             {
13300                const struct gl_pixelstore_attrib save = ctx->Unpack;
13301                ctx->Unpack = ctx->DefaultPacking;
13302                CALL_TextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13303                                                      n[4].i, n[5].i, n[6].i,
13304                                                      n[7].i, n[8].i, n[9].i,
13305                                                      n[10].e, n[11].e,
13306                                                      get_pointer(&n[12])));
13307                ctx->Unpack = save;      /* restore */
13308             }
13309             break;
13310          case OPCODE_COPY_TEXTURE_IMAGE1D:
13311             CALL_CopyTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13312                                                    n[4].e, n[5].i, n[6].i,
13313                                                    n[7].i, n[8].i));
13314             break;
13315          case OPCODE_COPY_TEXTURE_IMAGE2D:
13316             CALL_CopyTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13317                                                    n[4].e, n[5].i, n[6].i,
13318                                                    n[7].i, n[8].i, n[9].i));
13319             break;
13320          case OPCODE_COPY_TEXTURE_SUB_IMAGE1D:
13321             CALL_CopyTextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13322                                                       n[4].i, n[5].i, n[6].i,
13323                                                       n[7].i));
13324             break;
13325          case OPCODE_COPY_TEXTURE_SUB_IMAGE2D:
13326             CALL_CopyTextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13327                                                       n[4].i, n[5].i, n[6].i,
13328                                                       n[7].i, n[8].i, n[9].i));
13329             break;
13330          case OPCODE_COPY_TEXTURE_SUB_IMAGE3D:
13331             CALL_CopyTextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13332                                                       n[4].i, n[5].i, n[6].i,
13333                                                       n[7].i, n[8].i, n[9].i,
13334                                                       n[10].i));
13335             break;
13336          case OPCODE_BIND_MULTITEXTURE:
13337             CALL_BindMultiTextureEXT(ctx->Exec, (n[1].e, n[2].e, n[3].ui));
13338             break;
13339          case OPCODE_MULTITEXPARAMETER_F:
13340             {
13341                GLfloat params[4];
13342                params[0] = n[4].f;
13343                params[1] = n[5].f;
13344                params[2] = n[6].f;
13345                params[3] = n[7].f;
13346                CALL_MultiTexParameterfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13347             }
13348             break;
13349          case OPCODE_MULTITEXPARAMETER_I:
13350             {
13351                GLint params[4];
13352                params[0] = n[4].i;
13353                params[1] = n[5].i;
13354                params[2] = n[6].i;
13355                params[3] = n[7].i;
13356                CALL_MultiTexParameterivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13357             }
13358             break;
13359          case OPCODE_MULTITEXPARAMETER_II:
13360             {
13361                GLint params[4];
13362                params[0] = n[4].i;
13363                params[1] = n[5].i;
13364                params[2] = n[6].i;
13365                params[3] = n[7].i;
13366                CALL_MultiTexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13367             }
13368             break;
13369          case OPCODE_MULTITEXPARAMETER_IUI:
13370             {
13371                GLuint params[4];
13372                params[0] = n[4].ui;
13373                params[1] = n[5].ui;
13374                params[2] = n[6].ui;
13375                params[3] = n[7].ui;
13376                CALL_MultiTexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13377             }
13378             break;
13379          case OPCODE_MULTITEX_IMAGE1D:
13380             {
13381                const struct gl_pixelstore_attrib save = ctx->Unpack;
13382                ctx->Unpack = ctx->DefaultPacking;
13383                CALL_MultiTexImage1DEXT(ctx->Exec, (n[1].e, /* texture */
13384                                                   n[2].e,  /* target */
13385                                                   n[3].i,  /* level */
13386                                                   n[4].i,  /* components */
13387                                                   n[5].i,  /* width */
13388                                                   n[6].e,  /* border */
13389                                                   n[7].e,  /* format */
13390                                                   n[8].e,  /* type */
13391                                                   get_pointer(&n[9])));
13392                ctx->Unpack = save;      /* restore */
13393             }
13394             break;
13395          case OPCODE_MULTITEX_IMAGE2D:
13396             {
13397                const struct gl_pixelstore_attrib save = ctx->Unpack;
13398                ctx->Unpack = ctx->DefaultPacking;
13399                CALL_MultiTexImage2DEXT(ctx->Exec, (n[1].e, /* texture */
13400                                                   n[2].e,  /* target */
13401                                                   n[3].i,  /* level */
13402                                                   n[4].i,  /* components */
13403                                                   n[5].i,  /* width */
13404                                                   n[6].i,  /* height */
13405                                                   n[7].e,  /* border */
13406                                                   n[8].e,  /* format */
13407                                                   n[9].e,  /* type */
13408                                                   get_pointer(&n[10])));
13409                ctx->Unpack = save;      /* restore */
13410             }
13411             break;
13412          case OPCODE_MULTITEX_IMAGE3D:
13413             {
13414                const struct gl_pixelstore_attrib save = ctx->Unpack;
13415                ctx->Unpack = ctx->DefaultPacking;
13416                CALL_MultiTexImage3DEXT(ctx->Exec, (n[1].e, /* texture */
13417                                                   n[2].e,  /* target */
13418                                                   n[3].i,  /* level */
13419                                                   n[4].i,  /* components */
13420                                                   n[5].i,  /* width */
13421                                                   n[6].i,  /* height */
13422                                                   n[7].i,  /* depth  */
13423                                                   n[8].e,  /* border */
13424                                                   n[9].e,  /* format */
13425                                                   n[10].e, /* type */
13426                                                   get_pointer(&n[11])));
13427                ctx->Unpack = save;      /* restore */
13428             }
13429             break;
13430          case OPCODE_MULTITEX_SUB_IMAGE1D:
13431             {
13432                const struct gl_pixelstore_attrib save = ctx->Unpack;
13433                ctx->Unpack = ctx->DefaultPacking;
13434                CALL_MultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13435                                                      n[4].i, n[5].i, n[6].e,
13436                                                      n[7].e, get_pointer(&n[8])));
13437                ctx->Unpack = save;      /* restore */
13438             }
13439             break;
13440          case OPCODE_MULTITEX_SUB_IMAGE2D:
13441             {
13442                const struct gl_pixelstore_attrib save = ctx->Unpack;
13443                ctx->Unpack = ctx->DefaultPacking;
13444                CALL_MultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13445                                                      n[4].i, n[5].i, n[6].e,
13446                                                      n[7].i, n[8].e, n[9].e,
13447                                                      get_pointer(&n[10])));
13448                ctx->Unpack = save;      /* restore */
13449             }
13450             break;
13451          case OPCODE_MULTITEX_SUB_IMAGE3D:
13452             {
13453                const struct gl_pixelstore_attrib save = ctx->Unpack;
13454                ctx->Unpack = ctx->DefaultPacking;
13455                CALL_MultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13456                                                      n[4].i, n[5].i, n[6].i,
13457                                                      n[7].i, n[8].i, n[9].i,
13458                                                      n[10].e, n[11].e,
13459                                                      get_pointer(&n[12])));
13460                ctx->Unpack = save;      /* restore */
13461             }
13462             break;
13463          case OPCODE_COPY_MULTITEX_IMAGE1D:
13464             CALL_CopyMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13465                                                    n[4].e, n[5].i, n[6].i,
13466                                                    n[7].i, n[8].i));
13467             break;
13468          case OPCODE_COPY_MULTITEX_IMAGE2D:
13469             CALL_CopyMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13470                                                    n[4].e, n[5].i, n[6].i,
13471                                                    n[7].i, n[8].i, n[9].i));
13472             break;
13473          case OPCODE_COPY_MULTITEX_SUB_IMAGE1D:
13474             CALL_CopyMultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13475                                                       n[4].i, n[5].i, n[6].i,
13476                                                       n[7].i));
13477             break;
13478          case OPCODE_COPY_MULTITEX_SUB_IMAGE2D:
13479             CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13480                                                       n[4].i, n[5].i, n[6].i,
13481                                                       n[7].i, n[8].i, n[9].i));
13482             break;
13483          case OPCODE_COPY_MULTITEX_SUB_IMAGE3D:
13484             CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13485                                                       n[4].i, n[5].i, n[6].i,
13486                                                       n[7].i, n[8].i, n[9].i,
13487                                                       n[10].i));
13488             break;
13489          case OPCODE_MULTITEXENV:
13490             {
13491                GLfloat params[4];
13492                params[0] = n[4].f;
13493                params[1] = n[5].f;
13494                params[2] = n[6].f;
13495                params[3] = n[7].f;
13496                CALL_MultiTexEnvfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13497             }
13498             break;
13499          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
13500             CALL_CompressedTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13501                                                          n[4].e, n[5].i, n[6].i,
13502                                                          n[7].i, get_pointer(&n[8])));
13503             break;
13504          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
13505             CALL_CompressedTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13506                                                          n[4].e, n[5].i, n[6].i,
13507                                                          n[7].i, n[8].i,
13508                                                          get_pointer(&n[9])));
13509             break;
13510          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
13511             CALL_CompressedTextureImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13512                                                          n[4].e, n[5].i, n[6].i,
13513                                                          n[7].i, n[8].i, n[9].i,
13514                                                          get_pointer(&n[10])));
13515             break;
13516          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
13517             CALL_CompressedTextureSubImage1DEXT(ctx->Exec,
13518                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13519                                                  n[5].i, n[6].e, n[7].i,
13520                                                  get_pointer(&n[8])));
13521             break;
13522          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
13523             CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
13524                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13525                                                  n[5].i, n[6].i, n[7].i, n[8].e,
13526                                                  n[9].i, get_pointer(&n[10])));
13527             break;
13528          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
13529             CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
13530                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13531                                                  n[5].i, n[6].i, n[7].i, n[8].i,
13532                                                  n[9].i, n[10].e, n[11].i,
13533                                                  get_pointer(&n[12])));
13534             break;
13535          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
13536             CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13537                                                          n[4].e, n[5].i, n[6].i,
13538                                                          n[7].i, get_pointer(&n[8])));
13539             break;
13540          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
13541             CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13542                                                          n[4].e, n[5].i, n[6].i,
13543                                                          n[7].i, n[8].i,
13544                                                          get_pointer(&n[9])));
13545             break;
13546          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
13547             CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13548                                                          n[4].e, n[5].i, n[6].i,
13549                                                          n[7].i, n[8].i, n[9].i,
13550                                                          get_pointer(&n[10])));
13551             break;
13552          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
13553             CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec,
13554                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13555                                                  n[5].i, n[6].e, n[7].i,
13556                                                  get_pointer(&n[8])));
13557             break;
13558          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
13559             CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
13560                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13561                                                  n[5].i, n[6].i, n[7].i, n[8].e,
13562                                                  n[9].i, get_pointer(&n[10])));
13563             break;
13564          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
13565             CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
13566                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13567                                                  n[5].i, n[6].i, n[7].i, n[8].i,
13568                                                  n[9].i, n[10].e, n[11].i,
13569                                                  get_pointer(&n[12])));
13570             break;
13571          case OPCODE_NAMED_PROGRAM_STRING:
13572             CALL_NamedProgramStringEXT(ctx->Exec,
13573                                   (n[1].ui, n[2].e, n[3].e, n[4].i,
13574                                    get_pointer(&n[5])));
13575             break;
13576          case OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER:
13577             CALL_NamedProgramLocalParameter4fEXT(ctx->Exec,
13578                                             (n[1].ui, n[2].e, n[3].ui, n[4].f,
13579                                              n[5].f, n[6].f, n[7].f));
13580             break;
13581 
13582          case OPCODE_CONTINUE:
13583             n = (Node *) get_pointer(&n[1]);
13584             break;
13585          case OPCODE_NOP:
13586             /* no-op */
13587             break;
13588          case OPCODE_END_OF_LIST:
13589             done = GL_TRUE;
13590             break;
13591          default:
13592             {
13593                char msg[1000];
13594                snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d",
13595                              (int) opcode);
13596                _mesa_problem(ctx, "%s", msg);
13597             }
13598             done = GL_TRUE;
13599          }
13600 
13601          /* increment n to point to next compiled command */
13602          if (opcode != OPCODE_CONTINUE) {
13603             assert(InstSize[opcode] > 0);
13604             n += InstSize[opcode];
13605          }
13606       }
13607    }
13608 
13609    vbo_save_EndCallList(ctx);
13610 
13611    ctx->ListState.CallDepth--;
13612 }
13613 
13614 
13615 
13616 /**********************************************************************/
13617 /*                           GL functions                             */
13618 /**********************************************************************/
13619 
13620 /**
13621  * Test if a display list number is valid.
13622  */
13623 GLboolean GLAPIENTRY
_mesa_IsList(GLuint list)13624 _mesa_IsList(GLuint list)
13625 {
13626    GET_CURRENT_CONTEXT(ctx);
13627    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
13628    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
13629    return islist(ctx, list);
13630 }
13631 
13632 
13633 /**
13634  * Delete a sequence of consecutive display lists.
13635  */
13636 void GLAPIENTRY
_mesa_DeleteLists(GLuint list,GLsizei range)13637 _mesa_DeleteLists(GLuint list, GLsizei range)
13638 {
13639    GET_CURRENT_CONTEXT(ctx);
13640    GLuint i;
13641    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
13642    ASSERT_OUTSIDE_BEGIN_END(ctx);
13643 
13644    if (range < 0) {
13645       _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
13646       return;
13647    }
13648 
13649    if (range > 1) {
13650       /* We may be deleting a set of bitmap lists.  See if there's a
13651        * bitmap atlas to free.
13652        */
13653       struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, list);
13654       if (atlas) {
13655          _mesa_delete_bitmap_atlas(ctx, atlas);
13656          _mesa_HashRemove(ctx->Shared->BitmapAtlas, list);
13657       }
13658    }
13659 
13660    for (i = list; i < list + range; i++) {
13661       destroy_list(ctx, i);
13662    }
13663 }
13664 
13665 
13666 /**
13667  * Return a display list number, n, such that lists n through n+range-1
13668  * are free.
13669  */
13670 GLuint GLAPIENTRY
_mesa_GenLists(GLsizei range)13671 _mesa_GenLists(GLsizei range)
13672 {
13673    GET_CURRENT_CONTEXT(ctx);
13674    GLuint base;
13675    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
13676    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
13677 
13678    if (range < 0) {
13679       _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
13680       return 0;
13681    }
13682    if (range == 0) {
13683       return 0;
13684    }
13685 
13686    /*
13687     * Make this an atomic operation
13688     */
13689    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13690 
13691    base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
13692    if (base) {
13693       /* reserve the list IDs by with empty/dummy lists */
13694       GLint i;
13695       for (i = 0; i < range; i++) {
13696          _mesa_HashInsertLocked(ctx->Shared->DisplayList, base + i,
13697                                 make_list(base + i, 1), true);
13698       }
13699    }
13700 
13701    if (USE_BITMAP_ATLAS &&
13702        range > 16 &&
13703        ctx->Driver.DrawAtlasBitmaps) {
13704       /* "range > 16" is a rough heuristic to guess when glGenLists might be
13705        * used to allocate display lists for glXUseXFont or wglUseFontBitmaps.
13706        * Create the empty atlas now.
13707        */
13708       struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, base);
13709       if (!atlas) {
13710          atlas = alloc_bitmap_atlas(ctx, base, true);
13711       }
13712       if (atlas) {
13713          /* Atlas _should_ be new/empty now, but clobbering is OK */
13714          assert(atlas->numBitmaps == 0);
13715          atlas->numBitmaps = range;
13716       }
13717    }
13718 
13719    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13720 
13721    return base;
13722 }
13723 
13724 
13725 /**
13726  * Begin a new display list.
13727  */
13728 void GLAPIENTRY
_mesa_NewList(GLuint name,GLenum mode)13729 _mesa_NewList(GLuint name, GLenum mode)
13730 {
13731    GET_CURRENT_CONTEXT(ctx);
13732 
13733    FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
13734    ASSERT_OUTSIDE_BEGIN_END(ctx);
13735 
13736    if (MESA_VERBOSE & VERBOSE_API)
13737       _mesa_debug(ctx, "glNewList %u %s\n", name,
13738                   _mesa_enum_to_string(mode));
13739 
13740    if (name == 0) {
13741       _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
13742       return;
13743    }
13744 
13745    if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
13746       _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
13747       return;
13748    }
13749 
13750    if (ctx->ListState.CurrentList) {
13751       /* already compiling a display list */
13752       _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
13753       return;
13754    }
13755 
13756    ctx->CompileFlag = GL_TRUE;
13757    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
13758 
13759    /* Reset accumulated list state */
13760    invalidate_saved_current_state( ctx );
13761 
13762    /* Allocate new display list */
13763    ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
13764    ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
13765    ctx->ListState.CurrentPos = 0;
13766 
13767    vbo_save_NewList(ctx, name, mode);
13768 
13769    ctx->CurrentServerDispatch = ctx->Save;
13770    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13771    if (ctx->MarshalExec == NULL) {
13772       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13773    }
13774 }
13775 
13776 
13777 /**
13778  * End definition of current display list.
13779  */
13780 void GLAPIENTRY
_mesa_EndList(void)13781 _mesa_EndList(void)
13782 {
13783    GET_CURRENT_CONTEXT(ctx);
13784    SAVE_FLUSH_VERTICES(ctx);
13785    FLUSH_VERTICES(ctx, 0);
13786 
13787    if (MESA_VERBOSE & VERBOSE_API)
13788       _mesa_debug(ctx, "glEndList\n");
13789 
13790    if (ctx->ExecuteFlag && _mesa_inside_dlist_begin_end(ctx)) {
13791       _mesa_error(ctx, GL_INVALID_OPERATION,
13792                   "glEndList() called inside glBegin/End");
13793    }
13794 
13795    /* Check that a list is under construction */
13796    if (!ctx->ListState.CurrentList) {
13797       _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
13798       return;
13799    }
13800 
13801    /* Call before emitting END_OF_LIST, in case the driver wants to
13802     * emit opcodes itself.
13803     */
13804    vbo_save_EndList(ctx);
13805 
13806    (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
13807 
13808    trim_list(ctx);
13809 
13810    /* Destroy old list, if any */
13811    destroy_list(ctx, ctx->ListState.CurrentList->Name);
13812 
13813    /* Install the new list */
13814    _mesa_HashInsert(ctx->Shared->DisplayList,
13815                     ctx->ListState.CurrentList->Name,
13816                     ctx->ListState.CurrentList, true);
13817 
13818 
13819    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
13820       mesa_print_display_list(ctx->ListState.CurrentList->Name);
13821 
13822    ctx->ListState.CurrentList = NULL;
13823    ctx->ListState.CurrentBlock = NULL;
13824    ctx->ListState.CurrentPos = 0;
13825    ctx->ExecuteFlag = GL_TRUE;
13826    ctx->CompileFlag = GL_FALSE;
13827 
13828    ctx->CurrentServerDispatch = ctx->Exec;
13829    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13830    if (ctx->MarshalExec == NULL) {
13831       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13832    }
13833 }
13834 
13835 
13836 void GLAPIENTRY
_mesa_CallList(GLuint list)13837 _mesa_CallList(GLuint list)
13838 {
13839    GLboolean save_compile_flag;
13840    GET_CURRENT_CONTEXT(ctx);
13841    FLUSH_CURRENT(ctx, 0);
13842 
13843    if (MESA_VERBOSE & VERBOSE_API)
13844       _mesa_debug(ctx, "glCallList %d\n", list);
13845 
13846    if (list == 0) {
13847       _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
13848       return;
13849    }
13850 
13851    if (0)
13852       mesa_print_display_list( list );
13853 
13854    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off,
13855     * execute the display list, and restore the CompileFlag.
13856     */
13857    save_compile_flag = ctx->CompileFlag;
13858    if (save_compile_flag) {
13859       ctx->CompileFlag = GL_FALSE;
13860    }
13861 
13862    execute_list(ctx, list);
13863    ctx->CompileFlag = save_compile_flag;
13864 
13865    /* also restore API function pointers to point to "save" versions */
13866    if (save_compile_flag) {
13867       ctx->CurrentServerDispatch = ctx->Save;
13868        _glapi_set_dispatch(ctx->CurrentServerDispatch);
13869       if (ctx->MarshalExec == NULL) {
13870          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13871       }
13872    }
13873 }
13874 
13875 
13876 /**
13877  * Try to execute a glCallLists() command where the display lists contain
13878  * glBitmap commands with a texture atlas.
13879  * \return true for success, false otherwise
13880  */
13881 static bool
render_bitmap_atlas(struct gl_context * ctx,GLsizei n,GLenum type,const void * lists)13882 render_bitmap_atlas(struct gl_context *ctx, GLsizei n, GLenum type,
13883                     const void *lists)
13884 {
13885    struct gl_bitmap_atlas *atlas;
13886    int i;
13887 
13888    if (!USE_BITMAP_ATLAS ||
13889        !ctx->Current.RasterPosValid ||
13890        ctx->List.ListBase == 0 ||
13891        type != GL_UNSIGNED_BYTE ||
13892        !ctx->Driver.DrawAtlasBitmaps) {
13893       /* unsupported */
13894       return false;
13895    }
13896 
13897    atlas = lookup_bitmap_atlas(ctx, ctx->List.ListBase);
13898 
13899    if (!atlas) {
13900       /* Even if glGenLists wasn't called, we can still try to create
13901        * the atlas now.
13902        */
13903       atlas = alloc_bitmap_atlas(ctx, ctx->List.ListBase, false);
13904    }
13905 
13906    if (atlas && !atlas->complete && !atlas->incomplete) {
13907       /* Try to build the bitmap atlas now.
13908        * If the atlas was created in glGenLists, we'll have recorded the
13909        * number of lists (bitmaps).  Otherwise, take a guess at 256.
13910        */
13911       if (atlas->numBitmaps == 0)
13912          atlas->numBitmaps = 256;
13913       build_bitmap_atlas(ctx, atlas, ctx->List.ListBase);
13914    }
13915 
13916    if (!atlas || !atlas->complete) {
13917       return false;
13918    }
13919 
13920    /* check that all display list IDs are in the atlas */
13921    for (i = 0; i < n; i++) {
13922       const GLubyte *ids = (const GLubyte *) lists;
13923 
13924       if (ids[i] >= atlas->numBitmaps) {
13925          return false;
13926       }
13927    }
13928 
13929    ctx->Driver.DrawAtlasBitmaps(ctx, atlas, n, (const GLubyte *) lists);
13930 
13931    return true;
13932 }
13933 
13934 
13935 /**
13936  * Execute glCallLists:  call multiple display lists.
13937  */
13938 void GLAPIENTRY
_mesa_CallLists(GLsizei n,GLenum type,const GLvoid * lists)13939 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
13940 {
13941    GET_CURRENT_CONTEXT(ctx);
13942    GLint i;
13943    GLboolean save_compile_flag;
13944 
13945    if (MESA_VERBOSE & VERBOSE_API)
13946       _mesa_debug(ctx, "glCallLists %d\n", n);
13947 
13948    switch (type) {
13949    case GL_BYTE:
13950    case GL_UNSIGNED_BYTE:
13951    case GL_SHORT:
13952    case GL_UNSIGNED_SHORT:
13953    case GL_INT:
13954    case GL_UNSIGNED_INT:
13955    case GL_FLOAT:
13956    case GL_2_BYTES:
13957    case GL_3_BYTES:
13958    case GL_4_BYTES:
13959       /* OK */
13960       break;
13961    default:
13962       _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
13963       return;
13964    }
13965 
13966    if (n < 0) {
13967       _mesa_error(ctx, GL_INVALID_VALUE, "glCallLists(n < 0)");
13968       return;
13969    } else if (n == 0 || lists == NULL) {
13970       /* nothing to do */
13971       return;
13972    }
13973 
13974    if (render_bitmap_atlas(ctx, n, type, lists)) {
13975       return;
13976    }
13977 
13978    /* Save the CompileFlag status, turn it off, execute display list,
13979     * and restore the CompileFlag.
13980     */
13981    save_compile_flag = ctx->CompileFlag;
13982    ctx->CompileFlag = GL_FALSE;
13983 
13984    for (i = 0; i < n; i++) {
13985       GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
13986       execute_list(ctx, list);
13987    }
13988 
13989    ctx->CompileFlag = save_compile_flag;
13990 
13991    /* also restore API function pointers to point to "save" versions */
13992    if (save_compile_flag) {
13993       ctx->CurrentServerDispatch = ctx->Save;
13994       _glapi_set_dispatch(ctx->CurrentServerDispatch);
13995       if (ctx->MarshalExec == NULL) {
13996          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13997       }
13998    }
13999 }
14000 
14001 
14002 /**
14003  * Set the offset added to list numbers in glCallLists.
14004  */
14005 void GLAPIENTRY
_mesa_ListBase(GLuint base)14006 _mesa_ListBase(GLuint base)
14007 {
14008    GET_CURRENT_CONTEXT(ctx);
14009    FLUSH_VERTICES(ctx, 0);      /* must be called before assert */
14010    ASSERT_OUTSIDE_BEGIN_END(ctx);
14011    ctx->List.ListBase = base;
14012 }
14013 
14014 /**
14015  * Setup the given dispatch table to point to Mesa's display list
14016  * building functions.
14017  *
14018  * This does not include any of the tnl functions - they are
14019  * initialized from _mesa_init_api_defaults and from the active vtxfmt
14020  * struct.
14021  */
14022 void
_mesa_initialize_save_table(const struct gl_context * ctx)14023 _mesa_initialize_save_table(const struct gl_context *ctx)
14024 {
14025    struct _glapi_table *table = ctx->Save;
14026    int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size());
14027 
14028    /* Initially populate the dispatch table with the contents of the
14029     * normal-execution dispatch table.  This lets us skip populating functions
14030     * that should be called directly instead of compiled into display lists.
14031     */
14032    memcpy(table, ctx->Exec, numEntries * sizeof(_glapi_proc));
14033 
14034    /* VBO functions */
14035    vbo_initialize_save_dispatch(ctx, table);
14036 
14037    /* GL 1.0 */
14038    SET_Accum(table, save_Accum);
14039    SET_AlphaFunc(table, save_AlphaFunc);
14040    SET_Bitmap(table, save_Bitmap);
14041    SET_BlendFunc(table, save_BlendFunc);
14042    SET_CallList(table, save_CallList);
14043    SET_CallLists(table, save_CallLists);
14044    SET_Clear(table, save_Clear);
14045    SET_ClearAccum(table, save_ClearAccum);
14046    SET_ClearColor(table, save_ClearColor);
14047    SET_ClearDepth(table, save_ClearDepth);
14048    SET_ClearIndex(table, save_ClearIndex);
14049    SET_ClearStencil(table, save_ClearStencil);
14050    SET_ClipPlane(table, save_ClipPlane);
14051    SET_ColorMask(table, save_ColorMask);
14052    SET_ColorMaski(table, save_ColorMaskIndexed);
14053    SET_ColorMaterial(table, save_ColorMaterial);
14054    SET_CopyPixels(table, save_CopyPixels);
14055    SET_CullFace(table, save_CullFace);
14056    SET_DepthFunc(table, save_DepthFunc);
14057    SET_DepthMask(table, save_DepthMask);
14058    SET_DepthRange(table, save_DepthRange);
14059    SET_Disable(table, save_Disable);
14060    SET_Disablei(table, save_DisableIndexed);
14061    SET_DrawBuffer(table, save_DrawBuffer);
14062    SET_DrawPixels(table, save_DrawPixels);
14063    SET_Enable(table, save_Enable);
14064    SET_Enablei(table, save_EnableIndexed);
14065    SET_EvalMesh1(table, save_EvalMesh1);
14066    SET_EvalMesh2(table, save_EvalMesh2);
14067    SET_Fogf(table, save_Fogf);
14068    SET_Fogfv(table, save_Fogfv);
14069    SET_Fogi(table, save_Fogi);
14070    SET_Fogiv(table, save_Fogiv);
14071    SET_FrontFace(table, save_FrontFace);
14072    SET_Frustum(table, save_Frustum);
14073    SET_Hint(table, save_Hint);
14074    SET_IndexMask(table, save_IndexMask);
14075    SET_InitNames(table, save_InitNames);
14076    SET_LightModelf(table, save_LightModelf);
14077    SET_LightModelfv(table, save_LightModelfv);
14078    SET_LightModeli(table, save_LightModeli);
14079    SET_LightModeliv(table, save_LightModeliv);
14080    SET_Lightf(table, save_Lightf);
14081    SET_Lightfv(table, save_Lightfv);
14082    SET_Lighti(table, save_Lighti);
14083    SET_Lightiv(table, save_Lightiv);
14084    SET_LineStipple(table, save_LineStipple);
14085    SET_LineWidth(table, save_LineWidth);
14086    SET_ListBase(table, save_ListBase);
14087    SET_LoadIdentity(table, save_LoadIdentity);
14088    SET_LoadMatrixd(table, save_LoadMatrixd);
14089    SET_LoadMatrixf(table, save_LoadMatrixf);
14090    SET_LoadName(table, save_LoadName);
14091    SET_LogicOp(table, save_LogicOp);
14092    SET_Map1d(table, save_Map1d);
14093    SET_Map1f(table, save_Map1f);
14094    SET_Map2d(table, save_Map2d);
14095    SET_Map2f(table, save_Map2f);
14096    SET_MapGrid1d(table, save_MapGrid1d);
14097    SET_MapGrid1f(table, save_MapGrid1f);
14098    SET_MapGrid2d(table, save_MapGrid2d);
14099    SET_MapGrid2f(table, save_MapGrid2f);
14100    SET_MatrixMode(table, save_MatrixMode);
14101    SET_MultMatrixd(table, save_MultMatrixd);
14102    SET_MultMatrixf(table, save_MultMatrixf);
14103    SET_NewList(table, save_NewList);
14104    SET_Ortho(table, save_Ortho);
14105    SET_PassThrough(table, save_PassThrough);
14106    SET_PixelMapfv(table, save_PixelMapfv);
14107    SET_PixelMapuiv(table, save_PixelMapuiv);
14108    SET_PixelMapusv(table, save_PixelMapusv);
14109    SET_PixelTransferf(table, save_PixelTransferf);
14110    SET_PixelTransferi(table, save_PixelTransferi);
14111    SET_PixelZoom(table, save_PixelZoom);
14112    SET_PointSize(table, save_PointSize);
14113    SET_PolygonMode(table, save_PolygonMode);
14114    SET_PolygonOffset(table, save_PolygonOffset);
14115    SET_PolygonStipple(table, save_PolygonStipple);
14116    SET_PopAttrib(table, save_PopAttrib);
14117    SET_PopMatrix(table, save_PopMatrix);
14118    SET_PopName(table, save_PopName);
14119    SET_PushAttrib(table, save_PushAttrib);
14120    SET_PushMatrix(table, save_PushMatrix);
14121    SET_PushName(table, save_PushName);
14122    SET_RasterPos2d(table, save_RasterPos2d);
14123    SET_RasterPos2dv(table, save_RasterPos2dv);
14124    SET_RasterPos2f(table, save_RasterPos2f);
14125    SET_RasterPos2fv(table, save_RasterPos2fv);
14126    SET_RasterPos2i(table, save_RasterPos2i);
14127    SET_RasterPos2iv(table, save_RasterPos2iv);
14128    SET_RasterPos2s(table, save_RasterPos2s);
14129    SET_RasterPos2sv(table, save_RasterPos2sv);
14130    SET_RasterPos3d(table, save_RasterPos3d);
14131    SET_RasterPos3dv(table, save_RasterPos3dv);
14132    SET_RasterPos3f(table, save_RasterPos3f);
14133    SET_RasterPos3fv(table, save_RasterPos3fv);
14134    SET_RasterPos3i(table, save_RasterPos3i);
14135    SET_RasterPos3iv(table, save_RasterPos3iv);
14136    SET_RasterPos3s(table, save_RasterPos3s);
14137    SET_RasterPos3sv(table, save_RasterPos3sv);
14138    SET_RasterPos4d(table, save_RasterPos4d);
14139    SET_RasterPos4dv(table, save_RasterPos4dv);
14140    SET_RasterPos4f(table, save_RasterPos4f);
14141    SET_RasterPos4fv(table, save_RasterPos4fv);
14142    SET_RasterPos4i(table, save_RasterPos4i);
14143    SET_RasterPos4iv(table, save_RasterPos4iv);
14144    SET_RasterPos4s(table, save_RasterPos4s);
14145    SET_RasterPos4sv(table, save_RasterPos4sv);
14146    SET_ReadBuffer(table, save_ReadBuffer);
14147    SET_Rectf(table, save_Rectf);
14148    SET_Rectd(table, save_Rectd);
14149    SET_Rectdv(table, save_Rectdv);
14150    SET_Rectfv(table, save_Rectfv);
14151    SET_Recti(table, save_Recti);
14152    SET_Rectiv(table, save_Rectiv);
14153    SET_Rects(table, save_Rects);
14154    SET_Rectsv(table, save_Rectsv);
14155    SET_Rotated(table, save_Rotated);
14156    SET_Rotatef(table, save_Rotatef);
14157    SET_Scaled(table, save_Scaled);
14158    SET_Scalef(table, save_Scalef);
14159    SET_Scissor(table, save_Scissor);
14160    SET_ShadeModel(table, save_ShadeModel);
14161    SET_StencilFunc(table, save_StencilFunc);
14162    SET_StencilMask(table, save_StencilMask);
14163    SET_StencilOp(table, save_StencilOp);
14164    SET_TexEnvf(table, save_TexEnvf);
14165    SET_TexEnvfv(table, save_TexEnvfv);
14166    SET_TexEnvi(table, save_TexEnvi);
14167    SET_TexEnviv(table, save_TexEnviv);
14168    SET_TexGend(table, save_TexGend);
14169    SET_TexGendv(table, save_TexGendv);
14170    SET_TexGenf(table, save_TexGenf);
14171    SET_TexGenfv(table, save_TexGenfv);
14172    SET_TexGeni(table, save_TexGeni);
14173    SET_TexGeniv(table, save_TexGeniv);
14174    SET_TexImage1D(table, save_TexImage1D);
14175    SET_TexImage2D(table, save_TexImage2D);
14176    SET_TexParameterf(table, save_TexParameterf);
14177    SET_TexParameterfv(table, save_TexParameterfv);
14178    SET_TexParameteri(table, save_TexParameteri);
14179    SET_TexParameteriv(table, save_TexParameteriv);
14180    SET_Translated(table, save_Translated);
14181    SET_Translatef(table, save_Translatef);
14182    SET_Viewport(table, save_Viewport);
14183 
14184    /* GL 1.1 */
14185    SET_BindTexture(table, save_BindTexture);
14186    SET_CopyTexImage1D(table, save_CopyTexImage1D);
14187    SET_CopyTexImage2D(table, save_CopyTexImage2D);
14188    SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
14189    SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
14190    SET_PrioritizeTextures(table, save_PrioritizeTextures);
14191    SET_TexSubImage1D(table, save_TexSubImage1D);
14192    SET_TexSubImage2D(table, save_TexSubImage2D);
14193 
14194    /* GL 1.2 */
14195    SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
14196    SET_TexImage3D(table, save_TexImage3D);
14197    SET_TexSubImage3D(table, save_TexSubImage3D);
14198 
14199    /* GL 2.0 */
14200    SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
14201    SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
14202    SET_StencilOpSeparate(table, save_StencilOpSeparate);
14203 
14204    /* ATI_separate_stencil */
14205    SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
14206 
14207    /* GL_ARB_imaging */
14208    /* Not all are supported */
14209    SET_BlendColor(table, save_BlendColor);
14210    SET_BlendEquation(table, save_BlendEquation);
14211 
14212    /* 2. GL_EXT_blend_color */
14213 #if 0
14214    SET_BlendColorEXT(table, save_BlendColorEXT);
14215 #endif
14216 
14217    /* 6. GL_EXT_texture3d */
14218 #if 0
14219    SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
14220    SET_TexImage3DEXT(table, save_TexImage3DEXT);
14221    SET_TexSubImage3DEXT(table, save_TexSubImage3D);
14222 #endif
14223 
14224    /* 37. GL_EXT_blend_minmax */
14225 #if 0
14226    SET_BlendEquationEXT(table, save_BlendEquationEXT);
14227 #endif
14228 
14229    /* 54. GL_EXT_point_parameters */
14230    SET_PointParameterf(table, save_PointParameterfEXT);
14231    SET_PointParameterfv(table, save_PointParameterfvEXT);
14232 
14233    /* 91. GL_ARB_tessellation_shader */
14234    SET_PatchParameteri(table, save_PatchParameteri);
14235    SET_PatchParameterfv(table, save_PatchParameterfv);
14236 
14237    /* 100. ARB_viewport_array */
14238    SET_ViewportArrayv(table, save_ViewportArrayv);
14239    SET_ViewportIndexedf(table, save_ViewportIndexedf);
14240    SET_ViewportIndexedfv(table, save_ViewportIndexedfv);
14241    SET_ScissorArrayv(table, save_ScissorArrayv);
14242    SET_ScissorIndexed(table, save_ScissorIndexed);
14243    SET_ScissorIndexedv(table, save_ScissorIndexedv);
14244    SET_DepthRangeArrayv(table, save_DepthRangeArrayv);
14245    SET_DepthRangeIndexed(table, save_DepthRangeIndexed);
14246 
14247    /* 122. ARB_compute_shader */
14248    SET_DispatchCompute(table, save_DispatchCompute);
14249    SET_DispatchComputeIndirect(table, save_DispatchComputeIndirect);
14250 
14251    /* 173. GL_EXT_blend_func_separate */
14252    SET_BlendFuncSeparate(table, save_BlendFuncSeparateEXT);
14253 
14254    /* 197. GL_MESA_window_pos */
14255    SET_WindowPos2d(table, save_WindowPos2dMESA);
14256    SET_WindowPos2dv(table, save_WindowPos2dvMESA);
14257    SET_WindowPos2f(table, save_WindowPos2fMESA);
14258    SET_WindowPos2fv(table, save_WindowPos2fvMESA);
14259    SET_WindowPos2i(table, save_WindowPos2iMESA);
14260    SET_WindowPos2iv(table, save_WindowPos2ivMESA);
14261    SET_WindowPos2s(table, save_WindowPos2sMESA);
14262    SET_WindowPos2sv(table, save_WindowPos2svMESA);
14263    SET_WindowPos3d(table, save_WindowPos3dMESA);
14264    SET_WindowPos3dv(table, save_WindowPos3dvMESA);
14265    SET_WindowPos3f(table, save_WindowPos3fMESA);
14266    SET_WindowPos3fv(table, save_WindowPos3fvMESA);
14267    SET_WindowPos3i(table, save_WindowPos3iMESA);
14268    SET_WindowPos3iv(table, save_WindowPos3ivMESA);
14269    SET_WindowPos3s(table, save_WindowPos3sMESA);
14270    SET_WindowPos3sv(table, save_WindowPos3svMESA);
14271    SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
14272    SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
14273    SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
14274    SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
14275    SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
14276    SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
14277    SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
14278    SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
14279 
14280    /* 245. GL_ATI_fragment_shader */
14281    SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
14282    SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
14283 
14284    /* 262. GL_NV_point_sprite */
14285    SET_PointParameteri(table, save_PointParameteriNV);
14286    SET_PointParameteriv(table, save_PointParameterivNV);
14287 
14288    /* 268. GL_EXT_stencil_two_side */
14289    SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
14290 
14291    /* ???. GL_EXT_depth_bounds_test */
14292    SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
14293 
14294    /* ARB 1. GL_ARB_multitexture */
14295    SET_ActiveTexture(table, save_ActiveTextureARB);
14296 
14297    /* ARB 3. GL_ARB_transpose_matrix */
14298    SET_LoadTransposeMatrixd(table, save_LoadTransposeMatrixdARB);
14299    SET_LoadTransposeMatrixf(table, save_LoadTransposeMatrixfARB);
14300    SET_MultTransposeMatrixd(table, save_MultTransposeMatrixdARB);
14301    SET_MultTransposeMatrixf(table, save_MultTransposeMatrixfARB);
14302 
14303    /* ARB 5. GL_ARB_multisample */
14304    SET_SampleCoverage(table, save_SampleCoverageARB);
14305 
14306    /* ARB 12. GL_ARB_texture_compression */
14307    SET_CompressedTexImage3D(table, save_CompressedTexImage3DARB);
14308    SET_CompressedTexImage2D(table, save_CompressedTexImage2DARB);
14309    SET_CompressedTexImage1D(table, save_CompressedTexImage1DARB);
14310    SET_CompressedTexSubImage3D(table, save_CompressedTexSubImage3DARB);
14311    SET_CompressedTexSubImage2D(table, save_CompressedTexSubImage2DARB);
14312    SET_CompressedTexSubImage1D(table, save_CompressedTexSubImage1DARB);
14313 
14314    /* ARB 14. GL_ARB_point_parameters */
14315    /* aliased with EXT_point_parameters functions */
14316 
14317    /* ARB 25. GL_ARB_window_pos */
14318    /* aliased with MESA_window_pos functions */
14319 
14320    /* ARB 26. GL_ARB_vertex_program */
14321    /* ARB 27. GL_ARB_fragment_program */
14322    /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
14323    SET_ProgramStringARB(table, save_ProgramStringARB);
14324    SET_BindProgramARB(table, save_BindProgramARB);
14325    SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
14326    SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
14327    SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
14328    SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
14329    SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
14330    SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
14331    SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
14332    SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
14333 
14334    SET_BeginQuery(table, save_BeginQueryARB);
14335    SET_EndQuery(table, save_EndQueryARB);
14336    SET_QueryCounter(table, save_QueryCounter);
14337 
14338    SET_DrawBuffers(table, save_DrawBuffersARB);
14339 
14340    SET_BlitFramebuffer(table, save_BlitFramebufferEXT);
14341 
14342    SET_UseProgram(table, save_UseProgram);
14343    SET_Uniform1f(table, save_Uniform1fARB);
14344    SET_Uniform2f(table, save_Uniform2fARB);
14345    SET_Uniform3f(table, save_Uniform3fARB);
14346    SET_Uniform4f(table, save_Uniform4fARB);
14347    SET_Uniform1fv(table, save_Uniform1fvARB);
14348    SET_Uniform2fv(table, save_Uniform2fvARB);
14349    SET_Uniform3fv(table, save_Uniform3fvARB);
14350    SET_Uniform4fv(table, save_Uniform4fvARB);
14351    SET_Uniform1i(table, save_Uniform1iARB);
14352    SET_Uniform2i(table, save_Uniform2iARB);
14353    SET_Uniform3i(table, save_Uniform3iARB);
14354    SET_Uniform4i(table, save_Uniform4iARB);
14355    SET_Uniform1iv(table, save_Uniform1ivARB);
14356    SET_Uniform2iv(table, save_Uniform2ivARB);
14357    SET_Uniform3iv(table, save_Uniform3ivARB);
14358    SET_Uniform4iv(table, save_Uniform4ivARB);
14359    SET_UniformMatrix2fv(table, save_UniformMatrix2fvARB);
14360    SET_UniformMatrix3fv(table, save_UniformMatrix3fvARB);
14361    SET_UniformMatrix4fv(table, save_UniformMatrix4fvARB);
14362    SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv);
14363    SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv);
14364    SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv);
14365    SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv);
14366    SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv);
14367    SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv);
14368 
14369    /* 299. GL_EXT_blend_equation_separate */
14370    SET_BlendEquationSeparate(table, save_BlendEquationSeparateEXT);
14371 
14372    /* GL_EXT_gpu_program_parameters */
14373    SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
14374    SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
14375 
14376    /* 364. GL_EXT_provoking_vertex */
14377    SET_ProvokingVertex(table, save_ProvokingVertexEXT);
14378 
14379    /* GL_EXT_texture_integer */
14380    SET_ClearColorIiEXT(table, save_ClearColorIi);
14381    SET_ClearColorIuiEXT(table, save_ClearColorIui);
14382    SET_TexParameterIiv(table, save_TexParameterIiv);
14383    SET_TexParameterIuiv(table, save_TexParameterIuiv);
14384 
14385    /* GL_ARB_clip_control */
14386    SET_ClipControl(table, save_ClipControl);
14387 
14388    /* GL_ARB_color_buffer_float */
14389    SET_ClampColor(table, save_ClampColorARB);
14390 
14391    /* GL 3.0 */
14392    SET_ClearBufferiv(table, save_ClearBufferiv);
14393    SET_ClearBufferuiv(table, save_ClearBufferuiv);
14394    SET_ClearBufferfv(table, save_ClearBufferfv);
14395    SET_ClearBufferfi(table, save_ClearBufferfi);
14396    SET_Uniform1ui(table, save_Uniform1ui);
14397    SET_Uniform2ui(table, save_Uniform2ui);
14398    SET_Uniform3ui(table, save_Uniform3ui);
14399    SET_Uniform4ui(table, save_Uniform4ui);
14400    SET_Uniform1uiv(table, save_Uniform1uiv);
14401    SET_Uniform2uiv(table, save_Uniform2uiv);
14402    SET_Uniform3uiv(table, save_Uniform3uiv);
14403    SET_Uniform4uiv(table, save_Uniform4uiv);
14404 
14405    /* GL_ARB_gpu_shader_fp64 */
14406    SET_Uniform1d(table, save_Uniform1d);
14407    SET_Uniform2d(table, save_Uniform2d);
14408    SET_Uniform3d(table, save_Uniform3d);
14409    SET_Uniform4d(table, save_Uniform4d);
14410    SET_Uniform1dv(table, save_Uniform1dv);
14411    SET_Uniform2dv(table, save_Uniform2dv);
14412    SET_Uniform3dv(table, save_Uniform3dv);
14413    SET_Uniform4dv(table, save_Uniform4dv);
14414    SET_UniformMatrix2dv(table, save_UniformMatrix2dv);
14415    SET_UniformMatrix3dv(table, save_UniformMatrix3dv);
14416    SET_UniformMatrix4dv(table, save_UniformMatrix4dv);
14417    SET_UniformMatrix2x3dv(table, save_UniformMatrix2x3dv);
14418    SET_UniformMatrix3x2dv(table, save_UniformMatrix3x2dv);
14419    SET_UniformMatrix2x4dv(table, save_UniformMatrix2x4dv);
14420    SET_UniformMatrix4x2dv(table, save_UniformMatrix4x2dv);
14421    SET_UniformMatrix3x4dv(table, save_UniformMatrix3x4dv);
14422    SET_UniformMatrix4x3dv(table, save_UniformMatrix4x3dv);
14423 
14424    /* GL_ARB_gpu_shader_int64 */
14425    SET_Uniform1i64ARB(table, save_Uniform1i64ARB);
14426    SET_Uniform2i64ARB(table, save_Uniform2i64ARB);
14427    SET_Uniform3i64ARB(table, save_Uniform3i64ARB);
14428    SET_Uniform4i64ARB(table, save_Uniform4i64ARB);
14429    SET_Uniform1i64vARB(table, save_Uniform1i64vARB);
14430    SET_Uniform2i64vARB(table, save_Uniform2i64vARB);
14431    SET_Uniform3i64vARB(table, save_Uniform3i64vARB);
14432    SET_Uniform4i64vARB(table, save_Uniform4i64vARB);
14433    SET_Uniform1ui64ARB(table, save_Uniform1ui64ARB);
14434    SET_Uniform2ui64ARB(table, save_Uniform2ui64ARB);
14435    SET_Uniform3ui64ARB(table, save_Uniform3ui64ARB);
14436    SET_Uniform4ui64ARB(table, save_Uniform4ui64ARB);
14437    SET_Uniform1ui64vARB(table, save_Uniform1ui64vARB);
14438    SET_Uniform2ui64vARB(table, save_Uniform2ui64vARB);
14439    SET_Uniform3ui64vARB(table, save_Uniform3ui64vARB);
14440    SET_Uniform4ui64vARB(table, save_Uniform4ui64vARB);
14441 
14442    SET_ProgramUniform1i64ARB(table, save_ProgramUniform1i64ARB);
14443    SET_ProgramUniform2i64ARB(table, save_ProgramUniform2i64ARB);
14444    SET_ProgramUniform3i64ARB(table, save_ProgramUniform3i64ARB);
14445    SET_ProgramUniform4i64ARB(table, save_ProgramUniform4i64ARB);
14446    SET_ProgramUniform1i64vARB(table, save_ProgramUniform1i64vARB);
14447    SET_ProgramUniform2i64vARB(table, save_ProgramUniform2i64vARB);
14448    SET_ProgramUniform3i64vARB(table, save_ProgramUniform3i64vARB);
14449    SET_ProgramUniform4i64vARB(table, save_ProgramUniform4i64vARB);
14450    SET_ProgramUniform1ui64ARB(table, save_ProgramUniform1ui64ARB);
14451    SET_ProgramUniform2ui64ARB(table, save_ProgramUniform2ui64ARB);
14452    SET_ProgramUniform3ui64ARB(table, save_ProgramUniform3ui64ARB);
14453    SET_ProgramUniform4ui64ARB(table, save_ProgramUniform4ui64ARB);
14454    SET_ProgramUniform1ui64vARB(table, save_ProgramUniform1ui64vARB);
14455    SET_ProgramUniform2ui64vARB(table, save_ProgramUniform2ui64vARB);
14456    SET_ProgramUniform3ui64vARB(table, save_ProgramUniform3ui64vARB);
14457    SET_ProgramUniform4ui64vARB(table, save_ProgramUniform4ui64vARB);
14458 
14459    /* These are: */
14460    SET_BeginTransformFeedback(table, save_BeginTransformFeedback);
14461    SET_EndTransformFeedback(table, save_EndTransformFeedback);
14462    SET_BindTransformFeedback(table, save_BindTransformFeedback);
14463    SET_PauseTransformFeedback(table, save_PauseTransformFeedback);
14464    SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback);
14465    SET_DrawTransformFeedback(table, save_DrawTransformFeedback);
14466    SET_DrawTransformFeedbackStream(table, save_DrawTransformFeedbackStream);
14467    SET_DrawTransformFeedbackInstanced(table,
14468                                       save_DrawTransformFeedbackInstanced);
14469    SET_DrawTransformFeedbackStreamInstanced(table,
14470                                 save_DrawTransformFeedbackStreamInstanced);
14471    SET_BeginQueryIndexed(table, save_BeginQueryIndexed);
14472    SET_EndQueryIndexed(table, save_EndQueryIndexed);
14473 
14474    /* GL_ARB_instanced_arrays */
14475    SET_VertexAttribDivisor(table, save_VertexAttribDivisor);
14476 
14477    /* GL_NV_texture_barrier */
14478    SET_TextureBarrierNV(table, save_TextureBarrierNV);
14479 
14480    SET_BindSampler(table, save_BindSampler);
14481    SET_SamplerParameteri(table, save_SamplerParameteri);
14482    SET_SamplerParameterf(table, save_SamplerParameterf);
14483    SET_SamplerParameteriv(table, save_SamplerParameteriv);
14484    SET_SamplerParameterfv(table, save_SamplerParameterfv);
14485    SET_SamplerParameterIiv(table, save_SamplerParameterIiv);
14486    SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv);
14487 
14488    /* GL_ARB_draw_buffer_blend */
14489    SET_BlendFunciARB(table, save_BlendFunci);
14490    SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei);
14491    SET_BlendEquationiARB(table, save_BlendEquationi);
14492    SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
14493 
14494    /* GL_NV_conditional_render */
14495    SET_BeginConditionalRender(table, save_BeginConditionalRender);
14496    SET_EndConditionalRender(table, save_EndConditionalRender);
14497 
14498    /* GL_ARB_sync */
14499    SET_WaitSync(table, save_WaitSync);
14500 
14501    /* GL_ARB_uniform_buffer_object */
14502    SET_UniformBlockBinding(table, save_UniformBlockBinding);
14503 
14504    /* GL_ARB_shader_subroutines */
14505    SET_UniformSubroutinesuiv(table, save_UniformSubroutinesuiv);
14506 
14507    /* GL_ARB_draw_instanced */
14508    SET_DrawArraysInstancedARB(table, save_DrawArraysInstancedARB);
14509    SET_DrawElementsInstancedARB(table, save_DrawElementsInstancedARB);
14510 
14511    /* GL_ARB_draw_elements_base_vertex */
14512    SET_DrawElementsInstancedBaseVertex(table, save_DrawElementsInstancedBaseVertexARB);
14513 
14514    /* GL_ARB_base_instance */
14515    SET_DrawArraysInstancedBaseInstance(table, save_DrawArraysInstancedBaseInstance);
14516    SET_DrawElementsInstancedBaseInstance(table, save_DrawElementsInstancedBaseInstance);
14517    SET_DrawElementsInstancedBaseVertexBaseInstance(table, save_DrawElementsInstancedBaseVertexBaseInstance);
14518 
14519    /* GL_ARB_draw_indirect / GL_ARB_multi_draw_indirect */
14520    SET_DrawArraysIndirect(table, save_DrawArraysIndirect);
14521    SET_DrawElementsIndirect(table, save_DrawElementsIndirect);
14522    SET_MultiDrawArraysIndirect(table, save_MultiDrawArraysIndirect);
14523    SET_MultiDrawElementsIndirect(table, save_MultiDrawElementsIndirect);
14524 
14525    /* OpenGL 4.2 / GL_ARB_separate_shader_objects */
14526    SET_UseProgramStages(table, save_UseProgramStages);
14527    SET_ProgramUniform1f(table, save_ProgramUniform1f);
14528    SET_ProgramUniform2f(table, save_ProgramUniform2f);
14529    SET_ProgramUniform3f(table, save_ProgramUniform3f);
14530    SET_ProgramUniform4f(table, save_ProgramUniform4f);
14531    SET_ProgramUniform1fv(table, save_ProgramUniform1fv);
14532    SET_ProgramUniform2fv(table, save_ProgramUniform2fv);
14533    SET_ProgramUniform3fv(table, save_ProgramUniform3fv);
14534    SET_ProgramUniform4fv(table, save_ProgramUniform4fv);
14535    SET_ProgramUniform1d(table, save_ProgramUniform1d);
14536    SET_ProgramUniform2d(table, save_ProgramUniform2d);
14537    SET_ProgramUniform3d(table, save_ProgramUniform3d);
14538    SET_ProgramUniform4d(table, save_ProgramUniform4d);
14539    SET_ProgramUniform1dv(table, save_ProgramUniform1dv);
14540    SET_ProgramUniform2dv(table, save_ProgramUniform2dv);
14541    SET_ProgramUniform3dv(table, save_ProgramUniform3dv);
14542    SET_ProgramUniform4dv(table, save_ProgramUniform4dv);
14543    SET_ProgramUniform1i(table, save_ProgramUniform1i);
14544    SET_ProgramUniform2i(table, save_ProgramUniform2i);
14545    SET_ProgramUniform3i(table, save_ProgramUniform3i);
14546    SET_ProgramUniform4i(table, save_ProgramUniform4i);
14547    SET_ProgramUniform1iv(table, save_ProgramUniform1iv);
14548    SET_ProgramUniform2iv(table, save_ProgramUniform2iv);
14549    SET_ProgramUniform3iv(table, save_ProgramUniform3iv);
14550    SET_ProgramUniform4iv(table, save_ProgramUniform4iv);
14551    SET_ProgramUniform1ui(table, save_ProgramUniform1ui);
14552    SET_ProgramUniform2ui(table, save_ProgramUniform2ui);
14553    SET_ProgramUniform3ui(table, save_ProgramUniform3ui);
14554    SET_ProgramUniform4ui(table, save_ProgramUniform4ui);
14555    SET_ProgramUniform1uiv(table, save_ProgramUniform1uiv);
14556    SET_ProgramUniform2uiv(table, save_ProgramUniform2uiv);
14557    SET_ProgramUniform3uiv(table, save_ProgramUniform3uiv);
14558    SET_ProgramUniform4uiv(table, save_ProgramUniform4uiv);
14559    SET_ProgramUniformMatrix2fv(table, save_ProgramUniformMatrix2fv);
14560    SET_ProgramUniformMatrix3fv(table, save_ProgramUniformMatrix3fv);
14561    SET_ProgramUniformMatrix4fv(table, save_ProgramUniformMatrix4fv);
14562    SET_ProgramUniformMatrix2x3fv(table, save_ProgramUniformMatrix2x3fv);
14563    SET_ProgramUniformMatrix3x2fv(table, save_ProgramUniformMatrix3x2fv);
14564    SET_ProgramUniformMatrix2x4fv(table, save_ProgramUniformMatrix2x4fv);
14565    SET_ProgramUniformMatrix4x2fv(table, save_ProgramUniformMatrix4x2fv);
14566    SET_ProgramUniformMatrix3x4fv(table, save_ProgramUniformMatrix3x4fv);
14567    SET_ProgramUniformMatrix4x3fv(table, save_ProgramUniformMatrix4x3fv);
14568    SET_ProgramUniformMatrix2dv(table, save_ProgramUniformMatrix2dv);
14569    SET_ProgramUniformMatrix3dv(table, save_ProgramUniformMatrix3dv);
14570    SET_ProgramUniformMatrix4dv(table, save_ProgramUniformMatrix4dv);
14571    SET_ProgramUniformMatrix2x3dv(table, save_ProgramUniformMatrix2x3dv);
14572    SET_ProgramUniformMatrix3x2dv(table, save_ProgramUniformMatrix3x2dv);
14573    SET_ProgramUniformMatrix2x4dv(table, save_ProgramUniformMatrix2x4dv);
14574    SET_ProgramUniformMatrix4x2dv(table, save_ProgramUniformMatrix4x2dv);
14575    SET_ProgramUniformMatrix3x4dv(table, save_ProgramUniformMatrix3x4dv);
14576    SET_ProgramUniformMatrix4x3dv(table, save_ProgramUniformMatrix4x3dv);
14577 
14578    /* GL_{ARB,EXT}_polygon_offset_clamp */
14579    SET_PolygonOffsetClampEXT(table, save_PolygonOffsetClampEXT);
14580 
14581    /* GL_EXT_window_rectangles */
14582    SET_WindowRectanglesEXT(table, save_WindowRectanglesEXT);
14583 
14584    /* GL_NV_conservative_raster */
14585    SET_SubpixelPrecisionBiasNV(table, save_SubpixelPrecisionBiasNV);
14586 
14587    /* GL_NV_conservative_raster_dilate */
14588    SET_ConservativeRasterParameterfNV(table, save_ConservativeRasterParameterfNV);
14589 
14590    /* GL_NV_conservative_raster_pre_snap_triangles */
14591    SET_ConservativeRasterParameteriNV(table, save_ConservativeRasterParameteriNV);
14592 
14593    /* GL_EXT_direct_state_access */
14594    SET_MatrixLoadfEXT(table, save_MatrixLoadfEXT);
14595    SET_MatrixLoaddEXT(table, save_MatrixLoaddEXT);
14596    SET_MatrixMultfEXT(table, save_MatrixMultfEXT);
14597    SET_MatrixMultdEXT(table, save_MatrixMultdEXT);
14598    SET_MatrixRotatefEXT(table, save_MatrixRotatefEXT);
14599    SET_MatrixRotatedEXT(table, save_MatrixRotatedEXT);
14600    SET_MatrixScalefEXT(table, save_MatrixScalefEXT);
14601    SET_MatrixScaledEXT(table, save_MatrixScaledEXT);
14602    SET_MatrixTranslatefEXT(table, save_MatrixTranslatefEXT);
14603    SET_MatrixTranslatedEXT(table, save_MatrixTranslatedEXT);
14604    SET_MatrixLoadIdentityEXT(table, save_MatrixLoadIdentityEXT);
14605    SET_MatrixOrthoEXT(table, save_MatrixOrthoEXT);
14606    SET_MatrixFrustumEXT(table, save_MatrixFrustumEXT);
14607    SET_MatrixPushEXT(table, save_MatrixPushEXT);
14608    SET_MatrixPopEXT(table, save_MatrixPopEXT);
14609    SET_MatrixLoadTransposefEXT(table, save_MatrixLoadTransposefEXT);
14610    SET_MatrixLoadTransposedEXT(table, save_MatrixLoadTransposedEXT);
14611    SET_MatrixMultTransposefEXT(table, save_MatrixMultTransposefEXT);
14612    SET_MatrixMultTransposedEXT(table, save_MatrixMultTransposedEXT);
14613    SET_TextureParameteriEXT(table, save_TextureParameteriEXT);
14614    SET_TextureParameterivEXT(table, save_TextureParameterivEXT);
14615    SET_TextureParameterfEXT(table, save_TextureParameterfEXT);
14616    SET_TextureParameterfvEXT(table, save_TextureParameterfvEXT);
14617    SET_TextureParameterIivEXT(table, save_TextureParameterIivEXT);
14618    SET_TextureParameterIuivEXT(table, save_TextureParameterIuivEXT);
14619    SET_TextureImage1DEXT(table, save_TextureImage1DEXT);
14620    SET_TextureImage2DEXT(table, save_TextureImage2DEXT);
14621    SET_TextureImage3DEXT(table, save_TextureImage3DEXT);
14622    SET_TextureSubImage1DEXT(table, save_TextureSubImage1DEXT);
14623    SET_TextureSubImage2DEXT(table, save_TextureSubImage2DEXT);
14624    SET_TextureSubImage3DEXT(table, save_TextureSubImage3DEXT);
14625    SET_CopyTextureImage1DEXT(table, save_CopyTextureImage1DEXT);
14626    SET_CopyTextureImage2DEXT(table, save_CopyTextureImage2DEXT);
14627    SET_CopyTextureSubImage1DEXT(table, save_CopyTextureSubImage1DEXT);
14628    SET_CopyTextureSubImage2DEXT(table, save_CopyTextureSubImage2DEXT);
14629    SET_CopyTextureSubImage3DEXT(table, save_CopyTextureSubImage3DEXT);
14630    SET_BindMultiTextureEXT(table, save_BindMultiTextureEXT);
14631    SET_MultiTexParameteriEXT(table, save_MultiTexParameteriEXT);
14632    SET_MultiTexParameterivEXT(table, save_MultiTexParameterivEXT);
14633    SET_MultiTexParameterIivEXT(table, save_MultiTexParameterIivEXT);
14634    SET_MultiTexParameterIuivEXT(table, save_MultiTexParameterIuivEXT);
14635    SET_MultiTexParameterfEXT(table, save_MultiTexParameterfEXT);
14636    SET_MultiTexParameterfvEXT(table, save_MultiTexParameterfvEXT);
14637    SET_MultiTexImage1DEXT(table, save_MultiTexImage1DEXT);
14638    SET_MultiTexImage2DEXT(table, save_MultiTexImage2DEXT);
14639    SET_MultiTexImage3DEXT(table, save_MultiTexImage3DEXT);
14640    SET_MultiTexSubImage1DEXT(table, save_MultiTexSubImage1DEXT);
14641    SET_MultiTexSubImage2DEXT(table, save_MultiTexSubImage2DEXT);
14642    SET_MultiTexSubImage3DEXT(table, save_MultiTexSubImage3DEXT);
14643    SET_CopyMultiTexImage1DEXT(table, save_CopyMultiTexImage1DEXT);
14644    SET_CopyMultiTexImage2DEXT(table, save_CopyMultiTexImage2DEXT);
14645    SET_CopyMultiTexSubImage1DEXT(table, save_CopyMultiTexSubImage1DEXT);
14646    SET_CopyMultiTexSubImage2DEXT(table, save_CopyMultiTexSubImage2DEXT);
14647    SET_CopyMultiTexSubImage3DEXT(table, save_CopyMultiTexSubImage3DEXT);
14648    SET_MultiTexEnvfEXT(table, save_MultiTexEnvfEXT);
14649    SET_MultiTexEnvfvEXT(table, save_MultiTexEnvfvEXT);
14650    SET_MultiTexEnviEXT(table, save_MultiTexEnviEXT);
14651    SET_MultiTexEnvivEXT(table, save_MultiTexEnvivEXT);
14652    SET_CompressedTextureImage1DEXT(table, save_CompressedTextureImage1DEXT);
14653    SET_CompressedTextureImage2DEXT(table, save_CompressedTextureImage2DEXT);
14654    SET_CompressedTextureImage3DEXT(table, save_CompressedTextureImage3DEXT);
14655    SET_CompressedTextureSubImage1DEXT(table, save_CompressedTextureSubImage1DEXT);
14656    SET_CompressedTextureSubImage2DEXT(table, save_CompressedTextureSubImage2DEXT);
14657    SET_CompressedTextureSubImage3DEXT(table, save_CompressedTextureSubImage3DEXT);
14658    SET_CompressedMultiTexImage1DEXT(table, save_CompressedMultiTexImage1DEXT);
14659    SET_CompressedMultiTexImage2DEXT(table, save_CompressedMultiTexImage2DEXT);
14660    SET_CompressedMultiTexImage3DEXT(table, save_CompressedMultiTexImage3DEXT);
14661    SET_CompressedMultiTexSubImage1DEXT(table, save_CompressedMultiTexSubImage1DEXT);
14662    SET_CompressedMultiTexSubImage2DEXT(table, save_CompressedMultiTexSubImage2DEXT);
14663    SET_CompressedMultiTexSubImage3DEXT(table, save_CompressedMultiTexSubImage3DEXT);
14664    SET_NamedProgramStringEXT(table, save_NamedProgramStringEXT);
14665    SET_NamedProgramLocalParameter4dEXT(table, save_NamedProgramLocalParameter4dEXT);
14666    SET_NamedProgramLocalParameter4dvEXT(table, save_NamedProgramLocalParameter4dvEXT);
14667    SET_NamedProgramLocalParameter4fEXT(table, save_NamedProgramLocalParameter4fEXT);
14668    SET_NamedProgramLocalParameter4fvEXT(table, save_NamedProgramLocalParameter4fvEXT);
14669 }
14670 
14671 
14672 
14673 static const char *
enum_string(GLenum k)14674 enum_string(GLenum k)
14675 {
14676    return _mesa_enum_to_string(k);
14677 }
14678 
14679 
14680 /**
14681  * Print the commands in a display list.  For debugging only.
14682  * TODO: many commands aren't handled yet.
14683  * \param fname  filename to write display list to.  If null, use stdout.
14684  */
14685 static void GLAPIENTRY
print_list(struct gl_context * ctx,GLuint list,const char * fname)14686 print_list(struct gl_context *ctx, GLuint list, const char *fname)
14687 {
14688    struct gl_display_list *dlist;
14689    Node *n;
14690    GLboolean done;
14691    FILE *f = stdout;
14692 
14693    if (fname) {
14694       f = fopen(fname, "w");
14695       if (!f)
14696          return;
14697    }
14698 
14699    if (!islist(ctx, list)) {
14700       fprintf(f, "%u is not a display list ID\n", list);
14701       goto out;
14702    }
14703 
14704    dlist = _mesa_lookup_list(ctx, list);
14705    if (!dlist) {
14706       goto out;
14707    }
14708 
14709    n = dlist->Head;
14710 
14711    fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
14712 
14713    done = n ? GL_FALSE : GL_TRUE;
14714    while (!done) {
14715       const OpCode opcode = n[0].opcode;
14716 
14717       if (is_ext_opcode(opcode)) {
14718          n += ext_opcode_print(ctx, n, f);
14719       }
14720       else {
14721          switch (opcode) {
14722          case OPCODE_ACCUM:
14723             fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f);
14724             break;
14725          case OPCODE_ACTIVE_TEXTURE:
14726             fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e));
14727             break;
14728          case OPCODE_BITMAP:
14729             fprintf(f, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
14730                    n[3].f, n[4].f, n[5].f, n[6].f,
14731                    get_pointer(&n[7]));
14732             break;
14733          case OPCODE_BLEND_COLOR:
14734             fprintf(f, "BlendColor %f, %f, %f, %f\n",
14735                     n[1].f, n[2].f, n[3].f, n[4].f);
14736             break;
14737          case OPCODE_BLEND_EQUATION:
14738             fprintf(f, "BlendEquation %s\n",
14739                     enum_string(n[1].e));
14740             break;
14741          case OPCODE_BLEND_EQUATION_SEPARATE:
14742             fprintf(f, "BlendEquationSeparate %s, %s\n",
14743                     enum_string(n[1].e),
14744                     enum_string(n[2].e));
14745             break;
14746          case OPCODE_BLEND_FUNC_SEPARATE:
14747             fprintf(f, "BlendFuncSeparate %s, %s, %s, %s\n",
14748                     enum_string(n[1].e),
14749                     enum_string(n[2].e),
14750                     enum_string(n[3].e),
14751                     enum_string(n[4].e));
14752             break;
14753          case OPCODE_BLEND_EQUATION_I:
14754             fprintf(f, "BlendEquationi %u, %s\n",
14755                     n[1].ui, enum_string(n[2].e));
14756             break;
14757          case OPCODE_BLEND_EQUATION_SEPARATE_I:
14758             fprintf(f, "BlendEquationSeparatei %u, %s, %s\n",
14759                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
14760             break;
14761          case OPCODE_BLEND_FUNC_I:
14762             fprintf(f, "BlendFunci %u, %s, %s\n",
14763                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
14764             break;
14765          case OPCODE_BLEND_FUNC_SEPARATE_I:
14766             fprintf(f, "BlendFuncSeparatei %u, %s, %s, %s, %s\n",
14767                     n[1].ui,
14768                     enum_string(n[2].e),
14769                     enum_string(n[3].e),
14770                     enum_string(n[4].e),
14771                     enum_string(n[5].e));
14772             break;
14773          case OPCODE_CALL_LIST:
14774             fprintf(f, "CallList %d\n", (int) n[1].ui);
14775             break;
14776          case OPCODE_CALL_LISTS:
14777             fprintf(f, "CallLists %d, %s\n", n[1].i, enum_string(n[1].e));
14778             break;
14779          case OPCODE_DISABLE:
14780             fprintf(f, "Disable %s\n", enum_string(n[1].e));
14781             break;
14782          case OPCODE_ENABLE:
14783             fprintf(f, "Enable %s\n", enum_string(n[1].e));
14784             break;
14785          case OPCODE_FRUSTUM:
14786             fprintf(f, "Frustum %g %g %g %g %g %g\n",
14787                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
14788             break;
14789          case OPCODE_LINE_STIPPLE:
14790             fprintf(f, "LineStipple %d %x\n", n[1].i, (int) n[2].us);
14791             break;
14792          case OPCODE_LINE_WIDTH:
14793             fprintf(f, "LineWidth %f\n", n[1].f);
14794             break;
14795          case OPCODE_LOAD_IDENTITY:
14796             fprintf(f, "LoadIdentity\n");
14797             break;
14798          case OPCODE_LOAD_MATRIX:
14799             fprintf(f, "LoadMatrix\n");
14800             fprintf(f, "  %8f %8f %8f %8f\n",
14801                          n[1].f, n[5].f, n[9].f, n[13].f);
14802             fprintf(f, "  %8f %8f %8f %8f\n",
14803                          n[2].f, n[6].f, n[10].f, n[14].f);
14804             fprintf(f, "  %8f %8f %8f %8f\n",
14805                          n[3].f, n[7].f, n[11].f, n[15].f);
14806             fprintf(f, "  %8f %8f %8f %8f\n",
14807                          n[4].f, n[8].f, n[12].f, n[16].f);
14808             break;
14809          case OPCODE_MULT_MATRIX:
14810             fprintf(f, "MultMatrix (or Rotate)\n");
14811             fprintf(f, "  %8f %8f %8f %8f\n",
14812                          n[1].f, n[5].f, n[9].f, n[13].f);
14813             fprintf(f, "  %8f %8f %8f %8f\n",
14814                          n[2].f, n[6].f, n[10].f, n[14].f);
14815             fprintf(f, "  %8f %8f %8f %8f\n",
14816                          n[3].f, n[7].f, n[11].f, n[15].f);
14817             fprintf(f, "  %8f %8f %8f %8f\n",
14818                          n[4].f, n[8].f, n[12].f, n[16].f);
14819             break;
14820          case OPCODE_ORTHO:
14821             fprintf(f, "Ortho %g %g %g %g %g %g\n",
14822                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
14823             break;
14824          case OPCODE_POINT_SIZE:
14825             fprintf(f, "PointSize %f\n", n[1].f);
14826             break;
14827          case OPCODE_POP_ATTRIB:
14828             fprintf(f, "PopAttrib\n");
14829             break;
14830          case OPCODE_POP_MATRIX:
14831             fprintf(f, "PopMatrix\n");
14832             break;
14833          case OPCODE_POP_NAME:
14834             fprintf(f, "PopName\n");
14835             break;
14836          case OPCODE_PUSH_ATTRIB:
14837             fprintf(f, "PushAttrib %x\n", n[1].bf);
14838             break;
14839          case OPCODE_PUSH_MATRIX:
14840             fprintf(f, "PushMatrix\n");
14841             break;
14842          case OPCODE_PUSH_NAME:
14843             fprintf(f, "PushName %d\n", (int) n[1].ui);
14844             break;
14845          case OPCODE_RASTER_POS:
14846             fprintf(f, "RasterPos %g %g %g %g\n",
14847                          n[1].f, n[2].f, n[3].f, n[4].f);
14848             break;
14849          case OPCODE_ROTATE:
14850             fprintf(f, "Rotate %g %g %g %g\n",
14851                          n[1].f, n[2].f, n[3].f, n[4].f);
14852             break;
14853          case OPCODE_SCALE:
14854             fprintf(f, "Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
14855             break;
14856          case OPCODE_TRANSLATE:
14857             fprintf(f, "Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
14858             break;
14859          case OPCODE_BIND_TEXTURE:
14860             fprintf(f, "BindTexture %s %d\n",
14861                          _mesa_enum_to_string(n[1].ui), n[2].ui);
14862             break;
14863          case OPCODE_SHADE_MODEL:
14864             fprintf(f, "ShadeModel %s\n", _mesa_enum_to_string(n[1].ui));
14865             break;
14866          case OPCODE_MAP1:
14867             fprintf(f, "Map1 %s %.3f %.3f %d %d\n",
14868                          _mesa_enum_to_string(n[1].ui),
14869                          n[2].f, n[3].f, n[4].i, n[5].i);
14870             break;
14871          case OPCODE_MAP2:
14872             fprintf(f, "Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
14873                          _mesa_enum_to_string(n[1].ui),
14874                          n[2].f, n[3].f, n[4].f, n[5].f,
14875                          n[6].i, n[7].i, n[8].i, n[9].i);
14876             break;
14877          case OPCODE_MAPGRID1:
14878             fprintf(f, "MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
14879             break;
14880          case OPCODE_MAPGRID2:
14881             fprintf(f, "MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
14882                          n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
14883             break;
14884          case OPCODE_EVALMESH1:
14885             fprintf(f, "EvalMesh1 %d %d\n", n[1].i, n[2].i);
14886             break;
14887          case OPCODE_EVALMESH2:
14888             fprintf(f, "EvalMesh2 %d %d %d %d\n",
14889                          n[1].i, n[2].i, n[3].i, n[4].i);
14890             break;
14891 
14892          case OPCODE_ATTR_1F_NV:
14893             fprintf(f, "ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
14894             break;
14895          case OPCODE_ATTR_2F_NV:
14896             fprintf(f, "ATTR_2F_NV attr %d: %f %f\n",
14897                          n[1].i, n[2].f, n[3].f);
14898             break;
14899          case OPCODE_ATTR_3F_NV:
14900             fprintf(f, "ATTR_3F_NV attr %d: %f %f %f\n",
14901                          n[1].i, n[2].f, n[3].f, n[4].f);
14902             break;
14903          case OPCODE_ATTR_4F_NV:
14904             fprintf(f, "ATTR_4F_NV attr %d: %f %f %f %f\n",
14905                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
14906             break;
14907          case OPCODE_ATTR_1F_ARB:
14908             fprintf(f, "ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
14909             break;
14910          case OPCODE_ATTR_2F_ARB:
14911             fprintf(f, "ATTR_2F_ARB attr %d: %f %f\n",
14912                          n[1].i, n[2].f, n[3].f);
14913             break;
14914          case OPCODE_ATTR_3F_ARB:
14915             fprintf(f, "ATTR_3F_ARB attr %d: %f %f %f\n",
14916                          n[1].i, n[2].f, n[3].f, n[4].f);
14917             break;
14918          case OPCODE_ATTR_4F_ARB:
14919             fprintf(f, "ATTR_4F_ARB attr %d: %f %f %f %f\n",
14920                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
14921             break;
14922 
14923          case OPCODE_MATERIAL:
14924             fprintf(f, "MATERIAL %x %x: %f %f %f %f\n",
14925                          n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
14926             break;
14927          case OPCODE_BEGIN:
14928             fprintf(f, "BEGIN %x\n", n[1].i);
14929             break;
14930          case OPCODE_END:
14931             fprintf(f, "END\n");
14932             break;
14933          case OPCODE_RECTF:
14934             fprintf(f, "RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f,
14935                          n[4].f);
14936             break;
14937          case OPCODE_EVAL_C1:
14938             fprintf(f, "EVAL_C1 %f\n", n[1].f);
14939             break;
14940          case OPCODE_EVAL_C2:
14941             fprintf(f, "EVAL_C2 %f %f\n", n[1].f, n[2].f);
14942             break;
14943          case OPCODE_EVAL_P1:
14944             fprintf(f, "EVAL_P1 %d\n", n[1].i);
14945             break;
14946          case OPCODE_EVAL_P2:
14947             fprintf(f, "EVAL_P2 %d %d\n", n[1].i, n[2].i);
14948             break;
14949 
14950          case OPCODE_PROVOKING_VERTEX:
14951             fprintf(f, "ProvokingVertex %s\n",
14952                          _mesa_enum_to_string(n[1].ui));
14953             break;
14954 
14955             /*
14956              * meta opcodes/commands
14957              */
14958          case OPCODE_ERROR:
14959             fprintf(f, "Error: %s %s\n", enum_string(n[1].e),
14960                    (const char *) get_pointer(&n[2]));
14961             break;
14962          case OPCODE_CONTINUE:
14963             fprintf(f, "DISPLAY-LIST-CONTINUE\n");
14964             n = (Node *) get_pointer(&n[1]);
14965             break;
14966          case OPCODE_NOP:
14967             fprintf(f, "NOP\n");
14968             break;
14969          case OPCODE_END_OF_LIST:
14970             fprintf(f, "END-LIST %u\n", list);
14971             done = GL_TRUE;
14972             break;
14973          default:
14974             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
14975                printf
14976                   ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
14977                    opcode, (void *) n);
14978                goto out;
14979             }
14980             else {
14981                fprintf(f, "command %d, %u operands\n", opcode,
14982                             InstSize[opcode]);
14983             }
14984          }
14985          /* increment n to point to next compiled command */
14986          if (opcode != OPCODE_CONTINUE) {
14987             assert(InstSize[opcode] > 0);
14988             n += InstSize[opcode];
14989          }
14990       }
14991    }
14992 
14993  out:
14994    fflush(f);
14995    if (fname)
14996       fclose(f);
14997 }
14998 
14999 
15000 
15001 /**
15002  * Clients may call this function to help debug display list problems.
15003  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
15004  * changed, or break in the future without notice.
15005  */
15006 void
mesa_print_display_list(GLuint list)15007 mesa_print_display_list(GLuint list)
15008 {
15009    GET_CURRENT_CONTEXT(ctx);
15010    print_list(ctx, list, NULL);
15011 }
15012 
15013 
15014 /**********************************************************************/
15015 /*****                      Initialization                        *****/
15016 /**********************************************************************/
15017 
15018 void
_mesa_install_dlist_vtxfmt(struct _glapi_table * disp,const GLvertexformat * vfmt)15019 _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
15020                            const GLvertexformat *vfmt)
15021 {
15022    SET_CallList(disp, vfmt->CallList);
15023    SET_CallLists(disp, vfmt->CallLists);
15024 }
15025 
15026 
15027 /**
15028  * Initialize display list state for given context.
15029  */
15030 void
_mesa_init_display_list(struct gl_context * ctx)15031 _mesa_init_display_list(struct gl_context *ctx)
15032 {
15033    static GLboolean tableInitialized = GL_FALSE;
15034    GLvertexformat *vfmt = &ctx->ListState.ListVtxfmt;
15035 
15036    /* zero-out the instruction size table, just once */
15037    if (!tableInitialized) {
15038       memset(InstSize, 0, sizeof(InstSize));
15039       tableInitialized = GL_TRUE;
15040    }
15041 
15042    /* extension info */
15043    ctx->ListExt = CALLOC_STRUCT(gl_list_extensions);
15044 
15045    /* Display list */
15046    ctx->ListState.CallDepth = 0;
15047    ctx->ExecuteFlag = GL_TRUE;
15048    ctx->CompileFlag = GL_FALSE;
15049    ctx->ListState.CurrentBlock = NULL;
15050    ctx->ListState.CurrentPos = 0;
15051 
15052    /* Display List group */
15053    ctx->List.ListBase = 0;
15054 
15055    InstSize[OPCODE_NOP] = 1;
15056 
15057 #define NAME_AE(x) _ae_##x
15058 #define NAME_CALLLIST(x) save_##x
15059 #define NAME(x) save_##x
15060 #define NAME_ES(x) save_##x##ARB
15061 
15062 #include "vbo/vbo_init_tmp.h"
15063 }
15064 
15065 
15066 void
_mesa_free_display_list_data(struct gl_context * ctx)15067 _mesa_free_display_list_data(struct gl_context *ctx)
15068 {
15069    free(ctx->ListExt);
15070    ctx->ListExt = NULL;
15071 }
15072