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 #include "glthread_marshal.h"
67 
68 #include "math/m_matrix.h"
69 
70 #include "main/dispatch.h"
71 
72 #include "vbo/vbo.h"
73 #include "vbo/vbo_util.h"
74 #include "vbo/vbo_save.h"
75 #include "util/format_r11g11b10f.h"
76 #include "util/u_inlines.h"
77 #include "util/u_memory.h"
78 
79 #define USE_BITMAP_ATLAS 1
80 
81 /**
82  * Flush vertices.
83  *
84  * \param ctx GL context.
85  *
86  * Checks if dd_function_table::SaveNeedFlush is marked to flush
87  * stored (save) vertices, and calls vbo_save_SaveFlushVertices if so.
88  */
89 #define SAVE_FLUSH_VERTICES(ctx)                     \
90    do {                                              \
91       if (ctx->Driver.SaveNeedFlush)                 \
92          vbo_save_SaveFlushVertices(ctx);            \
93    } while (0)
94 
95 
96 /**
97  * Macro to assert that the API call was made outside the
98  * glBegin()/glEnd() pair, with return value.
99  *
100  * \param ctx GL context.
101  * \param retval value to return value in case the assertion fails.
102  */
103 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)          \
104    do {                                                                 \
105       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
106          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
107          return retval;                                                 \
108       }                                                                 \
109    } while (0)
110 
111 /**
112  * Macro to assert that the API call was made outside the
113  * glBegin()/glEnd() pair.
114  *
115  * \param ctx GL context.
116  */
117 #define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)                              \
118    do {                                                                 \
119       if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {               \
120          _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
121          return;                                                        \
122       }                                                                 \
123    } while (0)
124 
125 /**
126  * Macro to assert that the API call was made outside the
127  * glBegin()/glEnd() pair and flush the vertices.
128  *
129  * \param ctx GL context.
130  */
131 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                    \
132    do {                                                                 \
133       ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                               \
134       SAVE_FLUSH_VERTICES(ctx);                                         \
135    } while (0)
136 
137 /**
138  * Macro to assert that the API call was made outside the
139  * glBegin()/glEnd() pair and flush the vertices, with return value.
140  *
141  * \param ctx GL context.
142  * \param retval value to return value in case the assertion fails.
143  */
144 #define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
145    do {                                                                 \
146       ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);           \
147       SAVE_FLUSH_VERTICES(ctx);                                         \
148    } while (0)
149 
150 
151 /**
152  * Display list opcodes.
153  */
154 typedef enum
155 {
156    OPCODE_INVALID = -1,         /* Force signed enum */
157    OPCODE_ACCUM,
158    OPCODE_ALPHA_FUNC,
159    OPCODE_BIND_TEXTURE,
160    OPCODE_BITMAP,
161    OPCODE_BLEND_COLOR,
162    OPCODE_BLEND_EQUATION,
163    OPCODE_BLEND_EQUATION_SEPARATE,
164    OPCODE_BLEND_FUNC_SEPARATE,
165 
166    OPCODE_BLEND_EQUATION_I,
167    OPCODE_BLEND_EQUATION_SEPARATE_I,
168    OPCODE_BLEND_FUNC_I,
169    OPCODE_BLEND_FUNC_SEPARATE_I,
170 
171    OPCODE_CALL_LIST,
172    OPCODE_CALL_LISTS,
173    OPCODE_CLEAR,
174    OPCODE_CLEAR_ACCUM,
175    OPCODE_CLEAR_COLOR,
176    OPCODE_CLEAR_DEPTH,
177    OPCODE_CLEAR_INDEX,
178    OPCODE_CLEAR_STENCIL,
179    OPCODE_CLEAR_BUFFER_IV,
180    OPCODE_CLEAR_BUFFER_UIV,
181    OPCODE_CLEAR_BUFFER_FV,
182    OPCODE_CLEAR_BUFFER_FI,
183    OPCODE_CLIP_PLANE,
184    OPCODE_COLOR_MASK,
185    OPCODE_COLOR_MASK_INDEXED,
186    OPCODE_COLOR_MATERIAL,
187    OPCODE_COPY_PIXELS,
188    OPCODE_COPY_TEX_IMAGE1D,
189    OPCODE_COPY_TEX_IMAGE2D,
190    OPCODE_COPY_TEX_SUB_IMAGE1D,
191    OPCODE_COPY_TEX_SUB_IMAGE2D,
192    OPCODE_COPY_TEX_SUB_IMAGE3D,
193    OPCODE_CULL_FACE,
194    OPCODE_DEPTH_FUNC,
195    OPCODE_DEPTH_MASK,
196    OPCODE_DEPTH_RANGE,
197    OPCODE_DISABLE,
198    OPCODE_DISABLE_INDEXED,
199    OPCODE_DRAW_BUFFER,
200    OPCODE_DRAW_PIXELS,
201    OPCODE_ENABLE,
202    OPCODE_ENABLE_INDEXED,
203    OPCODE_EVALMESH1,
204    OPCODE_EVALMESH2,
205    OPCODE_FOG,
206    OPCODE_FRONT_FACE,
207    OPCODE_FRUSTUM,
208    OPCODE_HINT,
209    OPCODE_INDEX_MASK,
210    OPCODE_INIT_NAMES,
211    OPCODE_LIGHT,
212    OPCODE_LIGHT_MODEL,
213    OPCODE_LINE_STIPPLE,
214    OPCODE_LINE_WIDTH,
215    OPCODE_LIST_BASE,
216    OPCODE_LOAD_IDENTITY,
217    OPCODE_LOAD_MATRIX,
218    OPCODE_LOAD_NAME,
219    OPCODE_LOGIC_OP,
220    OPCODE_MAP1,
221    OPCODE_MAP2,
222    OPCODE_MAPGRID1,
223    OPCODE_MAPGRID2,
224    OPCODE_MATRIX_MODE,
225    OPCODE_MULT_MATRIX,
226    OPCODE_ORTHO,
227    OPCODE_PASSTHROUGH,
228    OPCODE_PIXEL_MAP,
229    OPCODE_PIXEL_TRANSFER,
230    OPCODE_PIXEL_ZOOM,
231    OPCODE_POINT_SIZE,
232    OPCODE_POINT_PARAMETERS,
233    OPCODE_POLYGON_MODE,
234    OPCODE_POLYGON_STIPPLE,
235    OPCODE_POLYGON_OFFSET,
236    OPCODE_POP_ATTRIB,
237    OPCODE_POP_MATRIX,
238    OPCODE_POP_NAME,
239    OPCODE_PRIORITIZE_TEXTURE,
240    OPCODE_PUSH_ATTRIB,
241    OPCODE_PUSH_MATRIX,
242    OPCODE_PUSH_NAME,
243    OPCODE_RASTER_POS,
244    OPCODE_READ_BUFFER,
245    OPCODE_ROTATE,
246    OPCODE_SCALE,
247    OPCODE_SCISSOR,
248    OPCODE_SELECT_TEXTURE_SGIS,
249    OPCODE_SELECT_TEXTURE_COORD_SET,
250    OPCODE_SHADE_MODEL,
251    OPCODE_STENCIL_FUNC,
252    OPCODE_STENCIL_MASK,
253    OPCODE_STENCIL_OP,
254    OPCODE_TEXENV,
255    OPCODE_TEXGEN,
256    OPCODE_TEXPARAMETER,
257    OPCODE_TEX_IMAGE1D,
258    OPCODE_TEX_IMAGE2D,
259    OPCODE_TEX_IMAGE3D,
260    OPCODE_TEX_SUB_IMAGE1D,
261    OPCODE_TEX_SUB_IMAGE2D,
262    OPCODE_TEX_SUB_IMAGE3D,
263    OPCODE_TRANSLATE,
264    OPCODE_VIEWPORT,
265    OPCODE_WINDOW_POS,
266    /* ARB_viewport_array */
267    OPCODE_VIEWPORT_ARRAY_V,
268    OPCODE_VIEWPORT_INDEXED_F,
269    OPCODE_VIEWPORT_INDEXED_FV,
270    OPCODE_SCISSOR_ARRAY_V,
271    OPCODE_SCISSOR_INDEXED,
272    OPCODE_SCISSOR_INDEXED_V,
273    OPCODE_DEPTH_ARRAY_V,
274    OPCODE_DEPTH_INDEXED,
275    /* GL_ARB_multitexture */
276    OPCODE_ACTIVE_TEXTURE,
277    /* GL_ARB_texture_compression */
278    OPCODE_COMPRESSED_TEX_IMAGE_1D,
279    OPCODE_COMPRESSED_TEX_IMAGE_2D,
280    OPCODE_COMPRESSED_TEX_IMAGE_3D,
281    OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
282    OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
283    OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
284    /* GL_ARB_multisample */
285    OPCODE_SAMPLE_COVERAGE,
286    /* GL_ARB_window_pos */
287    OPCODE_WINDOW_POS_ARB,
288    /* GL_ARB_vertex_program */
289    OPCODE_BIND_PROGRAM_ARB,
290    OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
291    /* GL_EXT_stencil_two_side */
292    OPCODE_ACTIVE_STENCIL_FACE_EXT,
293    /* GL_EXT_depth_bounds_test */
294    OPCODE_DEPTH_BOUNDS_EXT,
295    /* GL_ARB_vertex/fragment_program */
296    OPCODE_PROGRAM_STRING_ARB,
297    OPCODE_PROGRAM_ENV_PARAMETER_ARB,
298    /* GL_ARB_occlusion_query */
299    OPCODE_BEGIN_QUERY_ARB,
300    OPCODE_END_QUERY_ARB,
301    /* GL_ARB_draw_buffers */
302    OPCODE_DRAW_BUFFERS_ARB,
303    /* GL_ATI_fragment_shader */
304    OPCODE_BIND_FRAGMENT_SHADER_ATI,
305    OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
306    /* OpenGL 2.0 */
307    OPCODE_STENCIL_FUNC_SEPARATE,
308    OPCODE_STENCIL_OP_SEPARATE,
309    OPCODE_STENCIL_MASK_SEPARATE,
310    /* GL_NV_primitive_restart */
311    OPCODE_PRIMITIVE_RESTART_NV,
312    /* GL_ARB_shader_objects */
313    OPCODE_USE_PROGRAM,
314    OPCODE_UNIFORM_1F,
315    OPCODE_UNIFORM_2F,
316    OPCODE_UNIFORM_3F,
317    OPCODE_UNIFORM_4F,
318    OPCODE_UNIFORM_1FV,
319    OPCODE_UNIFORM_2FV,
320    OPCODE_UNIFORM_3FV,
321    OPCODE_UNIFORM_4FV,
322    OPCODE_UNIFORM_1I,
323    OPCODE_UNIFORM_2I,
324    OPCODE_UNIFORM_3I,
325    OPCODE_UNIFORM_4I,
326    OPCODE_UNIFORM_1IV,
327    OPCODE_UNIFORM_2IV,
328    OPCODE_UNIFORM_3IV,
329    OPCODE_UNIFORM_4IV,
330    OPCODE_UNIFORM_MATRIX22,
331    OPCODE_UNIFORM_MATRIX33,
332    OPCODE_UNIFORM_MATRIX44,
333    OPCODE_UNIFORM_MATRIX23,
334    OPCODE_UNIFORM_MATRIX32,
335    OPCODE_UNIFORM_MATRIX24,
336    OPCODE_UNIFORM_MATRIX42,
337    OPCODE_UNIFORM_MATRIX34,
338    OPCODE_UNIFORM_MATRIX43,
339 
340    /* OpenGL 3.0 */
341    OPCODE_UNIFORM_1UI,
342    OPCODE_UNIFORM_2UI,
343    OPCODE_UNIFORM_3UI,
344    OPCODE_UNIFORM_4UI,
345    OPCODE_UNIFORM_1UIV,
346    OPCODE_UNIFORM_2UIV,
347    OPCODE_UNIFORM_3UIV,
348    OPCODE_UNIFORM_4UIV,
349 
350    /* GL_ARB_gpu_shader_fp64 */
351    OPCODE_UNIFORM_1D,
352    OPCODE_UNIFORM_2D,
353    OPCODE_UNIFORM_3D,
354    OPCODE_UNIFORM_4D,
355    OPCODE_UNIFORM_1DV,
356    OPCODE_UNIFORM_2DV,
357    OPCODE_UNIFORM_3DV,
358    OPCODE_UNIFORM_4DV,
359    OPCODE_UNIFORM_MATRIX22D,
360    OPCODE_UNIFORM_MATRIX33D,
361    OPCODE_UNIFORM_MATRIX44D,
362    OPCODE_UNIFORM_MATRIX23D,
363    OPCODE_UNIFORM_MATRIX32D,
364    OPCODE_UNIFORM_MATRIX24D,
365    OPCODE_UNIFORM_MATRIX42D,
366    OPCODE_UNIFORM_MATRIX34D,
367    OPCODE_UNIFORM_MATRIX43D,
368 
369    /* GL_ARB_gpu_shader_int64 */
370    OPCODE_UNIFORM_1I64,
371    OPCODE_UNIFORM_2I64,
372    OPCODE_UNIFORM_3I64,
373    OPCODE_UNIFORM_4I64,
374    OPCODE_UNIFORM_1I64V,
375    OPCODE_UNIFORM_2I64V,
376    OPCODE_UNIFORM_3I64V,
377    OPCODE_UNIFORM_4I64V,
378    OPCODE_UNIFORM_1UI64,
379    OPCODE_UNIFORM_2UI64,
380    OPCODE_UNIFORM_3UI64,
381    OPCODE_UNIFORM_4UI64,
382    OPCODE_UNIFORM_1UI64V,
383    OPCODE_UNIFORM_2UI64V,
384    OPCODE_UNIFORM_3UI64V,
385    OPCODE_UNIFORM_4UI64V,
386    OPCODE_PROGRAM_UNIFORM_1I64,
387    OPCODE_PROGRAM_UNIFORM_2I64,
388    OPCODE_PROGRAM_UNIFORM_3I64,
389    OPCODE_PROGRAM_UNIFORM_4I64,
390    OPCODE_PROGRAM_UNIFORM_1I64V,
391    OPCODE_PROGRAM_UNIFORM_2I64V,
392    OPCODE_PROGRAM_UNIFORM_3I64V,
393    OPCODE_PROGRAM_UNIFORM_4I64V,
394    OPCODE_PROGRAM_UNIFORM_1UI64,
395    OPCODE_PROGRAM_UNIFORM_2UI64,
396    OPCODE_PROGRAM_UNIFORM_3UI64,
397    OPCODE_PROGRAM_UNIFORM_4UI64,
398    OPCODE_PROGRAM_UNIFORM_1UI64V,
399    OPCODE_PROGRAM_UNIFORM_2UI64V,
400    OPCODE_PROGRAM_UNIFORM_3UI64V,
401    OPCODE_PROGRAM_UNIFORM_4UI64V,
402 
403    /* OpenGL 4.0 / GL_ARB_tessellation_shader */
404    OPCODE_PATCH_PARAMETER_I,
405    OPCODE_PATCH_PARAMETER_FV_INNER,
406    OPCODE_PATCH_PARAMETER_FV_OUTER,
407 
408    /* OpenGL 4.2 / GL_ARB_separate_shader_objects */
409    OPCODE_USE_PROGRAM_STAGES,
410    OPCODE_PROGRAM_UNIFORM_1F,
411    OPCODE_PROGRAM_UNIFORM_2F,
412    OPCODE_PROGRAM_UNIFORM_3F,
413    OPCODE_PROGRAM_UNIFORM_4F,
414    OPCODE_PROGRAM_UNIFORM_1FV,
415    OPCODE_PROGRAM_UNIFORM_2FV,
416    OPCODE_PROGRAM_UNIFORM_3FV,
417    OPCODE_PROGRAM_UNIFORM_4FV,
418    OPCODE_PROGRAM_UNIFORM_1D,
419    OPCODE_PROGRAM_UNIFORM_2D,
420    OPCODE_PROGRAM_UNIFORM_3D,
421    OPCODE_PROGRAM_UNIFORM_4D,
422    OPCODE_PROGRAM_UNIFORM_1DV,
423    OPCODE_PROGRAM_UNIFORM_2DV,
424    OPCODE_PROGRAM_UNIFORM_3DV,
425    OPCODE_PROGRAM_UNIFORM_4DV,
426    OPCODE_PROGRAM_UNIFORM_1I,
427    OPCODE_PROGRAM_UNIFORM_2I,
428    OPCODE_PROGRAM_UNIFORM_3I,
429    OPCODE_PROGRAM_UNIFORM_4I,
430    OPCODE_PROGRAM_UNIFORM_1IV,
431    OPCODE_PROGRAM_UNIFORM_2IV,
432    OPCODE_PROGRAM_UNIFORM_3IV,
433    OPCODE_PROGRAM_UNIFORM_4IV,
434    OPCODE_PROGRAM_UNIFORM_1UI,
435    OPCODE_PROGRAM_UNIFORM_2UI,
436    OPCODE_PROGRAM_UNIFORM_3UI,
437    OPCODE_PROGRAM_UNIFORM_4UI,
438    OPCODE_PROGRAM_UNIFORM_1UIV,
439    OPCODE_PROGRAM_UNIFORM_2UIV,
440    OPCODE_PROGRAM_UNIFORM_3UIV,
441    OPCODE_PROGRAM_UNIFORM_4UIV,
442    OPCODE_PROGRAM_UNIFORM_MATRIX22F,
443    OPCODE_PROGRAM_UNIFORM_MATRIX33F,
444    OPCODE_PROGRAM_UNIFORM_MATRIX44F,
445    OPCODE_PROGRAM_UNIFORM_MATRIX23F,
446    OPCODE_PROGRAM_UNIFORM_MATRIX32F,
447    OPCODE_PROGRAM_UNIFORM_MATRIX24F,
448    OPCODE_PROGRAM_UNIFORM_MATRIX42F,
449    OPCODE_PROGRAM_UNIFORM_MATRIX34F,
450    OPCODE_PROGRAM_UNIFORM_MATRIX43F,
451    OPCODE_PROGRAM_UNIFORM_MATRIX22D,
452    OPCODE_PROGRAM_UNIFORM_MATRIX33D,
453    OPCODE_PROGRAM_UNIFORM_MATRIX44D,
454    OPCODE_PROGRAM_UNIFORM_MATRIX23D,
455    OPCODE_PROGRAM_UNIFORM_MATRIX32D,
456    OPCODE_PROGRAM_UNIFORM_MATRIX24D,
457    OPCODE_PROGRAM_UNIFORM_MATRIX42D,
458    OPCODE_PROGRAM_UNIFORM_MATRIX34D,
459    OPCODE_PROGRAM_UNIFORM_MATRIX43D,
460 
461    /* GL_ARB_clip_control */
462    OPCODE_CLIP_CONTROL,
463 
464    /* GL_ARB_color_buffer_float */
465    OPCODE_CLAMP_COLOR,
466 
467    /* GL_EXT_framebuffer_blit */
468    OPCODE_BLIT_FRAMEBUFFER,
469 
470    /* Vertex attributes -- fallback for when optimized display
471     * list build isn't active.
472     */
473    OPCODE_ATTR_1F_NV,
474    OPCODE_ATTR_2F_NV,
475    OPCODE_ATTR_3F_NV,
476    OPCODE_ATTR_4F_NV,
477    OPCODE_ATTR_1F_ARB,
478    OPCODE_ATTR_2F_ARB,
479    OPCODE_ATTR_3F_ARB,
480    OPCODE_ATTR_4F_ARB,
481    OPCODE_ATTR_1I,
482    OPCODE_ATTR_2I,
483    OPCODE_ATTR_3I,
484    OPCODE_ATTR_4I,
485    OPCODE_ATTR_1D,
486    OPCODE_ATTR_2D,
487    OPCODE_ATTR_3D,
488    OPCODE_ATTR_4D,
489    OPCODE_ATTR_1UI64,
490    OPCODE_MATERIAL,
491    OPCODE_BEGIN,
492    OPCODE_END,
493    OPCODE_EVAL_C1,
494    OPCODE_EVAL_C2,
495    OPCODE_EVAL_P1,
496    OPCODE_EVAL_P2,
497 
498    /* GL_EXT_provoking_vertex */
499    OPCODE_PROVOKING_VERTEX,
500 
501    /* GL_EXT_transform_feedback */
502    OPCODE_BEGIN_TRANSFORM_FEEDBACK,
503    OPCODE_END_TRANSFORM_FEEDBACK,
504    OPCODE_BIND_TRANSFORM_FEEDBACK,
505    OPCODE_PAUSE_TRANSFORM_FEEDBACK,
506    OPCODE_RESUME_TRANSFORM_FEEDBACK,
507    OPCODE_DRAW_TRANSFORM_FEEDBACK,
508 
509    /* GL_EXT_texture_integer */
510    OPCODE_CLEARCOLOR_I,
511    OPCODE_CLEARCOLOR_UI,
512    OPCODE_TEXPARAMETER_I,
513    OPCODE_TEXPARAMETER_UI,
514 
515    /* GL_ARB_instanced_arrays */
516    OPCODE_VERTEX_ATTRIB_DIVISOR,
517 
518    /* GL_NV_texture_barrier */
519    OPCODE_TEXTURE_BARRIER_NV,
520 
521    /* GL_ARB_sampler_object */
522    OPCODE_BIND_SAMPLER,
523    OPCODE_SAMPLER_PARAMETERIV,
524    OPCODE_SAMPLER_PARAMETERFV,
525    OPCODE_SAMPLER_PARAMETERIIV,
526    OPCODE_SAMPLER_PARAMETERUIV,
527 
528    /* ARB_compute_shader */
529    OPCODE_DISPATCH_COMPUTE,
530 
531    /* GL_ARB_sync */
532    OPCODE_WAIT_SYNC,
533 
534    /* GL_NV_conditional_render */
535    OPCODE_BEGIN_CONDITIONAL_RENDER,
536    OPCODE_END_CONDITIONAL_RENDER,
537 
538    /* ARB_timer_query */
539    OPCODE_QUERY_COUNTER,
540 
541    /* ARB_transform_feedback3 */
542    OPCODE_BEGIN_QUERY_INDEXED,
543    OPCODE_END_QUERY_INDEXED,
544    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM,
545 
546    /* ARB_transform_feedback_instanced */
547    OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED,
548    OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED,
549 
550    /* ARB_uniform_buffer_object */
551    OPCODE_UNIFORM_BLOCK_BINDING,
552 
553    /* ARB_shader_subroutines */
554    OPCODE_UNIFORM_SUBROUTINES,
555 
556    /* EXT_polygon_offset_clamp */
557    OPCODE_POLYGON_OFFSET_CLAMP,
558 
559    /* EXT_window_rectangles */
560    OPCODE_WINDOW_RECTANGLES,
561 
562    /* NV_conservative_raster */
563    OPCODE_SUBPIXEL_PRECISION_BIAS,
564 
565    /* NV_conservative_raster_dilate */
566    OPCODE_CONSERVATIVE_RASTER_PARAMETER_F,
567 
568    /* NV_conservative_raster_pre_snap_triangles */
569    OPCODE_CONSERVATIVE_RASTER_PARAMETER_I,
570 
571    /* EXT_direct_state_access */
572    OPCODE_MATRIX_LOAD,
573    OPCODE_MATRIX_MULT,
574    OPCODE_MATRIX_ROTATE,
575    OPCODE_MATRIX_SCALE,
576    OPCODE_MATRIX_TRANSLATE,
577    OPCODE_MATRIX_LOAD_IDENTITY,
578    OPCODE_MATRIX_ORTHO,
579    OPCODE_MATRIX_FRUSTUM,
580    OPCODE_MATRIX_PUSH,
581    OPCODE_MATRIX_POP,
582    OPCODE_TEXTUREPARAMETER_F,
583    OPCODE_TEXTUREPARAMETER_I,
584    OPCODE_TEXTUREPARAMETER_II,
585    OPCODE_TEXTUREPARAMETER_IUI,
586    OPCODE_TEXTURE_IMAGE1D,
587    OPCODE_TEXTURE_IMAGE2D,
588    OPCODE_TEXTURE_IMAGE3D,
589    OPCODE_TEXTURE_SUB_IMAGE1D,
590    OPCODE_TEXTURE_SUB_IMAGE2D,
591    OPCODE_TEXTURE_SUB_IMAGE3D,
592    OPCODE_COPY_TEXTURE_IMAGE1D,
593    OPCODE_COPY_TEXTURE_IMAGE2D,
594    OPCODE_COPY_TEXTURE_SUB_IMAGE1D,
595    OPCODE_COPY_TEXTURE_SUB_IMAGE2D,
596    OPCODE_COPY_TEXTURE_SUB_IMAGE3D,
597    OPCODE_BIND_MULTITEXTURE,
598    OPCODE_MULTITEXPARAMETER_F,
599    OPCODE_MULTITEXPARAMETER_I,
600    OPCODE_MULTITEXPARAMETER_II,
601    OPCODE_MULTITEXPARAMETER_IUI,
602    OPCODE_MULTITEX_IMAGE1D,
603    OPCODE_MULTITEX_IMAGE2D,
604    OPCODE_MULTITEX_IMAGE3D,
605    OPCODE_MULTITEX_SUB_IMAGE1D,
606    OPCODE_MULTITEX_SUB_IMAGE2D,
607    OPCODE_MULTITEX_SUB_IMAGE3D,
608    OPCODE_COPY_MULTITEX_IMAGE1D,
609    OPCODE_COPY_MULTITEX_IMAGE2D,
610    OPCODE_COPY_MULTITEX_SUB_IMAGE1D,
611    OPCODE_COPY_MULTITEX_SUB_IMAGE2D,
612    OPCODE_COPY_MULTITEX_SUB_IMAGE3D,
613    OPCODE_MULTITEXENV,
614    OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
615    OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
616    OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
617    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
618    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
619    OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
620    OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
621    OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
622    OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
623    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
624    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
625    OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
626    OPCODE_NAMED_PROGRAM_STRING,
627    OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER,
628 
629    /* GL_ARB_ES3_2_compatibility */
630    OPCODE_PRIMITIVE_BOUNDING_BOX,
631 
632    OPCODE_VERTEX_LIST,
633    OPCODE_VERTEX_LIST_LOOPBACK,
634    OPCODE_VERTEX_LIST_COPY_CURRENT,
635 
636    /* The following three are meta instructions */
637    OPCODE_ERROR,                /* raise compiled-in error */
638    OPCODE_CONTINUE,
639    OPCODE_NOP,                  /* No-op (used for 8-byte alignment */
640    OPCODE_END_OF_LIST
641 } OpCode;
642 
643 
644 
645 /**
646  * Display list node.
647  *
648  * Display list instructions are stored as sequences of "nodes".  Nodes
649  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
650  * are linked together with a pointer.
651  *
652  * Each instruction in the display list is stored as a sequence of
653  * contiguous nodes in memory.
654  * Each node is the union of a variety of data types.
655  *
656  * Note, all of these members should be 4 bytes in size or less for the
657  * sake of compact display lists.  We store 8-byte pointers in a pair of
658  * these nodes using the save/get_pointer() functions below.
659  */
660 union gl_dlist_node
661 {
662    struct {
663 #if !DETECT_OS_WINDOWS
664       OpCode opcode:16;
665 #else
666       /* sizeof(Node) is 8 with MSVC/mingw, so use an explicit 16 bits type. */
667       uint16_t opcode;
668 #endif
669       uint16_t InstSize;
670    };
671    GLboolean b;
672    GLbitfield bf;
673    GLubyte ub;
674    GLshort s;
675    GLushort us;
676    GLint i;
677    GLuint ui;
678    GLenum e;
679    GLfloat f;
680    GLsizei si;
681 };
682 
683 
684 typedef union gl_dlist_node Node;
685 
686 
687 /** How many 4-byte dwords to store a pointer */
688 #define POINTER_DWORDS (sizeof(void *) / 4)
689 
690 /* We want to keep sizeof(union gl_dlist_node) == 4 to minimize
691  * space for display lists.  The following types and functions are
692  * used to help store 4- and 8-byte pointers in 1 or 2 dlist_nodes.
693  */
694 union pointer
695 {
696    void *ptr;
697    GLuint dwords[POINTER_DWORDS];
698 };
699 
700 
701 /**
702  * Save a 4 or 8-byte pointer at dest (and dest+1).
703  */
704 static inline void
save_pointer(Node * dest,void * src)705 save_pointer(Node *dest, void *src)
706 {
707    union pointer p;
708    unsigned i;
709 
710    STATIC_ASSERT(POINTER_DWORDS == 1 || POINTER_DWORDS == 2);
711    STATIC_ASSERT(sizeof(Node) == 4);
712 
713    p.ptr = src;
714 
715    for (i = 0; i < POINTER_DWORDS; i++)
716       dest[i].ui = p.dwords[i];
717 }
718 
719 
720 /**
721  * Retrieve a 4 or 8-byte pointer from node (node+1).
722  */
723 static inline void *
get_pointer(const Node * node)724 get_pointer(const Node *node)
725 {
726    union pointer p;
727    unsigned i;
728 
729    for (i = 0; i < POINTER_DWORDS; i++)
730       p.dwords[i] = node[i].ui;
731 
732    return p.ptr;
733 }
734 
735 
736 /**
737  * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit
738  * environment.
739  */
740 union uint64_pair
741 {
742    GLuint64 uint64;
743    GLuint uint32[2];
744 };
745 
746 
747 union float64_pair
748 {
749    GLdouble d;
750    GLuint uint32[2];
751 };
752 
753 union int64_pair
754 {
755    GLint64 int64;
756    GLint int32[2];
757 };
758 
759 #define ASSIGN_DOUBLE_TO_NODES(n, idx, value)                              \
760    do {                                                                    \
761       union float64_pair tmp;                                              \
762       tmp.d = value;                                                       \
763       n[idx].ui = tmp.uint32[0];                                           \
764       n[idx+1].ui = tmp.uint32[1];                                         \
765    } while (0)
766 
767 #define ASSIGN_UINT64_TO_NODES(n, idx, value)                              \
768    do {                                                                    \
769       union uint64_pair tmp;                                               \
770       tmp.uint64 = value;                                                  \
771       n[idx].ui = tmp.uint32[0];                                           \
772       n[idx+1].ui = tmp.uint32[1];                                         \
773    } while (0)
774 
775 #define ASSIGN_INT64_TO_NODES(n, idx, value)                               \
776    do {                                                                    \
777       union int64_pair tmp;                                                \
778       tmp.int64 = value;                                                   \
779       n[idx].i = tmp.int32[0];                                             \
780       n[idx+1].i = tmp.int32[1];                                           \
781    } while (0)
782 
783 /**
784  * How many nodes to allocate at a time.  Note that bulk vertex data
785  * from glBegin/glVertex/glEnd primitives will typically wind up in
786  * a VBO, and not directly in the display list itself.
787  */
788 #define BLOCK_SIZE 256
789 
790 
791 void mesa_print_display_list(GLuint list);
792 
793 
794 /**
795  * Called by display list code when a display list is being deleted.
796  */
797 static void
vbo_destroy_vertex_list(struct gl_context * ctx,struct vbo_save_vertex_list * node)798 vbo_destroy_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node)
799 {
800    for (gl_vertex_processing_mode mode = VP_MODE_FF; mode < VP_MODE_MAX; ++mode) {
801       _mesa_reference_vao(ctx, &node->VAO[mode], NULL);
802       if (node->merged.gallium.private_refcount[mode]) {
803          assert(node->merged.gallium.private_refcount[mode] > 0);
804          p_atomic_add(&node->merged.gallium.state[mode]->reference.count,
805                       -node->merged.gallium.private_refcount[mode]);
806       }
807       pipe_vertex_state_reference(&node->merged.gallium.state[mode], NULL);
808    }
809 
810    if (node->merged.mode) {
811       free(node->merged.mode);
812       free(node->merged.start_counts);
813    }
814 
815    _mesa_reference_buffer_object(ctx, &node->cold->ib.obj, NULL);
816    free(node->cold->current_data);
817    node->cold->current_data = NULL;
818 
819    free(node->cold->prims);
820    free(node->cold);
821 }
822 
823 static void
vbo_print_vertex_list(struct gl_context * ctx,struct vbo_save_vertex_list * node,OpCode op,FILE * f)824 vbo_print_vertex_list(struct gl_context *ctx, struct vbo_save_vertex_list *node, OpCode op, FILE *f)
825 {
826    GLuint i;
827    struct gl_buffer_object *buffer = node->VAO[0]->BufferBinding[0].BufferObj;
828    const GLuint vertex_size = _vbo_save_get_stride(node)/sizeof(GLfloat);
829    (void) ctx;
830 
831    const char *label[] = {
832       "VBO-VERTEX-LIST", "VBO-VERTEX-LIST-LOOPBACK", "VBO-VERTEX-LIST-COPY-CURRENT"
833    };
834 
835    fprintf(f, "%s, %u vertices, %d primitives, %d vertsize, "
836            "buffer %p\n",
837            label[op - OPCODE_VERTEX_LIST],
838            node->cold->vertex_count, node->cold->prim_count, vertex_size,
839            buffer);
840 
841    for (i = 0; i < node->cold->prim_count; i++) {
842       struct _mesa_prim *prim = &node->cold->prims[i];
843       fprintf(f, "   prim %d: %s %d..%d %s %s\n",
844              i,
845              _mesa_lookup_prim_by_nr(prim->mode),
846              prim->start,
847              prim->start + prim->count,
848              (prim->begin) ? "BEGIN" : "(wrap)",
849              (prim->end) ? "END" : "(wrap)");
850    }
851 }
852 
853 
854 static inline
get_list_head(struct gl_context * ctx,struct gl_display_list * dlist)855 Node *get_list_head(struct gl_context *ctx, struct gl_display_list *dlist)
856 {
857    return dlist->small_list ?
858       &ctx->Shared->small_dlist_store.ptr[dlist->start] :
859       dlist->Head;
860 }
861 
862 
863 /**
864  * Does the given display list only contain a single glBitmap call?
865  */
866 static bool
is_bitmap_list(struct gl_context * ctx,struct gl_display_list * dlist)867 is_bitmap_list(struct gl_context *ctx, struct gl_display_list *dlist)
868 {
869    Node *n = get_list_head(ctx, dlist);
870    if (n[0].opcode == OPCODE_BITMAP) {
871       n += n[0].InstSize;
872       if (n[0].opcode == OPCODE_END_OF_LIST)
873          return true;
874    }
875    return false;
876 }
877 
878 
879 /**
880  * Is the given display list an empty list?
881  */
882 static bool
is_empty_list(struct gl_context * ctx,struct gl_display_list * dlist)883 is_empty_list(struct gl_context *ctx, struct gl_display_list *dlist)
884 {
885    Node *n = get_list_head(ctx, dlist);
886    return n[0].opcode == OPCODE_END_OF_LIST;
887 }
888 
889 
890 /**
891  * Delete/free a gl_bitmap_atlas.  Called during context tear-down.
892  */
893 void
_mesa_delete_bitmap_atlas(struct gl_context * ctx,struct gl_bitmap_atlas * atlas)894 _mesa_delete_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas)
895 {
896    if (atlas->texObj) {
897       ctx->Driver.DeleteTexture(ctx, atlas->texObj);
898    }
899    free(atlas->glyphs);
900    free(atlas);
901 }
902 
903 
904 /**
905  * Lookup a gl_bitmap_atlas by listBase ID.
906  */
907 static struct gl_bitmap_atlas *
lookup_bitmap_atlas(struct gl_context * ctx,GLuint listBase)908 lookup_bitmap_atlas(struct gl_context *ctx, GLuint listBase)
909 {
910    struct gl_bitmap_atlas *atlas;
911 
912    assert(listBase > 0);
913    atlas = _mesa_HashLookup(ctx->Shared->BitmapAtlas, listBase);
914    return atlas;
915 }
916 
917 
918 /**
919  * Create new bitmap atlas and insert into hash table.
920  */
921 static struct gl_bitmap_atlas *
alloc_bitmap_atlas(struct gl_context * ctx,GLuint listBase,bool isGenName)922 alloc_bitmap_atlas(struct gl_context *ctx, GLuint listBase, bool isGenName)
923 {
924    struct gl_bitmap_atlas *atlas;
925 
926    assert(listBase > 0);
927    assert(_mesa_HashLookup(ctx->Shared->BitmapAtlas, listBase) == NULL);
928 
929    atlas = calloc(1, sizeof(*atlas));
930    if (atlas) {
931       _mesa_HashInsert(ctx->Shared->BitmapAtlas, listBase, atlas, isGenName);
932       atlas->Id = listBase;
933    }
934 
935    return atlas;
936 }
937 
938 
939 /**
940  * Try to build a bitmap atlas.  This involves examining a sequence of
941  * display lists which contain glBitmap commands and putting the bitmap
942  * images into a texture map (the atlas).
943  * If we succeed, gl_bitmap_atlas::complete will be set to true.
944  * If we fail, gl_bitmap_atlas::incomplete will be set to true.
945  */
946 static void
build_bitmap_atlas(struct gl_context * ctx,struct gl_bitmap_atlas * atlas,GLuint listBase)947 build_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas,
948                    GLuint listBase)
949 {
950    unsigned i, row_height = 0, xpos = 0, ypos = 0;
951    GLubyte *map;
952    GLint map_stride;
953 
954    assert(atlas);
955    assert(!atlas->complete);
956    assert(atlas->numBitmaps > 0);
957 
958    /* We use a rectangle texture (non-normalized coords) for the atlas */
959    assert(ctx->Extensions.NV_texture_rectangle);
960    assert(ctx->Const.MaxTextureRectSize >= 1024);
961 
962    atlas->texWidth = 1024;
963    atlas->texHeight = 0;  /* determined below */
964 
965    atlas->glyphs = malloc(atlas->numBitmaps * sizeof(atlas->glyphs[0]));
966    if (!atlas->glyphs) {
967       /* give up */
968       atlas->incomplete = true;
969       return;
970    }
971 
972    /* Loop over the display lists.  They should all contain a single glBitmap
973     * call.  If not, bail out.  Also, compute the position and sizes of each
974     * bitmap in the atlas to determine the texture atlas size.
975     */
976    for (i = 0; i < atlas->numBitmaps; i++) {
977       struct gl_display_list *list = _mesa_lookup_list(ctx, listBase + i, true);
978       const Node *n;
979       struct gl_bitmap_glyph *g = &atlas->glyphs[i];
980       unsigned bitmap_width, bitmap_height;
981       float bitmap_xmove, bitmap_ymove, bitmap_xorig, bitmap_yorig;
982 
983       if (!list || is_empty_list(ctx, list)) {
984          /* stop here */
985          atlas->numBitmaps = i;
986          break;
987       }
988 
989       if (!is_bitmap_list(ctx, list)) {
990          /* This list does not contain exactly one glBitmap command. Give up. */
991          atlas->incomplete = true;
992          return;
993       }
994 
995       /* get bitmap info from the display list command */
996       n = get_list_head(ctx, list);
997       assert(n[0].opcode == OPCODE_BITMAP);
998       bitmap_width = n[1].i;
999       bitmap_height = n[2].i;
1000       bitmap_xorig = n[3].f;
1001       bitmap_yorig = n[4].f;
1002       bitmap_xmove = n[5].f;
1003       bitmap_ymove = n[6].f;
1004 
1005       if (xpos + bitmap_width > atlas->texWidth) {
1006          /* advance to the next row of the texture */
1007          xpos = 0;
1008          ypos += row_height;
1009          row_height = 0;
1010       }
1011 
1012       /* save the bitmap's position in the atlas */
1013       g->x = xpos;
1014       g->y = ypos;
1015       g->w = bitmap_width;
1016       g->h = bitmap_height;
1017       g->xorig = bitmap_xorig;
1018       g->yorig = bitmap_yorig;
1019       g->xmove = bitmap_xmove;
1020       g->ymove = bitmap_ymove;
1021 
1022       xpos += bitmap_width;
1023 
1024       /* keep track of tallest bitmap in the row */
1025       row_height = MAX2(row_height, bitmap_height);
1026    }
1027 
1028    /* Now we know the texture height */
1029    atlas->texHeight = ypos + row_height;
1030 
1031    if (atlas->texHeight == 0) {
1032       /* no glyphs found, give up */
1033       goto fail;
1034    }
1035    else if (atlas->texHeight > ctx->Const.MaxTextureRectSize) {
1036       /* too large, give up */
1037       goto fail;
1038    }
1039 
1040    /* Create atlas texture (texture ID is irrelevant) */
1041    atlas->texObj = ctx->Driver.NewTextureObject(ctx, 999, GL_TEXTURE_RECTANGLE);
1042    if (!atlas->texObj) {
1043       goto out_of_memory;
1044    }
1045 
1046    atlas->texObj->Sampler.Attrib.MinFilter = GL_NEAREST;
1047    atlas->texObj->Sampler.Attrib.MagFilter = GL_NEAREST;
1048    atlas->texObj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
1049    atlas->texObj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
1050    atlas->texObj->Sampler.Attrib.state.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
1051    atlas->texObj->Attrib.MaxLevel = 0;
1052    atlas->texObj->Immutable = GL_TRUE;
1053 
1054    atlas->texImage = _mesa_get_tex_image(ctx, atlas->texObj,
1055                                          GL_TEXTURE_RECTANGLE, 0);
1056    if (!atlas->texImage) {
1057       goto out_of_memory;
1058    }
1059 
1060    if (ctx->Const.BitmapUsesRed)
1061       _mesa_init_teximage_fields(ctx, atlas->texImage,
1062                                  atlas->texWidth, atlas->texHeight, 1, 0,
1063                                  GL_RED, MESA_FORMAT_R_UNORM8);
1064    else
1065       _mesa_init_teximage_fields(ctx, atlas->texImage,
1066                                  atlas->texWidth, atlas->texHeight, 1, 0,
1067                                  GL_ALPHA, MESA_FORMAT_A_UNORM8);
1068 
1069    /* alloc image storage */
1070    if (!ctx->Driver.AllocTextureImageBuffer(ctx, atlas->texImage)) {
1071       goto out_of_memory;
1072    }
1073 
1074    /* map teximage, load with bitmap glyphs */
1075    ctx->Driver.MapTextureImage(ctx, atlas->texImage, 0,
1076                                0, 0, atlas->texWidth, atlas->texHeight,
1077                                GL_MAP_WRITE_BIT, &map, &map_stride);
1078    if (!map) {
1079       goto out_of_memory;
1080    }
1081 
1082    /* Background/clear pixels are 0xff, foreground/set pixels are 0x0 */
1083    memset(map, 0xff, map_stride * atlas->texHeight);
1084 
1085    for (i = 0; i < atlas->numBitmaps; i++) {
1086       struct gl_display_list *list = _mesa_lookup_list(ctx, listBase + i, true);
1087       const Node *n = get_list_head(ctx, list);
1088 
1089       assert(n[0].opcode == OPCODE_BITMAP ||
1090              n[0].opcode == OPCODE_END_OF_LIST);
1091 
1092       if (n[0].opcode == OPCODE_BITMAP) {
1093          unsigned bitmap_width = n[1].i;
1094          unsigned bitmap_height = n[2].i;
1095          unsigned xpos = atlas->glyphs[i].x;
1096          unsigned ypos = atlas->glyphs[i].y;
1097          const void *bitmap_image = get_pointer(&n[7]);
1098 
1099          assert(atlas->glyphs[i].w == bitmap_width);
1100          assert(atlas->glyphs[i].h == bitmap_height);
1101 
1102          /* put the bitmap image into the texture image */
1103          _mesa_expand_bitmap(bitmap_width, bitmap_height,
1104                              &ctx->DefaultPacking, bitmap_image,
1105                              map + map_stride * ypos + xpos, /* dest addr */
1106                              map_stride, 0x0);
1107       }
1108    }
1109 
1110    ctx->Driver.UnmapTextureImage(ctx, atlas->texImage, 0);
1111 
1112    atlas->complete = true;
1113 
1114    return;
1115 
1116 out_of_memory:
1117    _mesa_error(ctx, GL_OUT_OF_MEMORY, "Display list bitmap atlas");
1118 fail:
1119    if (atlas->texObj) {
1120       ctx->Driver.DeleteTexture(ctx, atlas->texObj);
1121    }
1122    free(atlas->glyphs);
1123    atlas->glyphs = NULL;
1124    atlas->incomplete = true;
1125 }
1126 
1127 
1128 /**
1129  * Allocate a gl_display_list object with an initial block of storage.
1130  * \param count  how many display list nodes/tokens to allocate
1131  */
1132 static struct gl_display_list *
make_list(GLuint name,GLuint count)1133 make_list(GLuint name, GLuint count)
1134 {
1135    struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
1136    dlist->Name = name;
1137    dlist->Head = malloc(sizeof(Node) * count);
1138    dlist->Head[0].opcode = OPCODE_END_OF_LIST;
1139    return dlist;
1140 }
1141 
1142 
1143 /**
1144  * Lookup function to just encapsulate casting.
1145  */
1146 struct gl_display_list *
_mesa_lookup_list(struct gl_context * ctx,GLuint list,bool locked)1147 _mesa_lookup_list(struct gl_context *ctx, GLuint list, bool locked)
1148 {
1149    return (struct gl_display_list *)
1150       _mesa_HashLookupMaybeLocked(ctx->Shared->DisplayList, list, locked);
1151 }
1152 
1153 
1154 /**
1155  * Delete the named display list, but don't remove from hash table.
1156  * \param dlist - display list pointer
1157  */
1158 void
_mesa_delete_list(struct gl_context * ctx,struct gl_display_list * dlist)1159 _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
1160 {
1161    Node *n, *block;
1162 
1163    n = block = get_list_head(ctx, dlist);
1164 
1165    if (!n) {
1166       free(dlist->Label);
1167       free(dlist);
1168       return;
1169    }
1170 
1171    while (1) {
1172       const OpCode opcode = n[0].opcode;
1173 
1174       switch (opcode) {
1175             /* for some commands, we need to free malloc'd memory */
1176          case OPCODE_MAP1:
1177             free(get_pointer(&n[6]));
1178             break;
1179          case OPCODE_MAP2:
1180             free(get_pointer(&n[10]));
1181             break;
1182          case OPCODE_CALL_LISTS:
1183             free(get_pointer(&n[3]));
1184             break;
1185          case OPCODE_DRAW_PIXELS:
1186             free(get_pointer(&n[5]));
1187             break;
1188          case OPCODE_BITMAP:
1189             free(get_pointer(&n[7]));
1190             break;
1191          case OPCODE_POLYGON_STIPPLE:
1192             free(get_pointer(&n[1]));
1193             break;
1194          case OPCODE_TEX_IMAGE1D:
1195             free(get_pointer(&n[8]));
1196             break;
1197          case OPCODE_TEX_IMAGE2D:
1198             free(get_pointer(&n[9]));
1199             break;
1200          case OPCODE_TEX_IMAGE3D:
1201             free(get_pointer(&n[10]));
1202             break;
1203          case OPCODE_TEX_SUB_IMAGE1D:
1204             free(get_pointer(&n[7]));
1205             break;
1206          case OPCODE_TEX_SUB_IMAGE2D:
1207             free(get_pointer(&n[9]));
1208             break;
1209          case OPCODE_TEX_SUB_IMAGE3D:
1210             free(get_pointer(&n[11]));
1211             break;
1212          case OPCODE_COMPRESSED_TEX_IMAGE_1D:
1213             free(get_pointer(&n[7]));
1214             break;
1215          case OPCODE_COMPRESSED_TEX_IMAGE_2D:
1216             free(get_pointer(&n[8]));
1217             break;
1218          case OPCODE_COMPRESSED_TEX_IMAGE_3D:
1219             free(get_pointer(&n[9]));
1220             break;
1221          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
1222             free(get_pointer(&n[7]));
1223             break;
1224          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
1225             free(get_pointer(&n[9]));
1226             break;
1227          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
1228             free(get_pointer(&n[11]));
1229             break;
1230          case OPCODE_PROGRAM_STRING_ARB:
1231             free(get_pointer(&n[4]));      /* program string */
1232             break;
1233          case OPCODE_UNIFORM_1FV:
1234          case OPCODE_UNIFORM_2FV:
1235          case OPCODE_UNIFORM_3FV:
1236          case OPCODE_UNIFORM_4FV:
1237          case OPCODE_UNIFORM_1DV:
1238          case OPCODE_UNIFORM_2DV:
1239          case OPCODE_UNIFORM_3DV:
1240          case OPCODE_UNIFORM_4DV:
1241          case OPCODE_UNIFORM_1IV:
1242          case OPCODE_UNIFORM_2IV:
1243          case OPCODE_UNIFORM_3IV:
1244          case OPCODE_UNIFORM_4IV:
1245          case OPCODE_UNIFORM_1UIV:
1246          case OPCODE_UNIFORM_2UIV:
1247          case OPCODE_UNIFORM_3UIV:
1248          case OPCODE_UNIFORM_4UIV:
1249          case OPCODE_UNIFORM_1I64V:
1250          case OPCODE_UNIFORM_2I64V:
1251          case OPCODE_UNIFORM_3I64V:
1252          case OPCODE_UNIFORM_4I64V:
1253          case OPCODE_UNIFORM_1UI64V:
1254          case OPCODE_UNIFORM_2UI64V:
1255          case OPCODE_UNIFORM_3UI64V:
1256          case OPCODE_UNIFORM_4UI64V:
1257             free(get_pointer(&n[3]));
1258             break;
1259          case OPCODE_UNIFORM_MATRIX22:
1260          case OPCODE_UNIFORM_MATRIX33:
1261          case OPCODE_UNIFORM_MATRIX44:
1262          case OPCODE_UNIFORM_MATRIX24:
1263          case OPCODE_UNIFORM_MATRIX42:
1264          case OPCODE_UNIFORM_MATRIX23:
1265          case OPCODE_UNIFORM_MATRIX32:
1266          case OPCODE_UNIFORM_MATRIX34:
1267          case OPCODE_UNIFORM_MATRIX43:
1268          case OPCODE_UNIFORM_MATRIX22D:
1269          case OPCODE_UNIFORM_MATRIX33D:
1270          case OPCODE_UNIFORM_MATRIX44D:
1271          case OPCODE_UNIFORM_MATRIX24D:
1272          case OPCODE_UNIFORM_MATRIX42D:
1273          case OPCODE_UNIFORM_MATRIX23D:
1274          case OPCODE_UNIFORM_MATRIX32D:
1275          case OPCODE_UNIFORM_MATRIX34D:
1276          case OPCODE_UNIFORM_MATRIX43D:
1277             free(get_pointer(&n[4]));
1278             break;
1279          case OPCODE_PROGRAM_UNIFORM_1FV:
1280          case OPCODE_PROGRAM_UNIFORM_2FV:
1281          case OPCODE_PROGRAM_UNIFORM_3FV:
1282          case OPCODE_PROGRAM_UNIFORM_4FV:
1283          case OPCODE_PROGRAM_UNIFORM_1DV:
1284          case OPCODE_PROGRAM_UNIFORM_2DV:
1285          case OPCODE_PROGRAM_UNIFORM_3DV:
1286          case OPCODE_PROGRAM_UNIFORM_4DV:
1287          case OPCODE_PROGRAM_UNIFORM_1IV:
1288          case OPCODE_PROGRAM_UNIFORM_2IV:
1289          case OPCODE_PROGRAM_UNIFORM_3IV:
1290          case OPCODE_PROGRAM_UNIFORM_4IV:
1291          case OPCODE_PROGRAM_UNIFORM_1UIV:
1292          case OPCODE_PROGRAM_UNIFORM_2UIV:
1293          case OPCODE_PROGRAM_UNIFORM_3UIV:
1294          case OPCODE_PROGRAM_UNIFORM_4UIV:
1295          case OPCODE_PROGRAM_UNIFORM_1I64V:
1296          case OPCODE_PROGRAM_UNIFORM_2I64V:
1297          case OPCODE_PROGRAM_UNIFORM_3I64V:
1298          case OPCODE_PROGRAM_UNIFORM_4I64V:
1299          case OPCODE_PROGRAM_UNIFORM_1UI64V:
1300          case OPCODE_PROGRAM_UNIFORM_2UI64V:
1301          case OPCODE_PROGRAM_UNIFORM_3UI64V:
1302          case OPCODE_PROGRAM_UNIFORM_4UI64V:
1303             free(get_pointer(&n[4]));
1304             break;
1305          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
1306          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
1307          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
1308          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
1309          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
1310          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
1311          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
1312          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
1313          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
1314          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
1315          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
1316          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
1317          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
1318          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
1319          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
1320          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
1321          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
1322          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
1323             free(get_pointer(&n[5]));
1324             break;
1325          case OPCODE_PIXEL_MAP:
1326             free(get_pointer(&n[3]));
1327             break;
1328          case OPCODE_VIEWPORT_ARRAY_V:
1329          case OPCODE_SCISSOR_ARRAY_V:
1330          case OPCODE_DEPTH_ARRAY_V:
1331          case OPCODE_UNIFORM_SUBROUTINES:
1332          case OPCODE_WINDOW_RECTANGLES:
1333             free(get_pointer(&n[3]));
1334             break;
1335          case OPCODE_TEXTURE_IMAGE1D:
1336          case OPCODE_MULTITEX_IMAGE1D:
1337             free(get_pointer(&n[9]));
1338             break;
1339          case OPCODE_TEXTURE_IMAGE2D:
1340          case OPCODE_MULTITEX_IMAGE2D:
1341             free(get_pointer(&n[10]));
1342             break;
1343          case OPCODE_TEXTURE_IMAGE3D:
1344          case OPCODE_MULTITEX_IMAGE3D:
1345             free(get_pointer(&n[11]));
1346             break;
1347          case OPCODE_TEXTURE_SUB_IMAGE1D:
1348          case OPCODE_MULTITEX_SUB_IMAGE1D:
1349          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
1350          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
1351             free(get_pointer(&n[8]));
1352             break;
1353          case OPCODE_TEXTURE_SUB_IMAGE2D:
1354          case OPCODE_MULTITEX_SUB_IMAGE2D:
1355          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
1356          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
1357             free(get_pointer(&n[10]));
1358             break;
1359          case OPCODE_TEXTURE_SUB_IMAGE3D:
1360          case OPCODE_MULTITEX_SUB_IMAGE3D:
1361          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
1362          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
1363             free(get_pointer(&n[12]));
1364             break;
1365          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
1366          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
1367             free(get_pointer(&n[8]));
1368             break;
1369          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
1370          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
1371             free(get_pointer(&n[9]));
1372             break;
1373          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
1374          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
1375             free(get_pointer(&n[10]));
1376             break;
1377          case OPCODE_NAMED_PROGRAM_STRING:
1378             free(get_pointer(&n[5]));
1379             break;
1380          case OPCODE_VERTEX_LIST:
1381          case OPCODE_VERTEX_LIST_LOOPBACK:
1382          case OPCODE_VERTEX_LIST_COPY_CURRENT:
1383             vbo_destroy_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[1]);
1384             break;
1385          case OPCODE_CONTINUE:
1386             n = (Node *) get_pointer(&n[1]);
1387             assert (!dlist->small_list);
1388             free(block);
1389             block = n;
1390             continue;
1391          case OPCODE_END_OF_LIST:
1392             if (dlist->small_list) {
1393                unsigned start = dlist->begins_with_a_nop ? dlist->start - 1 :
1394                                                            dlist->start;
1395                for (int i = 0; i < dlist->count; i++) {
1396                   util_idalloc_free(&ctx->Shared->small_dlist_store.free_idx,
1397                                     start + i);
1398                }
1399             } else {
1400                free(block);
1401             }
1402             free(dlist->Label);
1403             free(dlist);
1404             return;
1405          default:
1406             /* just increment 'n' pointer, below */
1407             ;
1408       }
1409 
1410       assert(n[0].InstSize > 0);
1411       n += n[0].InstSize;
1412    }
1413 }
1414 
1415 
1416 /**
1417  * Called by _mesa_HashWalk() to check if a display list which is being
1418  * deleted belongs to a bitmap texture atlas.
1419  */
1420 static void
check_atlas_for_deleted_list(void * data,void * userData)1421 check_atlas_for_deleted_list(void *data, void *userData)
1422 {
1423    struct gl_bitmap_atlas *atlas = (struct gl_bitmap_atlas *) data;
1424    GLuint list_id = *((GLuint *) userData);  /* the list being deleted */
1425    const GLuint atlas_id = atlas->Id;
1426 
1427    /* See if the list_id falls in the range contained in this texture atlas */
1428    if (atlas->complete &&
1429        list_id >= atlas_id &&
1430        list_id < atlas_id + atlas->numBitmaps) {
1431       /* Mark the atlas as incomplete so it doesn't get used.  But don't
1432        * delete it yet since we don't want to try to recreate it in the next
1433        * glCallLists.
1434        */
1435       atlas->complete = false;
1436       atlas->incomplete = true;
1437    }
1438 }
1439 
1440 
1441 /**
1442  * Destroy a display list and remove from hash table.
1443  * \param list - display list number
1444  */
1445 static void
destroy_list(struct gl_context * ctx,GLuint list)1446 destroy_list(struct gl_context *ctx, GLuint list)
1447 {
1448    struct gl_display_list *dlist;
1449 
1450    if (list == 0)
1451       return;
1452 
1453    dlist = _mesa_lookup_list(ctx, list, false);
1454    if (!dlist)
1455       return;
1456 
1457    if (is_bitmap_list(ctx, dlist)) {
1458       /* If we're destroying a simple glBitmap display list, there's a
1459        * chance that we're destroying a bitmap image that's in a texture
1460        * atlas.  Examine all atlases to see if that's the case.  There's
1461        * usually few (if any) atlases so this isn't expensive.
1462        */
1463       _mesa_HashWalk(ctx->Shared->BitmapAtlas,
1464                      check_atlas_for_deleted_list, &list);
1465    }
1466 
1467    _mesa_HashLockMutex(ctx->Shared->DisplayList);
1468    _mesa_delete_list(ctx, dlist);
1469    _mesa_HashRemoveLocked(ctx->Shared->DisplayList, list);
1470    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
1471 }
1472 
1473 
1474 /**
1475  * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects.
1476  * If width < 0 or height < 0 or format or type are invalid we'll just
1477  * return NULL.  We will not generate an error since OpenGL command
1478  * arguments aren't error-checked until the command is actually executed
1479  * (not when they're compiled).
1480  * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded.
1481  */
1482 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)1483 unpack_image(struct gl_context *ctx, GLuint dimensions,
1484              GLsizei width, GLsizei height, GLsizei depth,
1485              GLenum format, GLenum type, const GLvoid * pixels,
1486              const struct gl_pixelstore_attrib *unpack)
1487 {
1488    if (width <= 0 || height <= 0) {
1489       return NULL;
1490    }
1491 
1492    if (_mesa_bytes_per_pixel(format, type) < 0) {
1493       /* bad format and/or type */
1494       return NULL;
1495    }
1496 
1497    if (!unpack->BufferObj) {
1498       /* no PBO */
1499       GLvoid *image;
1500 
1501       image = _mesa_unpack_image(dimensions, width, height, depth,
1502                                  format, type, pixels, unpack);
1503       if (pixels && !image) {
1504          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1505       }
1506       return image;
1507    }
1508    else if (_mesa_validate_pbo_access(dimensions, unpack, width, height,
1509                                       depth, format, type, INT_MAX, pixels)) {
1510       const GLubyte *map, *src;
1511       GLvoid *image;
1512 
1513       map = (GLubyte *)
1514          ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
1515                                     GL_MAP_READ_BIT, unpack->BufferObj,
1516                                     MAP_INTERNAL);
1517       if (!map) {
1518          /* unable to map src buffer! */
1519          _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
1520          return NULL;
1521       }
1522 
1523       src = ADD_POINTERS(map, pixels);
1524       image = _mesa_unpack_image(dimensions, width, height, depth,
1525                                  format, type, src, unpack);
1526 
1527       ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
1528 
1529       if (!image) {
1530          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
1531       }
1532       return image;
1533    }
1534 
1535    /* bad access! */
1536    _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access");
1537    return NULL;
1538 }
1539 
1540 
1541 /** Return copy of memory */
1542 static void *
memdup(const void * src,GLsizei bytes)1543 memdup(const void *src, GLsizei bytes)
1544 {
1545    void *b = bytes >= 0 ? malloc(bytes) : NULL;
1546    if (b)
1547       memcpy(b, src, bytes);
1548    return b;
1549 }
1550 
1551 
1552 /**
1553  * Allocate space for a display list instruction (opcode + payload space).
1554  * \param opcode  the instruction opcode (OPCODE_* value)
1555  * \param bytes   instruction payload size (not counting opcode)
1556  * \param align8  does the payload need to be 8-byte aligned?
1557  *                This is only relevant in 64-bit environments.
1558  * \return pointer to allocated memory (the payload will be at pointer+1)
1559  */
1560 static Node *
dlist_alloc(struct gl_context * ctx,OpCode opcode,GLuint bytes,bool align8)1561 dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8)
1562 {
1563    const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node);
1564    const GLuint contNodes = 1 + POINTER_DWORDS;  /* size of continue info */
1565    GLuint nopNode;
1566    Node *n;
1567 
1568    assert(bytes <= BLOCK_SIZE * sizeof(Node));
1569 
1570    if (sizeof(void *) > sizeof(Node) && align8
1571        && ctx->ListState.CurrentPos % 2 == 0) {
1572       /* The opcode would get placed at node[0] and the payload would start
1573        * at node[1].  But the payload needs to be at an even offset (8-byte
1574        * multiple).
1575        */
1576       nopNode = 1;
1577    }
1578    else {
1579       nopNode = 0;
1580    }
1581 
1582    if (ctx->ListState.CurrentPos + nopNode + numNodes + contNodes
1583        > BLOCK_SIZE) {
1584       /* This block is full.  Allocate a new block and chain to it */
1585       Node *newblock;
1586       n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1587       n[0].opcode = OPCODE_CONTINUE;
1588       newblock = malloc(sizeof(Node) * BLOCK_SIZE);
1589       if (!newblock) {
1590          _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
1591          return NULL;
1592       }
1593 
1594       /* a fresh block should be 8-byte aligned on 64-bit systems */
1595       assert(((GLintptr) newblock) % sizeof(void *) == 0);
1596 
1597       save_pointer(&n[1], newblock);
1598       ctx->ListState.CurrentBlock = newblock;
1599       ctx->ListState.CurrentPos = 0;
1600 
1601       /* Display list nodes are always 4 bytes.  If we need 8-byte alignment
1602        * we have to insert a NOP so that the payload of the real opcode lands
1603        * on an even location:
1604        *   node[0] = OPCODE_NOP
1605        *   node[1] = OPCODE_x;
1606        *   node[2] = start of payload
1607        */
1608       nopNode = sizeof(void *) > sizeof(Node) && align8;
1609    }
1610 
1611    n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
1612    if (nopNode) {
1613       assert(ctx->ListState.CurrentPos % 2 == 0); /* even value */
1614       n[0].opcode = OPCODE_NOP;
1615       n[0].InstSize = 1;
1616       n++;
1617       /* The "real" opcode will now be at an odd location and the payload
1618        * will be at an even location.
1619        */
1620    }
1621    ctx->ListState.CurrentPos += nopNode + numNodes;
1622 
1623    n[0].opcode = opcode;
1624    n[0].InstSize = numNodes;
1625 
1626    return n;
1627 }
1628 
1629 
1630 void *
_mesa_dlist_alloc_vertex_list(struct gl_context * ctx,bool copy_to_current)1631 _mesa_dlist_alloc_vertex_list(struct gl_context *ctx, bool copy_to_current)
1632 {
1633    Node *n =  dlist_alloc(ctx,
1634                           copy_to_current ? OPCODE_VERTEX_LIST_COPY_CURRENT :
1635                                             OPCODE_VERTEX_LIST,
1636                           sizeof(struct vbo_save_vertex_list),
1637                           true);
1638    if (n)
1639       return n + 1;  /* return pointer to payload area, after opcode */
1640    else
1641       return NULL;
1642 }
1643 
1644 
1645 /**
1646  * Allocate space for a display list instruction.  The space is basically
1647  * an array of Nodes where node[0] holds the opcode, node[1] is the first
1648  * function parameter, node[2] is the second parameter, etc.
1649  *
1650  * \param opcode  one of OPCODE_x
1651  * \param nparams  number of function parameters
1652  * \return  pointer to start of instruction space
1653  */
1654 static inline Node *
alloc_instruction(struct gl_context * ctx,OpCode opcode,GLuint nparams)1655 alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams)
1656 {
1657    return dlist_alloc(ctx, opcode, nparams * sizeof(Node), false);
1658 }
1659 
1660 
1661 /*
1662  * Display List compilation functions
1663  */
1664 static void GLAPIENTRY
save_Accum(GLenum op,GLfloat value)1665 save_Accum(GLenum op, GLfloat value)
1666 {
1667    GET_CURRENT_CONTEXT(ctx);
1668    Node *n;
1669    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1670    n = alloc_instruction(ctx, OPCODE_ACCUM, 2);
1671    if (n) {
1672       n[1].e = op;
1673       n[2].f = value;
1674    }
1675    if (ctx->ExecuteFlag) {
1676       CALL_Accum(ctx->Exec, (op, value));
1677    }
1678 }
1679 
1680 
1681 static void GLAPIENTRY
save_AlphaFunc(GLenum func,GLclampf ref)1682 save_AlphaFunc(GLenum func, GLclampf ref)
1683 {
1684    GET_CURRENT_CONTEXT(ctx);
1685    Node *n;
1686    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1687    n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2);
1688    if (n) {
1689       n[1].e = func;
1690       n[2].f = (GLfloat) ref;
1691    }
1692    if (ctx->ExecuteFlag) {
1693       CALL_AlphaFunc(ctx->Exec, (func, ref));
1694    }
1695 }
1696 
1697 
1698 static void GLAPIENTRY
save_BindTexture(GLenum target,GLuint texture)1699 save_BindTexture(GLenum target, GLuint texture)
1700 {
1701    GET_CURRENT_CONTEXT(ctx);
1702    Node *n;
1703    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1704    n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2);
1705    if (n) {
1706       n[1].e = target;
1707       n[2].ui = texture;
1708    }
1709    if (ctx->ExecuteFlag) {
1710       CALL_BindTexture(ctx->Exec, (target, texture));
1711    }
1712 }
1713 
1714 
1715 static void GLAPIENTRY
save_Bitmap(GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const GLubyte * pixels)1716 save_Bitmap(GLsizei width, GLsizei height,
1717             GLfloat xorig, GLfloat yorig,
1718             GLfloat xmove, GLfloat ymove, const GLubyte * pixels)
1719 {
1720    GET_CURRENT_CONTEXT(ctx);
1721    Node *n;
1722    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1723    n = alloc_instruction(ctx, OPCODE_BITMAP, 6 + POINTER_DWORDS);
1724    if (n) {
1725       n[1].i = (GLint) width;
1726       n[2].i = (GLint) height;
1727       n[3].f = xorig;
1728       n[4].f = yorig;
1729       n[5].f = xmove;
1730       n[6].f = ymove;
1731       save_pointer(&n[7],
1732                    unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX,
1733                                 GL_BITMAP, pixels, &ctx->Unpack));
1734    }
1735    if (ctx->ExecuteFlag) {
1736       CALL_Bitmap(ctx->Exec, (width, height,
1737                               xorig, yorig, xmove, ymove, pixels));
1738    }
1739 }
1740 
1741 
1742 static void GLAPIENTRY
save_BlendEquation(GLenum mode)1743 save_BlendEquation(GLenum mode)
1744 {
1745    GET_CURRENT_CONTEXT(ctx);
1746    Node *n;
1747    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1748    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1);
1749    if (n) {
1750       n[1].e = mode;
1751    }
1752    if (ctx->ExecuteFlag) {
1753       CALL_BlendEquation(ctx->Exec, (mode));
1754    }
1755 }
1756 
1757 
1758 static void GLAPIENTRY
save_BlendEquationSeparateEXT(GLenum modeRGB,GLenum modeA)1759 save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA)
1760 {
1761    GET_CURRENT_CONTEXT(ctx);
1762    Node *n;
1763    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1764    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2);
1765    if (n) {
1766       n[1].e = modeRGB;
1767       n[2].e = modeA;
1768    }
1769    if (ctx->ExecuteFlag) {
1770       CALL_BlendEquationSeparate(ctx->Exec, (modeRGB, modeA));
1771    }
1772 }
1773 
1774 
1775 static void GLAPIENTRY
save_BlendFuncSeparateEXT(GLenum sfactorRGB,GLenum dfactorRGB,GLenum sfactorA,GLenum dfactorA)1776 save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
1777                           GLenum sfactorA, GLenum dfactorA)
1778 {
1779    GET_CURRENT_CONTEXT(ctx);
1780    Node *n;
1781    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1782    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4);
1783    if (n) {
1784       n[1].e = sfactorRGB;
1785       n[2].e = dfactorRGB;
1786       n[3].e = sfactorA;
1787       n[4].e = dfactorA;
1788    }
1789    if (ctx->ExecuteFlag) {
1790       CALL_BlendFuncSeparate(ctx->Exec,
1791                                 (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
1792    }
1793 }
1794 
1795 
1796 static void GLAPIENTRY
save_BlendFunc(GLenum srcfactor,GLenum dstfactor)1797 save_BlendFunc(GLenum srcfactor, GLenum dstfactor)
1798 {
1799    save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor);
1800 }
1801 
1802 
1803 static void GLAPIENTRY
save_BlendColor(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)1804 save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
1805 {
1806    GET_CURRENT_CONTEXT(ctx);
1807    Node *n;
1808    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1809    n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4);
1810    if (n) {
1811       n[1].f = red;
1812       n[2].f = green;
1813       n[3].f = blue;
1814       n[4].f = alpha;
1815    }
1816    if (ctx->ExecuteFlag) {
1817       CALL_BlendColor(ctx->Exec, (red, green, blue, alpha));
1818    }
1819 }
1820 
1821 /* GL_ARB_draw_buffers_blend */
1822 static void GLAPIENTRY
save_BlendFuncSeparatei(GLuint buf,GLenum sfactorRGB,GLenum dfactorRGB,GLenum sfactorA,GLenum dfactorA)1823 save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
1824                         GLenum sfactorA, GLenum dfactorA)
1825 {
1826    GET_CURRENT_CONTEXT(ctx);
1827    Node *n;
1828    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1829    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
1830    if (n) {
1831       n[1].ui = buf;
1832       n[2].e = sfactorRGB;
1833       n[3].e = dfactorRGB;
1834       n[4].e = sfactorA;
1835       n[5].e = dfactorA;
1836    }
1837    if (ctx->ExecuteFlag) {
1838       CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
1839                                              sfactorA, dfactorA));
1840    }
1841 }
1842 
1843 /* GL_ARB_draw_buffers_blend */
1844 static void GLAPIENTRY
save_BlendFunci(GLuint buf,GLenum sfactor,GLenum dfactor)1845 save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
1846 {
1847    GET_CURRENT_CONTEXT(ctx);
1848    Node *n;
1849    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1850    n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_I, 3);
1851    if (n) {
1852       n[1].ui = buf;
1853       n[2].e = sfactor;
1854       n[3].e = dfactor;
1855    }
1856    if (ctx->ExecuteFlag) {
1857       CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
1858    }
1859 }
1860 
1861 /* GL_ARB_draw_buffers_blend */
1862 static void GLAPIENTRY
save_BlendEquationi(GLuint buf,GLenum mode)1863 save_BlendEquationi(GLuint buf, GLenum mode)
1864 {
1865    GET_CURRENT_CONTEXT(ctx);
1866    Node *n;
1867    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1868    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
1869    if (n) {
1870       n[1].ui = buf;
1871       n[2].e = mode;
1872    }
1873    if (ctx->ExecuteFlag) {
1874       CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
1875    }
1876 }
1877 
1878 /* GL_ARB_draw_buffers_blend */
1879 static void GLAPIENTRY
save_BlendEquationSeparatei(GLuint buf,GLenum modeRGB,GLenum modeA)1880 save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
1881 {
1882    GET_CURRENT_CONTEXT(ctx);
1883    Node *n;
1884    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
1885    n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
1886    if (n) {
1887       n[1].ui = buf;
1888       n[2].e = modeRGB;
1889       n[3].e = modeA;
1890    }
1891    if (ctx->ExecuteFlag) {
1892       CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
1893    }
1894 }
1895 
1896 
1897 /* GL_ARB_draw_instanced. */
1898 static void GLAPIENTRY
save_DrawArraysInstancedARB(UNUSED GLenum mode,UNUSED GLint first,UNUSED GLsizei count,UNUSED GLsizei primcount)1899 save_DrawArraysInstancedARB(UNUSED GLenum mode,
1900                             UNUSED GLint first,
1901                             UNUSED GLsizei count,
1902                             UNUSED GLsizei primcount)
1903 {
1904    GET_CURRENT_CONTEXT(ctx);
1905    _mesa_error(ctx, GL_INVALID_OPERATION,
1906                "glDrawArraysInstanced() during display list compile");
1907 }
1908 
1909 static void GLAPIENTRY
save_DrawElementsInstancedARB(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const GLvoid * indices,UNUSED GLsizei primcount)1910 save_DrawElementsInstancedARB(UNUSED GLenum mode,
1911                               UNUSED GLsizei count,
1912                               UNUSED GLenum type,
1913                               UNUSED const GLvoid *indices,
1914                               UNUSED GLsizei primcount)
1915 {
1916    GET_CURRENT_CONTEXT(ctx);
1917    _mesa_error(ctx, GL_INVALID_OPERATION,
1918                "glDrawElementsInstanced() during display list compile");
1919 }
1920 
1921 static void GLAPIENTRY
save_DrawElementsInstancedBaseVertexARB(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const GLvoid * indices,UNUSED GLsizei primcount,UNUSED GLint basevertex)1922 save_DrawElementsInstancedBaseVertexARB(UNUSED GLenum mode,
1923                                         UNUSED GLsizei count,
1924                                         UNUSED GLenum type,
1925                                         UNUSED const GLvoid *indices,
1926                                         UNUSED GLsizei primcount,
1927                                         UNUSED GLint basevertex)
1928 {
1929    GET_CURRENT_CONTEXT(ctx);
1930    _mesa_error(ctx, GL_INVALID_OPERATION,
1931                "glDrawElementsInstancedBaseVertex() during display list compile");
1932 }
1933 
1934 /* GL_ARB_base_instance. */
1935 static void GLAPIENTRY
save_DrawArraysInstancedBaseInstance(UNUSED GLenum mode,UNUSED GLint first,UNUSED GLsizei count,UNUSED GLsizei primcount,UNUSED GLuint baseinstance)1936 save_DrawArraysInstancedBaseInstance(UNUSED GLenum mode,
1937                                      UNUSED GLint first,
1938                                      UNUSED GLsizei count,
1939                                      UNUSED GLsizei primcount,
1940                                      UNUSED GLuint baseinstance)
1941 {
1942    GET_CURRENT_CONTEXT(ctx);
1943    _mesa_error(ctx, GL_INVALID_OPERATION,
1944                "glDrawArraysInstancedBaseInstance() during display list compile");
1945 }
1946 
1947 static void APIENTRY
save_DrawElementsInstancedBaseInstance(UNUSED GLenum mode,UNUSED GLsizei count,UNUSED GLenum type,UNUSED const void * indices,UNUSED GLsizei primcount,UNUSED GLuint baseinstance)1948 save_DrawElementsInstancedBaseInstance(UNUSED GLenum mode,
1949                                        UNUSED GLsizei count,
1950                                        UNUSED GLenum type,
1951                                        UNUSED const void *indices,
1952                                        UNUSED GLsizei primcount,
1953                                        UNUSED GLuint baseinstance)
1954 {
1955    GET_CURRENT_CONTEXT(ctx);
1956    _mesa_error(ctx, GL_INVALID_OPERATION,
1957                "glDrawElementsInstancedBaseInstance() during display list compile");
1958 }
1959 
1960 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)1961 save_DrawElementsInstancedBaseVertexBaseInstance(UNUSED GLenum mode,
1962                                                  UNUSED GLsizei count,
1963                                                  UNUSED GLenum type,
1964                                                  UNUSED const void *indices,
1965                                                  UNUSED GLsizei primcount,
1966                                                  UNUSED GLint basevertex,
1967                                                  UNUSED GLuint baseinstance)
1968 {
1969    GET_CURRENT_CONTEXT(ctx);
1970    _mesa_error(ctx, GL_INVALID_OPERATION,
1971                "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile");
1972 }
1973 
1974 static void APIENTRY
save_DrawArraysIndirect(UNUSED GLenum mode,UNUSED const void * indirect)1975 save_DrawArraysIndirect(UNUSED GLenum mode,
1976                         UNUSED const void *indirect)
1977 {
1978    GET_CURRENT_CONTEXT(ctx);
1979    _mesa_error(ctx, GL_INVALID_OPERATION,
1980                "glDrawArraysIndirect() during display list compile");
1981 }
1982 
1983 static void APIENTRY
save_DrawElementsIndirect(UNUSED GLenum mode,UNUSED GLenum type,UNUSED const void * indirect)1984 save_DrawElementsIndirect(UNUSED GLenum mode,
1985                           UNUSED GLenum type,
1986                           UNUSED const void *indirect)
1987 {
1988    GET_CURRENT_CONTEXT(ctx);
1989    _mesa_error(ctx, GL_INVALID_OPERATION,
1990                "glDrawElementsIndirect() during display list compile");
1991 }
1992 
1993 static void APIENTRY
save_MultiDrawArraysIndirect(UNUSED GLenum mode,UNUSED const void * indirect,UNUSED GLsizei primcount,UNUSED GLsizei stride)1994 save_MultiDrawArraysIndirect(UNUSED GLenum mode,
1995                              UNUSED const void *indirect,
1996                              UNUSED GLsizei primcount,
1997                              UNUSED GLsizei stride)
1998 {
1999    GET_CURRENT_CONTEXT(ctx);
2000    _mesa_error(ctx, GL_INVALID_OPERATION,
2001                "glMultiDrawArraysIndirect() during display list compile");
2002 }
2003 
2004 static void APIENTRY
save_MultiDrawElementsIndirect(UNUSED GLenum mode,UNUSED GLenum type,UNUSED const void * indirect,UNUSED GLsizei primcount,UNUSED GLsizei stride)2005 save_MultiDrawElementsIndirect(UNUSED GLenum mode,
2006                                UNUSED GLenum type,
2007                                UNUSED const void *indirect,
2008                                UNUSED GLsizei primcount,
2009                                UNUSED GLsizei stride)
2010 {
2011    GET_CURRENT_CONTEXT(ctx);
2012    _mesa_error(ctx, GL_INVALID_OPERATION,
2013                "glMultiDrawElementsIndirect() during display list compile");
2014 }
2015 
2016 /**
2017  * While building a display list we cache some OpenGL state.
2018  * Under some circumstances we need to invalidate that state (immediately
2019  * when we start compiling a list, or after glCallList(s)).
2020  */
2021 static void
invalidate_saved_current_state(struct gl_context * ctx)2022 invalidate_saved_current_state(struct gl_context *ctx)
2023 {
2024    GLint i;
2025 
2026    for (i = 0; i < VERT_ATTRIB_MAX; i++)
2027       ctx->ListState.ActiveAttribSize[i] = 0;
2028 
2029    for (i = 0; i < MAT_ATTRIB_MAX; i++)
2030       ctx->ListState.ActiveMaterialSize[i] = 0;
2031 
2032    /* Loopback usage applies recursively, so remember this state */
2033    bool use_loopback = ctx->ListState.Current.UseLoopback;
2034    memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
2035    ctx->ListState.Current.UseLoopback = use_loopback;
2036 
2037    ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
2038 }
2039 
2040 
2041 static void GLAPIENTRY
save_CallList(GLuint list)2042 save_CallList(GLuint list)
2043 {
2044    GET_CURRENT_CONTEXT(ctx);
2045    Node *n;
2046    SAVE_FLUSH_VERTICES(ctx);
2047 
2048    n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1);
2049    if (n) {
2050       n[1].ui = list;
2051    }
2052 
2053    /* After this, we don't know what state we're in.  Invalidate all
2054     * cached information previously gathered:
2055     */
2056    invalidate_saved_current_state( ctx );
2057 
2058    if (ctx->ExecuteFlag) {
2059       _mesa_CallList(list);
2060    }
2061 }
2062 
2063 
2064 static void GLAPIENTRY
save_CallLists(GLsizei num,GLenum type,const GLvoid * lists)2065 save_CallLists(GLsizei num, GLenum type, const GLvoid * lists)
2066 {
2067    GET_CURRENT_CONTEXT(ctx);
2068    unsigned type_size;
2069    Node *n;
2070    void *lists_copy;
2071 
2072    SAVE_FLUSH_VERTICES(ctx);
2073 
2074    switch (type) {
2075    case GL_BYTE:
2076    case GL_UNSIGNED_BYTE:
2077       type_size = 1;
2078       break;
2079    case GL_SHORT:
2080    case GL_UNSIGNED_SHORT:
2081    case GL_2_BYTES:
2082       type_size = 2;
2083       break;
2084    case GL_3_BYTES:
2085       type_size = 3;
2086       break;
2087    case GL_INT:
2088    case GL_UNSIGNED_INT:
2089    case GL_FLOAT:
2090    case GL_4_BYTES:
2091       type_size = 4;
2092       break;
2093    default:
2094       type_size = 0;
2095    }
2096 
2097    if (num > 0 && type_size > 0) {
2098       /* create a copy of the array of list IDs to save in the display list */
2099       lists_copy = memdup(lists, num * type_size);
2100    } else {
2101       lists_copy = NULL;
2102    }
2103 
2104    n = alloc_instruction(ctx, OPCODE_CALL_LISTS, 2 + POINTER_DWORDS);
2105    if (n) {
2106       n[1].i = num;
2107       n[2].e = type;
2108       save_pointer(&n[3], lists_copy);
2109    }
2110 
2111    /* After this, we don't know what state we're in.  Invalidate all
2112     * cached information previously gathered:
2113     */
2114    invalidate_saved_current_state( ctx );
2115 
2116    if (ctx->ExecuteFlag) {
2117       CALL_CallLists(ctx->Exec, (num, type, lists));
2118    }
2119 }
2120 
2121 
2122 static void GLAPIENTRY
save_Clear(GLbitfield mask)2123 save_Clear(GLbitfield mask)
2124 {
2125    GET_CURRENT_CONTEXT(ctx);
2126    Node *n;
2127    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2128    n = alloc_instruction(ctx, OPCODE_CLEAR, 1);
2129    if (n) {
2130       n[1].bf = mask;
2131    }
2132    if (ctx->ExecuteFlag) {
2133       CALL_Clear(ctx->Exec, (mask));
2134    }
2135 }
2136 
2137 
2138 static void GLAPIENTRY
save_ClearBufferiv(GLenum buffer,GLint drawbuffer,const GLint * value)2139 save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
2140 {
2141    GET_CURRENT_CONTEXT(ctx);
2142    Node *n;
2143    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2144    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6);
2145    if (n) {
2146       n[1].e = buffer;
2147       n[2].i = drawbuffer;
2148       n[3].i = value[0];
2149       if (buffer == GL_COLOR) {
2150          n[4].i = value[1];
2151          n[5].i = value[2];
2152          n[6].i = value[3];
2153       }
2154       else {
2155          n[4].i = 0;
2156          n[5].i = 0;
2157          n[6].i = 0;
2158       }
2159    }
2160    if (ctx->ExecuteFlag) {
2161       CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));
2162    }
2163 }
2164 
2165 
2166 static void GLAPIENTRY
save_ClearBufferuiv(GLenum buffer,GLint drawbuffer,const GLuint * value)2167 save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
2168 {
2169    GET_CURRENT_CONTEXT(ctx);
2170    Node *n;
2171    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2172    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6);
2173    if (n) {
2174       n[1].e = buffer;
2175       n[2].i = drawbuffer;
2176       n[3].ui = value[0];
2177       if (buffer == GL_COLOR) {
2178          n[4].ui = value[1];
2179          n[5].ui = value[2];
2180          n[6].ui = value[3];
2181       }
2182       else {
2183          n[4].ui = 0;
2184          n[5].ui = 0;
2185          n[6].ui = 0;
2186       }
2187    }
2188    if (ctx->ExecuteFlag) {
2189       CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));
2190    }
2191 }
2192 
2193 
2194 static void GLAPIENTRY
save_ClearBufferfv(GLenum buffer,GLint drawbuffer,const GLfloat * value)2195 save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
2196 {
2197    GET_CURRENT_CONTEXT(ctx);
2198    Node *n;
2199    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2200    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6);
2201    if (n) {
2202       n[1].e = buffer;
2203       n[2].i = drawbuffer;
2204       n[3].f = value[0];
2205       if (buffer == GL_COLOR) {
2206          n[4].f = value[1];
2207          n[5].f = value[2];
2208          n[6].f = value[3];
2209       }
2210       else {
2211          n[4].f = 0.0F;
2212          n[5].f = 0.0F;
2213          n[6].f = 0.0F;
2214       }
2215    }
2216    if (ctx->ExecuteFlag) {
2217       CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value));
2218    }
2219 }
2220 
2221 
2222 static void GLAPIENTRY
save_ClearBufferfi(GLenum buffer,GLint drawbuffer,GLfloat depth,GLint stencil)2223 save_ClearBufferfi(GLenum buffer, GLint drawbuffer,
2224                    GLfloat depth, GLint stencil)
2225 {
2226    GET_CURRENT_CONTEXT(ctx);
2227    Node *n;
2228    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2229    n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4);
2230    if (n) {
2231       n[1].e = buffer;
2232       n[2].i = drawbuffer;
2233       n[3].f = depth;
2234       n[4].i = stencil;
2235    }
2236    if (ctx->ExecuteFlag) {
2237       CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));
2238    }
2239 }
2240 
2241 
2242 static void GLAPIENTRY
save_ClearAccum(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)2243 save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
2244 {
2245    GET_CURRENT_CONTEXT(ctx);
2246    Node *n;
2247    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2248    n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4);
2249    if (n) {
2250       n[1].f = red;
2251       n[2].f = green;
2252       n[3].f = blue;
2253       n[4].f = alpha;
2254    }
2255    if (ctx->ExecuteFlag) {
2256       CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha));
2257    }
2258 }
2259 
2260 
2261 static void GLAPIENTRY
save_ClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)2262 save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
2263 {
2264    GET_CURRENT_CONTEXT(ctx);
2265    Node *n;
2266    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2267    n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4);
2268    if (n) {
2269       n[1].f = red;
2270       n[2].f = green;
2271       n[3].f = blue;
2272       n[4].f = alpha;
2273    }
2274    if (ctx->ExecuteFlag) {
2275       CALL_ClearColor(ctx->Exec, (red, green, blue, alpha));
2276    }
2277 }
2278 
2279 
2280 static void GLAPIENTRY
save_ClearDepth(GLclampd depth)2281 save_ClearDepth(GLclampd depth)
2282 {
2283    GET_CURRENT_CONTEXT(ctx);
2284    Node *n;
2285    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2286    n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1);
2287    if (n) {
2288       n[1].f = (GLfloat) depth;
2289    }
2290    if (ctx->ExecuteFlag) {
2291       CALL_ClearDepth(ctx->Exec, (depth));
2292    }
2293 }
2294 
2295 
2296 static void GLAPIENTRY
save_ClearIndex(GLfloat c)2297 save_ClearIndex(GLfloat c)
2298 {
2299    GET_CURRENT_CONTEXT(ctx);
2300    Node *n;
2301    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2302    n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1);
2303    if (n) {
2304       n[1].f = c;
2305    }
2306    if (ctx->ExecuteFlag) {
2307       CALL_ClearIndex(ctx->Exec, (c));
2308    }
2309 }
2310 
2311 
2312 static void GLAPIENTRY
save_ClearStencil(GLint s)2313 save_ClearStencil(GLint s)
2314 {
2315    GET_CURRENT_CONTEXT(ctx);
2316    Node *n;
2317    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2318    n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1);
2319    if (n) {
2320       n[1].i = s;
2321    }
2322    if (ctx->ExecuteFlag) {
2323       CALL_ClearStencil(ctx->Exec, (s));
2324    }
2325 }
2326 
2327 
2328 static void GLAPIENTRY
save_ClipPlane(GLenum plane,const GLdouble * equ)2329 save_ClipPlane(GLenum plane, const GLdouble * equ)
2330 {
2331    GET_CURRENT_CONTEXT(ctx);
2332    Node *n;
2333    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2334    n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5);
2335    if (n) {
2336       n[1].e = plane;
2337       n[2].f = (GLfloat) equ[0];
2338       n[3].f = (GLfloat) equ[1];
2339       n[4].f = (GLfloat) equ[2];
2340       n[5].f = (GLfloat) equ[3];
2341    }
2342    if (ctx->ExecuteFlag) {
2343       CALL_ClipPlane(ctx->Exec, (plane, equ));
2344    }
2345 }
2346 
2347 
2348 
2349 static void GLAPIENTRY
save_ColorMask(GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)2350 save_ColorMask(GLboolean red, GLboolean green,
2351                GLboolean blue, GLboolean alpha)
2352 {
2353    GET_CURRENT_CONTEXT(ctx);
2354    Node *n;
2355    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2356    n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4);
2357    if (n) {
2358       n[1].b = red;
2359       n[2].b = green;
2360       n[3].b = blue;
2361       n[4].b = alpha;
2362    }
2363    if (ctx->ExecuteFlag) {
2364       CALL_ColorMask(ctx->Exec, (red, green, blue, alpha));
2365    }
2366 }
2367 
2368 
2369 static void GLAPIENTRY
save_ColorMaskIndexed(GLuint buf,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)2370 save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green,
2371                       GLboolean blue, GLboolean alpha)
2372 {
2373    GET_CURRENT_CONTEXT(ctx);
2374    Node *n;
2375    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2376    n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5);
2377    if (n) {
2378       n[1].ui = buf;
2379       n[2].b = red;
2380       n[3].b = green;
2381       n[4].b = blue;
2382       n[5].b = alpha;
2383    }
2384    if (ctx->ExecuteFlag) {
2385       /*CALL_ColorMaski(ctx->Exec, (buf, red, green, blue, alpha));*/
2386    }
2387 }
2388 
2389 
2390 static void GLAPIENTRY
save_ColorMaterial(GLenum face,GLenum mode)2391 save_ColorMaterial(GLenum face, GLenum mode)
2392 {
2393    GET_CURRENT_CONTEXT(ctx);
2394    Node *n;
2395    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2396 
2397    n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2);
2398    if (n) {
2399       n[1].e = face;
2400       n[2].e = mode;
2401    }
2402    if (ctx->ExecuteFlag) {
2403       CALL_ColorMaterial(ctx->Exec, (face, mode));
2404    }
2405 }
2406 
2407 
2408 static void GLAPIENTRY
save_CopyPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum type)2409 save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
2410 {
2411    GET_CURRENT_CONTEXT(ctx);
2412    Node *n;
2413    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2414    n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5);
2415    if (n) {
2416       n[1].i = x;
2417       n[2].i = y;
2418       n[3].i = (GLint) width;
2419       n[4].i = (GLint) height;
2420       n[5].e = type;
2421    }
2422    if (ctx->ExecuteFlag) {
2423       CALL_CopyPixels(ctx->Exec, (x, y, width, height, type));
2424    }
2425 }
2426 
2427 
2428 
2429 static void GLAPIENTRY
save_CopyTexImage1D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)2430 save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
2431                     GLint x, GLint y, GLsizei width, GLint border)
2432 {
2433    GET_CURRENT_CONTEXT(ctx);
2434    Node *n;
2435    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2436    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7);
2437    if (n) {
2438       n[1].e = target;
2439       n[2].i = level;
2440       n[3].e = internalformat;
2441       n[4].i = x;
2442       n[5].i = y;
2443       n[6].i = width;
2444       n[7].i = border;
2445    }
2446    if (ctx->ExecuteFlag) {
2447       CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat,
2448                                       x, y, width, border));
2449    }
2450 }
2451 
2452 
2453 static void GLAPIENTRY
save_CopyTexImage2D(GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)2454 save_CopyTexImage2D(GLenum target, GLint level,
2455                     GLenum internalformat,
2456                     GLint x, GLint y, GLsizei width,
2457                     GLsizei height, GLint border)
2458 {
2459    GET_CURRENT_CONTEXT(ctx);
2460    Node *n;
2461    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2462    n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8);
2463    if (n) {
2464       n[1].e = target;
2465       n[2].i = level;
2466       n[3].e = internalformat;
2467       n[4].i = x;
2468       n[5].i = y;
2469       n[6].i = width;
2470       n[7].i = height;
2471       n[8].i = border;
2472    }
2473    if (ctx->ExecuteFlag) {
2474       CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat,
2475                                       x, y, width, height, border));
2476    }
2477 }
2478 
2479 
2480 
2481 static void GLAPIENTRY
save_CopyTexSubImage1D(GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)2482 save_CopyTexSubImage1D(GLenum target, GLint level,
2483                        GLint xoffset, GLint x, GLint y, GLsizei width)
2484 {
2485    GET_CURRENT_CONTEXT(ctx);
2486    Node *n;
2487    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2488    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6);
2489    if (n) {
2490       n[1].e = target;
2491       n[2].i = level;
2492       n[3].i = xoffset;
2493       n[4].i = x;
2494       n[5].i = y;
2495       n[6].i = width;
2496    }
2497    if (ctx->ExecuteFlag) {
2498       CALL_CopyTexSubImage1D(ctx->Exec,
2499                              (target, level, xoffset, x, y, width));
2500    }
2501 }
2502 
2503 
2504 static void GLAPIENTRY
save_CopyTexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)2505 save_CopyTexSubImage2D(GLenum target, GLint level,
2506                        GLint xoffset, GLint yoffset,
2507                        GLint x, GLint y, GLsizei width, GLint height)
2508 {
2509    GET_CURRENT_CONTEXT(ctx);
2510    Node *n;
2511    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2512    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8);
2513    if (n) {
2514       n[1].e = target;
2515       n[2].i = level;
2516       n[3].i = xoffset;
2517       n[4].i = yoffset;
2518       n[5].i = x;
2519       n[6].i = y;
2520       n[7].i = width;
2521       n[8].i = height;
2522    }
2523    if (ctx->ExecuteFlag) {
2524       CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
2525                                          x, y, width, height));
2526    }
2527 }
2528 
2529 
2530 static void GLAPIENTRY
save_CopyTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLint height)2531 save_CopyTexSubImage3D(GLenum target, GLint level,
2532                        GLint xoffset, GLint yoffset, GLint zoffset,
2533                        GLint x, GLint y, GLsizei width, GLint height)
2534 {
2535    GET_CURRENT_CONTEXT(ctx);
2536    Node *n;
2537    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2538    n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9);
2539    if (n) {
2540       n[1].e = target;
2541       n[2].i = level;
2542       n[3].i = xoffset;
2543       n[4].i = yoffset;
2544       n[5].i = zoffset;
2545       n[6].i = x;
2546       n[7].i = y;
2547       n[8].i = width;
2548       n[9].i = height;
2549    }
2550    if (ctx->ExecuteFlag) {
2551       CALL_CopyTexSubImage3D(ctx->Exec, (target, level,
2552                                          xoffset, yoffset, zoffset,
2553                                          x, y, width, height));
2554    }
2555 }
2556 
2557 
2558 static void GLAPIENTRY
save_CullFace(GLenum mode)2559 save_CullFace(GLenum mode)
2560 {
2561    GET_CURRENT_CONTEXT(ctx);
2562    Node *n;
2563    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2564    n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1);
2565    if (n) {
2566       n[1].e = mode;
2567    }
2568    if (ctx->ExecuteFlag) {
2569       CALL_CullFace(ctx->Exec, (mode));
2570    }
2571 }
2572 
2573 
2574 static void GLAPIENTRY
save_DepthFunc(GLenum func)2575 save_DepthFunc(GLenum func)
2576 {
2577    GET_CURRENT_CONTEXT(ctx);
2578    Node *n;
2579    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2580    n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1);
2581    if (n) {
2582       n[1].e = func;
2583    }
2584    if (ctx->ExecuteFlag) {
2585       CALL_DepthFunc(ctx->Exec, (func));
2586    }
2587 }
2588 
2589 
2590 static void GLAPIENTRY
save_DepthMask(GLboolean mask)2591 save_DepthMask(GLboolean mask)
2592 {
2593    GET_CURRENT_CONTEXT(ctx);
2594    Node *n;
2595    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2596    n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1);
2597    if (n) {
2598       n[1].b = mask;
2599    }
2600    if (ctx->ExecuteFlag) {
2601       CALL_DepthMask(ctx->Exec, (mask));
2602    }
2603 }
2604 
2605 
2606 static void GLAPIENTRY
save_DepthRange(GLclampd nearval,GLclampd farval)2607 save_DepthRange(GLclampd nearval, GLclampd farval)
2608 {
2609    GET_CURRENT_CONTEXT(ctx);
2610    Node *n;
2611    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2612    n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2);
2613    if (n) {
2614       n[1].f = (GLfloat) nearval;
2615       n[2].f = (GLfloat) farval;
2616    }
2617    if (ctx->ExecuteFlag) {
2618       CALL_DepthRange(ctx->Exec, (nearval, farval));
2619    }
2620 }
2621 
2622 
2623 static void GLAPIENTRY
save_Disable(GLenum cap)2624 save_Disable(GLenum cap)
2625 {
2626    GET_CURRENT_CONTEXT(ctx);
2627    Node *n;
2628    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2629    n = alloc_instruction(ctx, OPCODE_DISABLE, 1);
2630    if (n) {
2631       n[1].e = cap;
2632    }
2633    if (ctx->ExecuteFlag) {
2634       CALL_Disable(ctx->Exec, (cap));
2635    }
2636 }
2637 
2638 
2639 static void GLAPIENTRY
save_DisableIndexed(GLuint index,GLenum cap)2640 save_DisableIndexed(GLuint index, GLenum cap)
2641 {
2642    GET_CURRENT_CONTEXT(ctx);
2643    Node *n;
2644    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2645    n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2);
2646    if (n) {
2647       n[1].ui = index;
2648       n[2].e = cap;
2649    }
2650    if (ctx->ExecuteFlag) {
2651       CALL_Disablei(ctx->Exec, (index, cap));
2652    }
2653 }
2654 
2655 
2656 static void GLAPIENTRY
save_DrawBuffer(GLenum mode)2657 save_DrawBuffer(GLenum mode)
2658 {
2659    GET_CURRENT_CONTEXT(ctx);
2660    Node *n;
2661    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2662    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1);
2663    if (n) {
2664       n[1].e = mode;
2665    }
2666    if (ctx->ExecuteFlag) {
2667       CALL_DrawBuffer(ctx->Exec, (mode));
2668    }
2669 }
2670 
2671 
2672 static void GLAPIENTRY
save_DrawPixels(GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)2673 save_DrawPixels(GLsizei width, GLsizei height,
2674                 GLenum format, GLenum type, const GLvoid * pixels)
2675 {
2676    GET_CURRENT_CONTEXT(ctx);
2677    Node *n;
2678 
2679    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2680 
2681    n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 4 + POINTER_DWORDS);
2682    if (n) {
2683       n[1].i = width;
2684       n[2].i = height;
2685       n[3].e = format;
2686       n[4].e = type;
2687       save_pointer(&n[5],
2688                    unpack_image(ctx, 2, width, height, 1, format, type,
2689                                 pixels, &ctx->Unpack));
2690    }
2691    if (ctx->ExecuteFlag) {
2692       CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels));
2693    }
2694 }
2695 
2696 
2697 
2698 static void GLAPIENTRY
save_Enable(GLenum cap)2699 save_Enable(GLenum cap)
2700 {
2701    GET_CURRENT_CONTEXT(ctx);
2702    Node *n;
2703    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2704    n = alloc_instruction(ctx, OPCODE_ENABLE, 1);
2705    if (n) {
2706       n[1].e = cap;
2707    }
2708    if (ctx->ExecuteFlag) {
2709       CALL_Enable(ctx->Exec, (cap));
2710    }
2711 }
2712 
2713 
2714 
2715 static void GLAPIENTRY
save_EnableIndexed(GLuint index,GLenum cap)2716 save_EnableIndexed(GLuint index, GLenum cap)
2717 {
2718    GET_CURRENT_CONTEXT(ctx);
2719    Node *n;
2720    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2721    n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2);
2722    if (n) {
2723       n[1].ui = index;
2724       n[2].e = cap;
2725    }
2726    if (ctx->ExecuteFlag) {
2727       CALL_Enablei(ctx->Exec, (index, cap));
2728    }
2729 }
2730 
2731 
2732 
2733 static void GLAPIENTRY
save_EvalMesh1(GLenum mode,GLint i1,GLint i2)2734 save_EvalMesh1(GLenum mode, GLint i1, GLint i2)
2735 {
2736    GET_CURRENT_CONTEXT(ctx);
2737    Node *n;
2738    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2739    n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3);
2740    if (n) {
2741       n[1].e = mode;
2742       n[2].i = i1;
2743       n[3].i = i2;
2744    }
2745    if (ctx->ExecuteFlag) {
2746       CALL_EvalMesh1(ctx->Exec, (mode, i1, i2));
2747    }
2748 }
2749 
2750 
2751 static void GLAPIENTRY
save_EvalMesh2(GLenum mode,GLint i1,GLint i2,GLint j1,GLint j2)2752 save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
2753 {
2754    GET_CURRENT_CONTEXT(ctx);
2755    Node *n;
2756    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2757    n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5);
2758    if (n) {
2759       n[1].e = mode;
2760       n[2].i = i1;
2761       n[3].i = i2;
2762       n[4].i = j1;
2763       n[5].i = j2;
2764    }
2765    if (ctx->ExecuteFlag) {
2766       CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2));
2767    }
2768 }
2769 
2770 
2771 
2772 
2773 static void GLAPIENTRY
save_Fogfv(GLenum pname,const GLfloat * params)2774 save_Fogfv(GLenum pname, const GLfloat *params)
2775 {
2776    GET_CURRENT_CONTEXT(ctx);
2777    Node *n;
2778    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2779    n = alloc_instruction(ctx, OPCODE_FOG, 5);
2780    if (n) {
2781       n[1].e = pname;
2782       n[2].f = params[0];
2783       n[3].f = params[1];
2784       n[4].f = params[2];
2785       n[5].f = params[3];
2786    }
2787    if (ctx->ExecuteFlag) {
2788       CALL_Fogfv(ctx->Exec, (pname, params));
2789    }
2790 }
2791 
2792 
2793 static void GLAPIENTRY
save_Fogf(GLenum pname,GLfloat param)2794 save_Fogf(GLenum pname, GLfloat param)
2795 {
2796    GLfloat parray[4];
2797    parray[0] = param;
2798    parray[1] = parray[2] = parray[3] = 0.0F;
2799    save_Fogfv(pname, parray);
2800 }
2801 
2802 
2803 static void GLAPIENTRY
save_Fogiv(GLenum pname,const GLint * params)2804 save_Fogiv(GLenum pname, const GLint *params)
2805 {
2806    GLfloat p[4];
2807    switch (pname) {
2808    case GL_FOG_MODE:
2809    case GL_FOG_DENSITY:
2810    case GL_FOG_START:
2811    case GL_FOG_END:
2812    case GL_FOG_INDEX:
2813    case GL_FOG_COORDINATE_SOURCE:
2814       p[0] = (GLfloat) *params;
2815       p[1] = 0.0f;
2816       p[2] = 0.0f;
2817       p[3] = 0.0f;
2818       break;
2819    case GL_FOG_COLOR:
2820       p[0] = INT_TO_FLOAT(params[0]);
2821       p[1] = INT_TO_FLOAT(params[1]);
2822       p[2] = INT_TO_FLOAT(params[2]);
2823       p[3] = INT_TO_FLOAT(params[3]);
2824       break;
2825    default:
2826       /* Error will be caught later in gl_Fogfv */
2827       ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F);
2828    }
2829    save_Fogfv(pname, p);
2830 }
2831 
2832 
2833 static void GLAPIENTRY
save_Fogi(GLenum pname,GLint param)2834 save_Fogi(GLenum pname, GLint param)
2835 {
2836    GLint parray[4];
2837    parray[0] = param;
2838    parray[1] = parray[2] = parray[3] = 0;
2839    save_Fogiv(pname, parray);
2840 }
2841 
2842 
2843 static void GLAPIENTRY
save_FrontFace(GLenum mode)2844 save_FrontFace(GLenum mode)
2845 {
2846    GET_CURRENT_CONTEXT(ctx);
2847    Node *n;
2848    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2849    n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1);
2850    if (n) {
2851       n[1].e = mode;
2852    }
2853    if (ctx->ExecuteFlag) {
2854       CALL_FrontFace(ctx->Exec, (mode));
2855    }
2856 }
2857 
2858 
2859 static void GLAPIENTRY
save_Frustum(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)2860 save_Frustum(GLdouble left, GLdouble right,
2861              GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
2862 {
2863    GET_CURRENT_CONTEXT(ctx);
2864    Node *n;
2865    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2866    n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6);
2867    if (n) {
2868       n[1].f = (GLfloat) left;
2869       n[2].f = (GLfloat) right;
2870       n[3].f = (GLfloat) bottom;
2871       n[4].f = (GLfloat) top;
2872       n[5].f = (GLfloat) nearval;
2873       n[6].f = (GLfloat) farval;
2874    }
2875    if (ctx->ExecuteFlag) {
2876       CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval));
2877    }
2878 }
2879 
2880 
2881 static void GLAPIENTRY
save_Hint(GLenum target,GLenum mode)2882 save_Hint(GLenum target, GLenum mode)
2883 {
2884    GET_CURRENT_CONTEXT(ctx);
2885    Node *n;
2886    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2887    n = alloc_instruction(ctx, OPCODE_HINT, 2);
2888    if (n) {
2889       n[1].e = target;
2890       n[2].e = mode;
2891    }
2892    if (ctx->ExecuteFlag) {
2893       CALL_Hint(ctx->Exec, (target, mode));
2894    }
2895 }
2896 
2897 
2898 static void GLAPIENTRY
save_IndexMask(GLuint mask)2899 save_IndexMask(GLuint mask)
2900 {
2901    GET_CURRENT_CONTEXT(ctx);
2902    Node *n;
2903    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2904    n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1);
2905    if (n) {
2906       n[1].ui = mask;
2907    }
2908    if (ctx->ExecuteFlag) {
2909       CALL_IndexMask(ctx->Exec, (mask));
2910    }
2911 }
2912 
2913 
2914 static void GLAPIENTRY
save_InitNames(void)2915 save_InitNames(void)
2916 {
2917    GET_CURRENT_CONTEXT(ctx);
2918    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2919    (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0);
2920    if (ctx->ExecuteFlag) {
2921       CALL_InitNames(ctx->Exec, ());
2922    }
2923 }
2924 
2925 
2926 static void GLAPIENTRY
save_Lightfv(GLenum light,GLenum pname,const GLfloat * params)2927 save_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
2928 {
2929    GET_CURRENT_CONTEXT(ctx);
2930    Node *n;
2931    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
2932    n = alloc_instruction(ctx, OPCODE_LIGHT, 6);
2933    if (n) {
2934       GLint i, nParams;
2935       n[1].e = light;
2936       n[2].e = pname;
2937       switch (pname) {
2938       case GL_AMBIENT:
2939          nParams = 4;
2940          break;
2941       case GL_DIFFUSE:
2942          nParams = 4;
2943          break;
2944       case GL_SPECULAR:
2945          nParams = 4;
2946          break;
2947       case GL_POSITION:
2948          nParams = 4;
2949          break;
2950       case GL_SPOT_DIRECTION:
2951          nParams = 3;
2952          break;
2953       case GL_SPOT_EXPONENT:
2954          nParams = 1;
2955          break;
2956       case GL_SPOT_CUTOFF:
2957          nParams = 1;
2958          break;
2959       case GL_CONSTANT_ATTENUATION:
2960          nParams = 1;
2961          break;
2962       case GL_LINEAR_ATTENUATION:
2963          nParams = 1;
2964          break;
2965       case GL_QUADRATIC_ATTENUATION:
2966          nParams = 1;
2967          break;
2968       default:
2969          nParams = 0;
2970       }
2971       for (i = 0; i < nParams; i++) {
2972          n[3 + i].f = params[i];
2973       }
2974    }
2975    if (ctx->ExecuteFlag) {
2976       CALL_Lightfv(ctx->Exec, (light, pname, params));
2977    }
2978 }
2979 
2980 
2981 static void GLAPIENTRY
save_Lightf(GLenum light,GLenum pname,GLfloat param)2982 save_Lightf(GLenum light, GLenum pname, GLfloat param)
2983 {
2984    GLfloat parray[4];
2985    parray[0] = param;
2986    parray[1] = parray[2] = parray[3] = 0.0F;
2987    save_Lightfv(light, pname, parray);
2988 }
2989 
2990 
2991 static void GLAPIENTRY
save_Lightiv(GLenum light,GLenum pname,const GLint * params)2992 save_Lightiv(GLenum light, GLenum pname, const GLint *params)
2993 {
2994    GLfloat fparam[4];
2995    switch (pname) {
2996    case GL_AMBIENT:
2997    case GL_DIFFUSE:
2998    case GL_SPECULAR:
2999       fparam[0] = INT_TO_FLOAT(params[0]);
3000       fparam[1] = INT_TO_FLOAT(params[1]);
3001       fparam[2] = INT_TO_FLOAT(params[2]);
3002       fparam[3] = INT_TO_FLOAT(params[3]);
3003       break;
3004    case GL_POSITION:
3005       fparam[0] = (GLfloat) params[0];
3006       fparam[1] = (GLfloat) params[1];
3007       fparam[2] = (GLfloat) params[2];
3008       fparam[3] = (GLfloat) params[3];
3009       break;
3010    case GL_SPOT_DIRECTION:
3011       fparam[0] = (GLfloat) params[0];
3012       fparam[1] = (GLfloat) params[1];
3013       fparam[2] = (GLfloat) params[2];
3014       break;
3015    case GL_SPOT_EXPONENT:
3016    case GL_SPOT_CUTOFF:
3017    case GL_CONSTANT_ATTENUATION:
3018    case GL_LINEAR_ATTENUATION:
3019    case GL_QUADRATIC_ATTENUATION:
3020       fparam[0] = (GLfloat) params[0];
3021       break;
3022    default:
3023       /* error will be caught later in gl_Lightfv */
3024       ;
3025    }
3026    save_Lightfv(light, pname, fparam);
3027 }
3028 
3029 
3030 static void GLAPIENTRY
save_Lighti(GLenum light,GLenum pname,GLint param)3031 save_Lighti(GLenum light, GLenum pname, GLint param)
3032 {
3033    GLint parray[4];
3034    parray[0] = param;
3035    parray[1] = parray[2] = parray[3] = 0;
3036    save_Lightiv(light, pname, parray);
3037 }
3038 
3039 
3040 static void GLAPIENTRY
save_LightModelfv(GLenum pname,const GLfloat * params)3041 save_LightModelfv(GLenum pname, const GLfloat *params)
3042 {
3043    GET_CURRENT_CONTEXT(ctx);
3044    Node *n;
3045    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3046    n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5);
3047    if (n) {
3048       n[1].e = pname;
3049       n[2].f = params[0];
3050       n[3].f = params[1];
3051       n[4].f = params[2];
3052       n[5].f = params[3];
3053    }
3054    if (ctx->ExecuteFlag) {
3055       CALL_LightModelfv(ctx->Exec, (pname, params));
3056    }
3057 }
3058 
3059 
3060 static void GLAPIENTRY
save_LightModelf(GLenum pname,GLfloat param)3061 save_LightModelf(GLenum pname, GLfloat param)
3062 {
3063    GLfloat parray[4];
3064    parray[0] = param;
3065    parray[1] = parray[2] = parray[3] = 0.0F;
3066    save_LightModelfv(pname, parray);
3067 }
3068 
3069 
3070 static void GLAPIENTRY
save_LightModeliv(GLenum pname,const GLint * params)3071 save_LightModeliv(GLenum pname, const GLint *params)
3072 {
3073    GLfloat fparam[4];
3074    switch (pname) {
3075    case GL_LIGHT_MODEL_AMBIENT:
3076       fparam[0] = INT_TO_FLOAT(params[0]);
3077       fparam[1] = INT_TO_FLOAT(params[1]);
3078       fparam[2] = INT_TO_FLOAT(params[2]);
3079       fparam[3] = INT_TO_FLOAT(params[3]);
3080       break;
3081    case GL_LIGHT_MODEL_LOCAL_VIEWER:
3082    case GL_LIGHT_MODEL_TWO_SIDE:
3083    case GL_LIGHT_MODEL_COLOR_CONTROL:
3084       fparam[0] = (GLfloat) params[0];
3085       fparam[1] = 0.0F;
3086       fparam[2] = 0.0F;
3087       fparam[3] = 0.0F;
3088       break;
3089    default:
3090       /* Error will be caught later in gl_LightModelfv */
3091       ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F);
3092    }
3093    save_LightModelfv(pname, fparam);
3094 }
3095 
3096 
3097 static void GLAPIENTRY
save_LightModeli(GLenum pname,GLint param)3098 save_LightModeli(GLenum pname, GLint param)
3099 {
3100    GLint parray[4];
3101    parray[0] = param;
3102    parray[1] = parray[2] = parray[3] = 0;
3103    save_LightModeliv(pname, parray);
3104 }
3105 
3106 
3107 static void GLAPIENTRY
save_LineStipple(GLint factor,GLushort pattern)3108 save_LineStipple(GLint factor, GLushort pattern)
3109 {
3110    GET_CURRENT_CONTEXT(ctx);
3111    Node *n;
3112    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3113    n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2);
3114    if (n) {
3115       n[1].i = factor;
3116       n[2].us = pattern;
3117    }
3118    if (ctx->ExecuteFlag) {
3119       CALL_LineStipple(ctx->Exec, (factor, pattern));
3120    }
3121 }
3122 
3123 
3124 static void GLAPIENTRY
save_LineWidth(GLfloat width)3125 save_LineWidth(GLfloat width)
3126 {
3127    GET_CURRENT_CONTEXT(ctx);
3128    Node *n;
3129    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3130    n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1);
3131    if (n) {
3132       n[1].f = width;
3133    }
3134    if (ctx->ExecuteFlag) {
3135       CALL_LineWidth(ctx->Exec, (width));
3136    }
3137 }
3138 
3139 
3140 static void GLAPIENTRY
save_ListBase(GLuint base)3141 save_ListBase(GLuint base)
3142 {
3143    GET_CURRENT_CONTEXT(ctx);
3144    Node *n;
3145    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3146    n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1);
3147    if (n) {
3148       n[1].ui = base;
3149    }
3150    if (ctx->ExecuteFlag) {
3151       CALL_ListBase(ctx->Exec, (base));
3152    }
3153 }
3154 
3155 
3156 static void GLAPIENTRY
save_LoadIdentity(void)3157 save_LoadIdentity(void)
3158 {
3159    GET_CURRENT_CONTEXT(ctx);
3160    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3161    (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0);
3162    if (ctx->ExecuteFlag) {
3163       CALL_LoadIdentity(ctx->Exec, ());
3164    }
3165 }
3166 
3167 
3168 static void GLAPIENTRY
save_LoadMatrixf(const GLfloat * m)3169 save_LoadMatrixf(const GLfloat * m)
3170 {
3171    GET_CURRENT_CONTEXT(ctx);
3172    Node *n;
3173    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3174    n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16);
3175    if (n) {
3176       GLuint i;
3177       for (i = 0; i < 16; i++) {
3178          n[1 + i].f = m[i];
3179       }
3180    }
3181    if (ctx->ExecuteFlag) {
3182       CALL_LoadMatrixf(ctx->Exec, (m));
3183    }
3184 }
3185 
3186 
3187 static void GLAPIENTRY
save_LoadMatrixd(const GLdouble * m)3188 save_LoadMatrixd(const GLdouble * m)
3189 {
3190    GLfloat f[16];
3191    GLint i;
3192    for (i = 0; i < 16; i++) {
3193       f[i] = (GLfloat) m[i];
3194    }
3195    save_LoadMatrixf(f);
3196 }
3197 
3198 
3199 static void GLAPIENTRY
save_LoadName(GLuint name)3200 save_LoadName(GLuint name)
3201 {
3202    GET_CURRENT_CONTEXT(ctx);
3203    Node *n;
3204    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3205    n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1);
3206    if (n) {
3207       n[1].ui = name;
3208    }
3209    if (ctx->ExecuteFlag) {
3210       CALL_LoadName(ctx->Exec, (name));
3211    }
3212 }
3213 
3214 
3215 static void GLAPIENTRY
save_LogicOp(GLenum opcode)3216 save_LogicOp(GLenum opcode)
3217 {
3218    GET_CURRENT_CONTEXT(ctx);
3219    Node *n;
3220    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3221    n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1);
3222    if (n) {
3223       n[1].e = opcode;
3224    }
3225    if (ctx->ExecuteFlag) {
3226       CALL_LogicOp(ctx->Exec, (opcode));
3227    }
3228 }
3229 
3230 
3231 static void GLAPIENTRY
save_Map1d(GLenum target,GLdouble u1,GLdouble u2,GLint stride,GLint order,const GLdouble * points)3232 save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
3233            GLint order, const GLdouble * points)
3234 {
3235    GET_CURRENT_CONTEXT(ctx);
3236    Node *n;
3237    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3238    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
3239    if (n) {
3240       GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points);
3241       n[1].e = target;
3242       n[2].f = (GLfloat) u1;
3243       n[3].f = (GLfloat) u2;
3244       n[4].i = _mesa_evaluator_components(target);      /* stride */
3245       n[5].i = order;
3246       save_pointer(&n[6], pnts);
3247    }
3248    if (ctx->ExecuteFlag) {
3249       CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points));
3250    }
3251 }
3252 
3253 static void GLAPIENTRY
save_Map1f(GLenum target,GLfloat u1,GLfloat u2,GLint stride,GLint order,const GLfloat * points)3254 save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
3255            GLint order, const GLfloat * points)
3256 {
3257    GET_CURRENT_CONTEXT(ctx);
3258    Node *n;
3259    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3260    n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS);
3261    if (n) {
3262       GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points);
3263       n[1].e = target;
3264       n[2].f = u1;
3265       n[3].f = u2;
3266       n[4].i = _mesa_evaluator_components(target);      /* stride */
3267       n[5].i = order;
3268       save_pointer(&n[6], pnts);
3269    }
3270    if (ctx->ExecuteFlag) {
3271       CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points));
3272    }
3273 }
3274 
3275 
3276 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)3277 save_Map2d(GLenum target,
3278            GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
3279            GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
3280            const GLdouble * points)
3281 {
3282    GET_CURRENT_CONTEXT(ctx);
3283    Node *n;
3284    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3285    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
3286    if (n) {
3287       GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder,
3288                                               vstride, vorder, points);
3289       n[1].e = target;
3290       n[2].f = (GLfloat) u1;
3291       n[3].f = (GLfloat) u2;
3292       n[4].f = (GLfloat) v1;
3293       n[5].f = (GLfloat) v2;
3294       /* XXX verify these strides are correct */
3295       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
3296       n[7].i = _mesa_evaluator_components(target);      /*vstride */
3297       n[8].i = uorder;
3298       n[9].i = vorder;
3299       save_pointer(&n[10], pnts);
3300    }
3301    if (ctx->ExecuteFlag) {
3302       CALL_Map2d(ctx->Exec, (target,
3303                              u1, u2, ustride, uorder,
3304                              v1, v2, vstride, vorder, points));
3305    }
3306 }
3307 
3308 
3309 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)3310 save_Map2f(GLenum target,
3311            GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
3312            GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
3313            const GLfloat * points)
3314 {
3315    GET_CURRENT_CONTEXT(ctx);
3316    Node *n;
3317    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3318    n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS);
3319    if (n) {
3320       GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder,
3321                                               vstride, vorder, points);
3322       n[1].e = target;
3323       n[2].f = u1;
3324       n[3].f = u2;
3325       n[4].f = v1;
3326       n[5].f = v2;
3327       /* XXX verify these strides are correct */
3328       n[6].i = _mesa_evaluator_components(target) * vorder;     /*ustride */
3329       n[7].i = _mesa_evaluator_components(target);      /*vstride */
3330       n[8].i = uorder;
3331       n[9].i = vorder;
3332       save_pointer(&n[10], pnts);
3333    }
3334    if (ctx->ExecuteFlag) {
3335       CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
3336                              v1, v2, vstride, vorder, points));
3337    }
3338 }
3339 
3340 
3341 static void GLAPIENTRY
save_MapGrid1f(GLint un,GLfloat u1,GLfloat u2)3342 save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
3343 {
3344    GET_CURRENT_CONTEXT(ctx);
3345    Node *n;
3346    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3347    n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3);
3348    if (n) {
3349       n[1].i = un;
3350       n[2].f = u1;
3351       n[3].f = u2;
3352    }
3353    if (ctx->ExecuteFlag) {
3354       CALL_MapGrid1f(ctx->Exec, (un, u1, u2));
3355    }
3356 }
3357 
3358 
3359 static void GLAPIENTRY
save_MapGrid1d(GLint un,GLdouble u1,GLdouble u2)3360 save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
3361 {
3362    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
3363 }
3364 
3365 
3366 static void GLAPIENTRY
save_MapGrid2f(GLint un,GLfloat u1,GLfloat u2,GLint vn,GLfloat v1,GLfloat v2)3367 save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2,
3368                GLint vn, GLfloat v1, GLfloat v2)
3369 {
3370    GET_CURRENT_CONTEXT(ctx);
3371    Node *n;
3372    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3373    n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6);
3374    if (n) {
3375       n[1].i = un;
3376       n[2].f = u1;
3377       n[3].f = u2;
3378       n[4].i = vn;
3379       n[5].f = v1;
3380       n[6].f = v2;
3381    }
3382    if (ctx->ExecuteFlag) {
3383       CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2));
3384    }
3385 }
3386 
3387 
3388 
3389 static void GLAPIENTRY
save_MapGrid2d(GLint un,GLdouble u1,GLdouble u2,GLint vn,GLdouble v1,GLdouble v2)3390 save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2,
3391                GLint vn, GLdouble v1, GLdouble v2)
3392 {
3393    save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
3394                   vn, (GLfloat) v1, (GLfloat) v2);
3395 }
3396 
3397 
3398 static void GLAPIENTRY
save_MatrixMode(GLenum mode)3399 save_MatrixMode(GLenum mode)
3400 {
3401    GET_CURRENT_CONTEXT(ctx);
3402    Node *n;
3403    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3404    n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1);
3405    if (n) {
3406       n[1].e = mode;
3407    }
3408    if (ctx->ExecuteFlag) {
3409       CALL_MatrixMode(ctx->Exec, (mode));
3410    }
3411 }
3412 
3413 
3414 static void GLAPIENTRY
save_MultMatrixf(const GLfloat * m)3415 save_MultMatrixf(const GLfloat * m)
3416 {
3417    GET_CURRENT_CONTEXT(ctx);
3418    Node *n;
3419    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3420    n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16);
3421    if (n) {
3422       GLuint i;
3423       for (i = 0; i < 16; i++) {
3424          n[1 + i].f = m[i];
3425       }
3426    }
3427    if (ctx->ExecuteFlag) {
3428       CALL_MultMatrixf(ctx->Exec, (m));
3429    }
3430 }
3431 
3432 
3433 static void GLAPIENTRY
save_MultMatrixd(const GLdouble * m)3434 save_MultMatrixd(const GLdouble * m)
3435 {
3436    GLfloat f[16];
3437    GLint i;
3438    for (i = 0; i < 16; i++) {
3439       f[i] = (GLfloat) m[i];
3440    }
3441    save_MultMatrixf(f);
3442 }
3443 
3444 
3445 static void GLAPIENTRY
save_NewList(GLuint name,GLenum mode)3446 save_NewList(GLuint name, GLenum mode)
3447 {
3448    GET_CURRENT_CONTEXT(ctx);
3449    /* It's an error to call this function while building a display list */
3450    _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
3451    (void) name;
3452    (void) mode;
3453 }
3454 
3455 
3456 
3457 static void GLAPIENTRY
save_Ortho(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)3458 save_Ortho(GLdouble left, GLdouble right,
3459            GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
3460 {
3461    GET_CURRENT_CONTEXT(ctx);
3462    Node *n;
3463    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3464    n = alloc_instruction(ctx, OPCODE_ORTHO, 6);
3465    if (n) {
3466       n[1].f = (GLfloat) left;
3467       n[2].f = (GLfloat) right;
3468       n[3].f = (GLfloat) bottom;
3469       n[4].f = (GLfloat) top;
3470       n[5].f = (GLfloat) nearval;
3471       n[6].f = (GLfloat) farval;
3472    }
3473    if (ctx->ExecuteFlag) {
3474       CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval));
3475    }
3476 }
3477 
3478 
3479 static void GLAPIENTRY
save_PatchParameteri(GLenum pname,const GLint value)3480 save_PatchParameteri(GLenum pname, const GLint value)
3481 {
3482    GET_CURRENT_CONTEXT(ctx);
3483    Node *n;
3484    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3485    n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_I, 2);
3486    if (n) {
3487       n[1].e = pname;
3488       n[2].i = value;
3489    }
3490    if (ctx->ExecuteFlag) {
3491       CALL_PatchParameteri(ctx->Exec, (pname, value));
3492    }
3493 }
3494 
3495 
3496 static void GLAPIENTRY
save_PatchParameterfv(GLenum pname,const GLfloat * params)3497 save_PatchParameterfv(GLenum pname, const GLfloat *params)
3498 {
3499    GET_CURRENT_CONTEXT(ctx);
3500    Node *n;
3501    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3502 
3503    if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3504       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_OUTER, 5);
3505    } else {
3506       assert(pname == GL_PATCH_DEFAULT_INNER_LEVEL);
3507       n = alloc_instruction(ctx, OPCODE_PATCH_PARAMETER_FV_INNER, 3);
3508    }
3509    if (n) {
3510       n[1].e = pname;
3511       if (pname == GL_PATCH_DEFAULT_OUTER_LEVEL) {
3512          n[2].f = params[0];
3513          n[3].f = params[1];
3514          n[4].f = params[2];
3515          n[5].f = params[3];
3516       } else {
3517          n[2].f = params[0];
3518          n[3].f = params[1];
3519       }
3520    }
3521    if (ctx->ExecuteFlag) {
3522       CALL_PatchParameterfv(ctx->Exec, (pname, params));
3523    }
3524 }
3525 
3526 
3527 static void GLAPIENTRY
save_PixelMapfv(GLenum map,GLint mapsize,const GLfloat * values)3528 save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
3529 {
3530    GET_CURRENT_CONTEXT(ctx);
3531    Node *n;
3532    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3533    n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 2 + POINTER_DWORDS);
3534    if (n) {
3535       n[1].e = map;
3536       n[2].i = mapsize;
3537       save_pointer(&n[3], memdup(values, mapsize * sizeof(GLfloat)));
3538    }
3539    if (ctx->ExecuteFlag) {
3540       CALL_PixelMapfv(ctx->Exec, (map, mapsize, values));
3541    }
3542 }
3543 
3544 
3545 static void GLAPIENTRY
save_PixelMapuiv(GLenum map,GLint mapsize,const GLuint * values)3546 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
3547 {
3548    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3549    GLint i;
3550    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3551       for (i = 0; i < mapsize; i++) {
3552          fvalues[i] = (GLfloat) values[i];
3553       }
3554    }
3555    else {
3556       for (i = 0; i < mapsize; i++) {
3557          fvalues[i] = UINT_TO_FLOAT(values[i]);
3558       }
3559    }
3560    save_PixelMapfv(map, mapsize, fvalues);
3561 }
3562 
3563 
3564 static void GLAPIENTRY
save_PixelMapusv(GLenum map,GLint mapsize,const GLushort * values)3565 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
3566 {
3567    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
3568    GLint i;
3569    if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
3570       for (i = 0; i < mapsize; i++) {
3571          fvalues[i] = (GLfloat) values[i];
3572       }
3573    }
3574    else {
3575       for (i = 0; i < mapsize; i++) {
3576          fvalues[i] = USHORT_TO_FLOAT(values[i]);
3577       }
3578    }
3579    save_PixelMapfv(map, mapsize, fvalues);
3580 }
3581 
3582 
3583 static void GLAPIENTRY
save_PixelTransferf(GLenum pname,GLfloat param)3584 save_PixelTransferf(GLenum pname, GLfloat param)
3585 {
3586    GET_CURRENT_CONTEXT(ctx);
3587    Node *n;
3588    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3589    n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2);
3590    if (n) {
3591       n[1].e = pname;
3592       n[2].f = param;
3593    }
3594    if (ctx->ExecuteFlag) {
3595       CALL_PixelTransferf(ctx->Exec, (pname, param));
3596    }
3597 }
3598 
3599 
3600 static void GLAPIENTRY
save_PixelTransferi(GLenum pname,GLint param)3601 save_PixelTransferi(GLenum pname, GLint param)
3602 {
3603    save_PixelTransferf(pname, (GLfloat) param);
3604 }
3605 
3606 
3607 static void GLAPIENTRY
save_PixelZoom(GLfloat xfactor,GLfloat yfactor)3608 save_PixelZoom(GLfloat xfactor, GLfloat yfactor)
3609 {
3610    GET_CURRENT_CONTEXT(ctx);
3611    Node *n;
3612    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3613    n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2);
3614    if (n) {
3615       n[1].f = xfactor;
3616       n[2].f = yfactor;
3617    }
3618    if (ctx->ExecuteFlag) {
3619       CALL_PixelZoom(ctx->Exec, (xfactor, yfactor));
3620    }
3621 }
3622 
3623 
3624 static void GLAPIENTRY
save_PointParameterfvEXT(GLenum pname,const GLfloat * params)3625 save_PointParameterfvEXT(GLenum pname, const GLfloat *params)
3626 {
3627    GET_CURRENT_CONTEXT(ctx);
3628    Node *n;
3629    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3630    n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4);
3631    if (n) {
3632       n[1].e = pname;
3633       n[2].f = params[0];
3634       n[3].f = params[1];
3635       n[4].f = params[2];
3636    }
3637    if (ctx->ExecuteFlag) {
3638       CALL_PointParameterfv(ctx->Exec, (pname, params));
3639    }
3640 }
3641 
3642 
3643 static void GLAPIENTRY
save_PointParameterfEXT(GLenum pname,GLfloat param)3644 save_PointParameterfEXT(GLenum pname, GLfloat param)
3645 {
3646    GLfloat parray[3];
3647    parray[0] = param;
3648    parray[1] = parray[2] = 0.0F;
3649    save_PointParameterfvEXT(pname, parray);
3650 }
3651 
3652 static void GLAPIENTRY
save_PointParameteri(GLenum pname,GLint param)3653 save_PointParameteri(GLenum pname, GLint param)
3654 {
3655    GLfloat parray[3];
3656    parray[0] = (GLfloat) param;
3657    parray[1] = parray[2] = 0.0F;
3658    save_PointParameterfvEXT(pname, parray);
3659 }
3660 
3661 static void GLAPIENTRY
save_PointParameteriv(GLenum pname,const GLint * param)3662 save_PointParameteriv(GLenum pname, const GLint * param)
3663 {
3664    GLfloat parray[3];
3665    parray[0] = (GLfloat) param[0];
3666    parray[1] = parray[2] = 0.0F;
3667    save_PointParameterfvEXT(pname, parray);
3668 }
3669 
3670 
3671 static void GLAPIENTRY
save_PointSize(GLfloat size)3672 save_PointSize(GLfloat size)
3673 {
3674    GET_CURRENT_CONTEXT(ctx);
3675    Node *n;
3676    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3677    n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1);
3678    if (n) {
3679       n[1].f = size;
3680    }
3681    if (ctx->ExecuteFlag) {
3682       CALL_PointSize(ctx->Exec, (size));
3683    }
3684 }
3685 
3686 
3687 static void GLAPIENTRY
save_PolygonMode(GLenum face,GLenum mode)3688 save_PolygonMode(GLenum face, GLenum mode)
3689 {
3690    GET_CURRENT_CONTEXT(ctx);
3691    Node *n;
3692    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3693    n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2);
3694    if (n) {
3695       n[1].e = face;
3696       n[2].e = mode;
3697    }
3698    if (ctx->ExecuteFlag) {
3699       CALL_PolygonMode(ctx->Exec, (face, mode));
3700    }
3701 }
3702 
3703 
3704 static void GLAPIENTRY
save_PolygonStipple(const GLubyte * pattern)3705 save_PolygonStipple(const GLubyte * pattern)
3706 {
3707    GET_CURRENT_CONTEXT(ctx);
3708    Node *n;
3709 
3710    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3711 
3712    n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, POINTER_DWORDS);
3713    if (n) {
3714       save_pointer(&n[1],
3715                    unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
3716                                 pattern, &ctx->Unpack));
3717    }
3718    if (ctx->ExecuteFlag) {
3719       CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
3720    }
3721 }
3722 
3723 
3724 static void GLAPIENTRY
save_PolygonOffset(GLfloat factor,GLfloat units)3725 save_PolygonOffset(GLfloat factor, GLfloat units)
3726 {
3727    GET_CURRENT_CONTEXT(ctx);
3728    Node *n;
3729    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3730    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2);
3731    if (n) {
3732       n[1].f = factor;
3733       n[2].f = units;
3734    }
3735    if (ctx->ExecuteFlag) {
3736       CALL_PolygonOffset(ctx->Exec, (factor, units));
3737    }
3738 }
3739 
3740 
3741 static void GLAPIENTRY
save_PolygonOffsetClampEXT(GLfloat factor,GLfloat units,GLfloat clamp)3742 save_PolygonOffsetClampEXT(GLfloat factor, GLfloat units, GLfloat clamp)
3743 {
3744    GET_CURRENT_CONTEXT(ctx);
3745    Node *n;
3746    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3747    n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET_CLAMP, 3);
3748    if (n) {
3749       n[1].f = factor;
3750       n[2].f = units;
3751       n[3].f = clamp;
3752    }
3753    if (ctx->ExecuteFlag) {
3754       CALL_PolygonOffsetClampEXT(ctx->Exec, (factor, units, clamp));
3755    }
3756 }
3757 
3758 static void GLAPIENTRY
save_PopAttrib(void)3759 save_PopAttrib(void)
3760 {
3761    GET_CURRENT_CONTEXT(ctx);
3762    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3763    (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0);
3764    if (ctx->ExecuteFlag) {
3765       CALL_PopAttrib(ctx->Exec, ());
3766    }
3767 }
3768 
3769 
3770 static void GLAPIENTRY
save_PopMatrix(void)3771 save_PopMatrix(void)
3772 {
3773    GET_CURRENT_CONTEXT(ctx);
3774    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3775    (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0);
3776    if (ctx->ExecuteFlag) {
3777       CALL_PopMatrix(ctx->Exec, ());
3778    }
3779 }
3780 
3781 
3782 static void GLAPIENTRY
save_PopName(void)3783 save_PopName(void)
3784 {
3785    GET_CURRENT_CONTEXT(ctx);
3786    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3787    (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0);
3788    if (ctx->ExecuteFlag) {
3789       CALL_PopName(ctx->Exec, ());
3790    }
3791 }
3792 
3793 
3794 static void GLAPIENTRY
save_PrioritizeTextures(GLsizei num,const GLuint * textures,const GLclampf * priorities)3795 save_PrioritizeTextures(GLsizei num, const GLuint * textures,
3796                         const GLclampf * priorities)
3797 {
3798    GET_CURRENT_CONTEXT(ctx);
3799    GLint i;
3800    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3801 
3802    for (i = 0; i < num; i++) {
3803       Node *n;
3804       n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2);
3805       if (n) {
3806          n[1].ui = textures[i];
3807          n[2].f = priorities[i];
3808       }
3809    }
3810    if (ctx->ExecuteFlag) {
3811       CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities));
3812    }
3813 }
3814 
3815 
3816 static void GLAPIENTRY
save_PushAttrib(GLbitfield mask)3817 save_PushAttrib(GLbitfield mask)
3818 {
3819    GET_CURRENT_CONTEXT(ctx);
3820    Node *n;
3821    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3822    n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1);
3823    if (n) {
3824       n[1].bf = mask;
3825    }
3826    if (ctx->ExecuteFlag) {
3827       CALL_PushAttrib(ctx->Exec, (mask));
3828    }
3829 }
3830 
3831 
3832 static void GLAPIENTRY
save_PushMatrix(void)3833 save_PushMatrix(void)
3834 {
3835    GET_CURRENT_CONTEXT(ctx);
3836    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3837    (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0);
3838    if (ctx->ExecuteFlag) {
3839       CALL_PushMatrix(ctx->Exec, ());
3840    }
3841 }
3842 
3843 
3844 static void GLAPIENTRY
save_PushName(GLuint name)3845 save_PushName(GLuint name)
3846 {
3847    GET_CURRENT_CONTEXT(ctx);
3848    Node *n;
3849    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3850    n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1);
3851    if (n) {
3852       n[1].ui = name;
3853    }
3854    if (ctx->ExecuteFlag) {
3855       CALL_PushName(ctx->Exec, (name));
3856    }
3857 }
3858 
3859 
3860 static void GLAPIENTRY
save_RasterPos4f(GLfloat x,GLfloat y,GLfloat z,GLfloat w)3861 save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
3862 {
3863    GET_CURRENT_CONTEXT(ctx);
3864    Node *n;
3865    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
3866    n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4);
3867    if (n) {
3868       n[1].f = x;
3869       n[2].f = y;
3870       n[3].f = z;
3871       n[4].f = w;
3872    }
3873    if (ctx->ExecuteFlag) {
3874       CALL_RasterPos4f(ctx->Exec, (x, y, z, w));
3875    }
3876 }
3877 
3878 static void GLAPIENTRY
save_RasterPos2d(GLdouble x,GLdouble y)3879 save_RasterPos2d(GLdouble x, GLdouble y)
3880 {
3881    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3882 }
3883 
3884 static void GLAPIENTRY
save_RasterPos2f(GLfloat x,GLfloat y)3885 save_RasterPos2f(GLfloat x, GLfloat y)
3886 {
3887    save_RasterPos4f(x, y, 0.0F, 1.0F);
3888 }
3889 
3890 static void GLAPIENTRY
save_RasterPos2i(GLint x,GLint y)3891 save_RasterPos2i(GLint x, GLint y)
3892 {
3893    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
3894 }
3895 
3896 static void GLAPIENTRY
save_RasterPos2s(GLshort x,GLshort y)3897 save_RasterPos2s(GLshort x, GLshort y)
3898 {
3899    save_RasterPos4f(x, y, 0.0F, 1.0F);
3900 }
3901 
3902 static void GLAPIENTRY
save_RasterPos3d(GLdouble x,GLdouble y,GLdouble z)3903 save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
3904 {
3905    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3906 }
3907 
3908 static void GLAPIENTRY
save_RasterPos3f(GLfloat x,GLfloat y,GLfloat z)3909 save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
3910 {
3911    save_RasterPos4f(x, y, z, 1.0F);
3912 }
3913 
3914 static void GLAPIENTRY
save_RasterPos3i(GLint x,GLint y,GLint z)3915 save_RasterPos3i(GLint x, GLint y, GLint z)
3916 {
3917    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
3918 }
3919 
3920 static void GLAPIENTRY
save_RasterPos3s(GLshort x,GLshort y,GLshort z)3921 save_RasterPos3s(GLshort x, GLshort y, GLshort z)
3922 {
3923    save_RasterPos4f(x, y, z, 1.0F);
3924 }
3925 
3926 static void GLAPIENTRY
save_RasterPos4d(GLdouble x,GLdouble y,GLdouble z,GLdouble w)3927 save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3928 {
3929    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3930 }
3931 
3932 static void GLAPIENTRY
save_RasterPos4i(GLint x,GLint y,GLint z,GLint w)3933 save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
3934 {
3935    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
3936 }
3937 
3938 static void GLAPIENTRY
save_RasterPos4s(GLshort x,GLshort y,GLshort z,GLshort w)3939 save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
3940 {
3941    save_RasterPos4f(x, y, z, w);
3942 }
3943 
3944 static void GLAPIENTRY
save_RasterPos2dv(const GLdouble * v)3945 save_RasterPos2dv(const GLdouble * v)
3946 {
3947    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3948 }
3949 
3950 static void GLAPIENTRY
save_RasterPos2fv(const GLfloat * v)3951 save_RasterPos2fv(const GLfloat * v)
3952 {
3953    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3954 }
3955 
3956 static void GLAPIENTRY
save_RasterPos2iv(const GLint * v)3957 save_RasterPos2iv(const GLint * v)
3958 {
3959    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
3960 }
3961 
3962 static void GLAPIENTRY
save_RasterPos2sv(const GLshort * v)3963 save_RasterPos2sv(const GLshort * v)
3964 {
3965    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
3966 }
3967 
3968 static void GLAPIENTRY
save_RasterPos3dv(const GLdouble * v)3969 save_RasterPos3dv(const GLdouble * v)
3970 {
3971    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3972 }
3973 
3974 static void GLAPIENTRY
save_RasterPos3fv(const GLfloat * v)3975 save_RasterPos3fv(const GLfloat * v)
3976 {
3977    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3978 }
3979 
3980 static void GLAPIENTRY
save_RasterPos3iv(const GLint * v)3981 save_RasterPos3iv(const GLint * v)
3982 {
3983    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
3984 }
3985 
3986 static void GLAPIENTRY
save_RasterPos3sv(const GLshort * v)3987 save_RasterPos3sv(const GLshort * v)
3988 {
3989    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
3990 }
3991 
3992 static void GLAPIENTRY
save_RasterPos4dv(const GLdouble * v)3993 save_RasterPos4dv(const GLdouble * v)
3994 {
3995    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
3996                     (GLfloat) v[2], (GLfloat) v[3]);
3997 }
3998 
3999 static void GLAPIENTRY
save_RasterPos4fv(const GLfloat * v)4000 save_RasterPos4fv(const GLfloat * v)
4001 {
4002    save_RasterPos4f(v[0], v[1], v[2], v[3]);
4003 }
4004 
4005 static void GLAPIENTRY
save_RasterPos4iv(const GLint * v)4006 save_RasterPos4iv(const GLint * v)
4007 {
4008    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
4009                     (GLfloat) v[2], (GLfloat) v[3]);
4010 }
4011 
4012 static void GLAPIENTRY
save_RasterPos4sv(const GLshort * v)4013 save_RasterPos4sv(const GLshort * v)
4014 {
4015    save_RasterPos4f(v[0], v[1], v[2], v[3]);
4016 }
4017 
4018 
4019 static void GLAPIENTRY
save_PassThrough(GLfloat token)4020 save_PassThrough(GLfloat token)
4021 {
4022    GET_CURRENT_CONTEXT(ctx);
4023    Node *n;
4024    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4025    n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1);
4026    if (n) {
4027       n[1].f = token;
4028    }
4029    if (ctx->ExecuteFlag) {
4030       CALL_PassThrough(ctx->Exec, (token));
4031    }
4032 }
4033 
4034 
4035 static void GLAPIENTRY
save_ReadBuffer(GLenum mode)4036 save_ReadBuffer(GLenum mode)
4037 {
4038    GET_CURRENT_CONTEXT(ctx);
4039    Node *n;
4040    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4041    n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1);
4042    if (n) {
4043       n[1].e = mode;
4044    }
4045    if (ctx->ExecuteFlag) {
4046       CALL_ReadBuffer(ctx->Exec, (mode));
4047    }
4048 }
4049 
4050 
4051 static void GLAPIENTRY
save_Rotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)4052 save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
4053 {
4054    GET_CURRENT_CONTEXT(ctx);
4055    Node *n;
4056    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4057    n = alloc_instruction(ctx, OPCODE_ROTATE, 4);
4058    if (n) {
4059       n[1].f = angle;
4060       n[2].f = x;
4061       n[3].f = y;
4062       n[4].f = z;
4063    }
4064    if (ctx->ExecuteFlag) {
4065       CALL_Rotatef(ctx->Exec, (angle, x, y, z));
4066    }
4067 }
4068 
4069 
4070 static void GLAPIENTRY
save_Rotated(GLdouble angle,GLdouble x,GLdouble y,GLdouble z)4071 save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
4072 {
4073    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
4074 }
4075 
4076 
4077 static void GLAPIENTRY
save_Scalef(GLfloat x,GLfloat y,GLfloat z)4078 save_Scalef(GLfloat x, GLfloat y, GLfloat z)
4079 {
4080    GET_CURRENT_CONTEXT(ctx);
4081    Node *n;
4082    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4083    n = alloc_instruction(ctx, OPCODE_SCALE, 3);
4084    if (n) {
4085       n[1].f = x;
4086       n[2].f = y;
4087       n[3].f = z;
4088    }
4089    if (ctx->ExecuteFlag) {
4090       CALL_Scalef(ctx->Exec, (x, y, z));
4091    }
4092 }
4093 
4094 
4095 static void GLAPIENTRY
save_Scaled(GLdouble x,GLdouble y,GLdouble z)4096 save_Scaled(GLdouble x, GLdouble y, GLdouble z)
4097 {
4098    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4099 }
4100 
4101 
4102 static void GLAPIENTRY
save_Scissor(GLint x,GLint y,GLsizei width,GLsizei height)4103 save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
4104 {
4105    GET_CURRENT_CONTEXT(ctx);
4106    Node *n;
4107    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4108    n = alloc_instruction(ctx, OPCODE_SCISSOR, 4);
4109    if (n) {
4110       n[1].i = x;
4111       n[2].i = y;
4112       n[3].i = width;
4113       n[4].i = height;
4114    }
4115    if (ctx->ExecuteFlag) {
4116       CALL_Scissor(ctx->Exec, (x, y, width, height));
4117    }
4118 }
4119 
4120 
4121 static void GLAPIENTRY
save_ShadeModel(GLenum mode)4122 save_ShadeModel(GLenum mode)
4123 {
4124    GET_CURRENT_CONTEXT(ctx);
4125    Node *n;
4126    ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
4127 
4128    if (ctx->ExecuteFlag) {
4129       CALL_ShadeModel(ctx->Exec, (mode));
4130    }
4131 
4132    /* Don't compile this call if it's a no-op.
4133     * By avoiding this state change we have a better chance of
4134     * coalescing subsequent drawing commands into one batch.
4135     */
4136    if (ctx->ListState.Current.ShadeModel == mode)
4137       return;
4138 
4139    SAVE_FLUSH_VERTICES(ctx);
4140 
4141    ctx->ListState.Current.ShadeModel = mode;
4142 
4143    n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
4144    if (n) {
4145       n[1].e = mode;
4146    }
4147 }
4148 
4149 
4150 static void GLAPIENTRY
save_StencilFunc(GLenum func,GLint ref,GLuint mask)4151 save_StencilFunc(GLenum func, GLint ref, GLuint mask)
4152 {
4153    GET_CURRENT_CONTEXT(ctx);
4154    Node *n;
4155    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4156    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3);
4157    if (n) {
4158       n[1].e = func;
4159       n[2].i = ref;
4160       n[3].ui = mask;
4161    }
4162    if (ctx->ExecuteFlag) {
4163       CALL_StencilFunc(ctx->Exec, (func, ref, mask));
4164    }
4165 }
4166 
4167 
4168 static void GLAPIENTRY
save_StencilMask(GLuint mask)4169 save_StencilMask(GLuint mask)
4170 {
4171    GET_CURRENT_CONTEXT(ctx);
4172    Node *n;
4173    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4174    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1);
4175    if (n) {
4176       n[1].ui = mask;
4177    }
4178    if (ctx->ExecuteFlag) {
4179       CALL_StencilMask(ctx->Exec, (mask));
4180    }
4181 }
4182 
4183 
4184 static void GLAPIENTRY
save_StencilOp(GLenum fail,GLenum zfail,GLenum zpass)4185 save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
4186 {
4187    GET_CURRENT_CONTEXT(ctx);
4188    Node *n;
4189    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4190    n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3);
4191    if (n) {
4192       n[1].e = fail;
4193       n[2].e = zfail;
4194       n[3].e = zpass;
4195    }
4196    if (ctx->ExecuteFlag) {
4197       CALL_StencilOp(ctx->Exec, (fail, zfail, zpass));
4198    }
4199 }
4200 
4201 
4202 static void GLAPIENTRY
save_StencilFuncSeparate(GLenum face,GLenum func,GLint ref,GLuint mask)4203 save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
4204 {
4205    GET_CURRENT_CONTEXT(ctx);
4206    Node *n;
4207    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4208    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4209    if (n) {
4210       n[1].e = face;
4211       n[2].e = func;
4212       n[3].i = ref;
4213       n[4].ui = mask;
4214    }
4215    if (ctx->ExecuteFlag) {
4216       CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
4217    }
4218 }
4219 
4220 
4221 static void GLAPIENTRY
save_StencilFuncSeparateATI(GLenum frontfunc,GLenum backfunc,GLint ref,GLuint mask)4222 save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
4223                             GLuint mask)
4224 {
4225    GET_CURRENT_CONTEXT(ctx);
4226    Node *n;
4227    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4228    /* GL_FRONT */
4229    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4230    if (n) {
4231       n[1].e = GL_FRONT;
4232       n[2].e = frontfunc;
4233       n[3].i = ref;
4234       n[4].ui = mask;
4235    }
4236    /* GL_BACK */
4237    n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
4238    if (n) {
4239       n[1].e = GL_BACK;
4240       n[2].e = backfunc;
4241       n[3].i = ref;
4242       n[4].ui = mask;
4243    }
4244    if (ctx->ExecuteFlag) {
4245       CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
4246       CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
4247    }
4248 }
4249 
4250 
4251 static void GLAPIENTRY
save_StencilMaskSeparate(GLenum face,GLuint mask)4252 save_StencilMaskSeparate(GLenum face, GLuint mask)
4253 {
4254    GET_CURRENT_CONTEXT(ctx);
4255    Node *n;
4256    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4257    n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
4258    if (n) {
4259       n[1].e = face;
4260       n[2].ui = mask;
4261    }
4262    if (ctx->ExecuteFlag) {
4263       CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
4264    }
4265 }
4266 
4267 
4268 static void GLAPIENTRY
save_StencilOpSeparate(GLenum face,GLenum fail,GLenum zfail,GLenum zpass)4269 save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
4270 {
4271    GET_CURRENT_CONTEXT(ctx);
4272    Node *n;
4273    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4274    n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4);
4275    if (n) {
4276       n[1].e = face;
4277       n[2].e = fail;
4278       n[3].e = zfail;
4279       n[4].e = zpass;
4280    }
4281    if (ctx->ExecuteFlag) {
4282       CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
4283    }
4284 }
4285 
4286 
4287 static void GLAPIENTRY
save_TexEnvfv(GLenum target,GLenum pname,const GLfloat * params)4288 save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
4289 {
4290    GET_CURRENT_CONTEXT(ctx);
4291    Node *n;
4292    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4293    n = alloc_instruction(ctx, OPCODE_TEXENV, 6);
4294    if (n) {
4295       n[1].e = target;
4296       n[2].e = pname;
4297       if (pname == GL_TEXTURE_ENV_COLOR) {
4298          n[3].f = params[0];
4299          n[4].f = params[1];
4300          n[5].f = params[2];
4301          n[6].f = params[3];
4302       }
4303       else {
4304          n[3].f = params[0];
4305          n[4].f = n[5].f = n[6].f = 0.0F;
4306       }
4307    }
4308    if (ctx->ExecuteFlag) {
4309       CALL_TexEnvfv(ctx->Exec, (target, pname, params));
4310    }
4311 }
4312 
4313 
4314 static void GLAPIENTRY
save_TexEnvf(GLenum target,GLenum pname,GLfloat param)4315 save_TexEnvf(GLenum target, GLenum pname, GLfloat param)
4316 {
4317    GLfloat parray[4];
4318    parray[0] = (GLfloat) param;
4319    parray[1] = parray[2] = parray[3] = 0.0F;
4320    save_TexEnvfv(target, pname, parray);
4321 }
4322 
4323 
4324 static void GLAPIENTRY
save_TexEnvi(GLenum target,GLenum pname,GLint param)4325 save_TexEnvi(GLenum target, GLenum pname, GLint param)
4326 {
4327    GLfloat p[4];
4328    p[0] = (GLfloat) param;
4329    p[1] = p[2] = p[3] = 0.0F;
4330    save_TexEnvfv(target, pname, p);
4331 }
4332 
4333 
4334 static void GLAPIENTRY
save_TexEnviv(GLenum target,GLenum pname,const GLint * param)4335 save_TexEnviv(GLenum target, GLenum pname, const GLint * param)
4336 {
4337    GLfloat p[4];
4338    if (pname == GL_TEXTURE_ENV_COLOR) {
4339       p[0] = INT_TO_FLOAT(param[0]);
4340       p[1] = INT_TO_FLOAT(param[1]);
4341       p[2] = INT_TO_FLOAT(param[2]);
4342       p[3] = INT_TO_FLOAT(param[3]);
4343    }
4344    else {
4345       p[0] = (GLfloat) param[0];
4346       p[1] = p[2] = p[3] = 0.0F;
4347    }
4348    save_TexEnvfv(target, pname, p);
4349 }
4350 
4351 
4352 static void GLAPIENTRY
save_TexGenfv(GLenum coord,GLenum pname,const GLfloat * params)4353 save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
4354 {
4355    GET_CURRENT_CONTEXT(ctx);
4356    Node *n;
4357    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4358    n = alloc_instruction(ctx, OPCODE_TEXGEN, 6);
4359    if (n) {
4360       n[1].e = coord;
4361       n[2].e = pname;
4362       n[3].f = params[0];
4363       n[4].f = params[1];
4364       n[5].f = params[2];
4365       n[6].f = params[3];
4366    }
4367    if (ctx->ExecuteFlag) {
4368       CALL_TexGenfv(ctx->Exec, (coord, pname, params));
4369    }
4370 }
4371 
4372 
4373 static void GLAPIENTRY
save_TexGeniv(GLenum coord,GLenum pname,const GLint * params)4374 save_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
4375 {
4376    GLfloat p[4];
4377    p[0] = (GLfloat) params[0];
4378    p[1] = (GLfloat) params[1];
4379    p[2] = (GLfloat) params[2];
4380    p[3] = (GLfloat) params[3];
4381    save_TexGenfv(coord, pname, p);
4382 }
4383 
4384 
4385 static void GLAPIENTRY
save_TexGend(GLenum coord,GLenum pname,GLdouble param)4386 save_TexGend(GLenum coord, GLenum pname, GLdouble param)
4387 {
4388    GLfloat parray[4];
4389    parray[0] = (GLfloat) param;
4390    parray[1] = parray[2] = parray[3] = 0.0F;
4391    save_TexGenfv(coord, pname, parray);
4392 }
4393 
4394 
4395 static void GLAPIENTRY
save_TexGendv(GLenum coord,GLenum pname,const GLdouble * params)4396 save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
4397 {
4398    GLfloat p[4];
4399    p[0] = (GLfloat) params[0];
4400    p[1] = (GLfloat) params[1];
4401    p[2] = (GLfloat) params[2];
4402    p[3] = (GLfloat) params[3];
4403    save_TexGenfv(coord, pname, p);
4404 }
4405 
4406 
4407 static void GLAPIENTRY
save_TexGenf(GLenum coord,GLenum pname,GLfloat param)4408 save_TexGenf(GLenum coord, GLenum pname, GLfloat param)
4409 {
4410    GLfloat parray[4];
4411    parray[0] = param;
4412    parray[1] = parray[2] = parray[3] = 0.0F;
4413    save_TexGenfv(coord, pname, parray);
4414 }
4415 
4416 
4417 static void GLAPIENTRY
save_TexGeni(GLenum coord,GLenum pname,GLint param)4418 save_TexGeni(GLenum coord, GLenum pname, GLint param)
4419 {
4420    GLint parray[4];
4421    parray[0] = param;
4422    parray[1] = parray[2] = parray[3] = 0;
4423    save_TexGeniv(coord, pname, parray);
4424 }
4425 
4426 
4427 static void GLAPIENTRY
save_TexParameterfv(GLenum target,GLenum pname,const GLfloat * params)4428 save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
4429 {
4430    GET_CURRENT_CONTEXT(ctx);
4431    Node *n;
4432    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4433    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6);
4434    if (n) {
4435       n[1].e = target;
4436       n[2].e = pname;
4437       n[3].f = params[0];
4438       n[4].f = params[1];
4439       n[5].f = params[2];
4440       n[6].f = params[3];
4441    }
4442    if (ctx->ExecuteFlag) {
4443       CALL_TexParameterfv(ctx->Exec, (target, pname, params));
4444    }
4445 }
4446 
4447 
4448 static void GLAPIENTRY
save_TexParameterf(GLenum target,GLenum pname,GLfloat param)4449 save_TexParameterf(GLenum target, GLenum pname, GLfloat param)
4450 {
4451    GLfloat parray[4];
4452    parray[0] = param;
4453    parray[1] = parray[2] = parray[3] = 0.0F;
4454    save_TexParameterfv(target, pname, parray);
4455 }
4456 
4457 
4458 static void GLAPIENTRY
save_TexParameteri(GLenum target,GLenum pname,GLint param)4459 save_TexParameteri(GLenum target, GLenum pname, GLint param)
4460 {
4461    GLfloat fparam[4];
4462    fparam[0] = (GLfloat) param;
4463    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4464    save_TexParameterfv(target, pname, fparam);
4465 }
4466 
4467 
4468 static void GLAPIENTRY
save_TexParameteriv(GLenum target,GLenum pname,const GLint * params)4469 save_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
4470 {
4471    GLfloat fparam[4];
4472    fparam[0] = (GLfloat) params[0];
4473    fparam[1] = fparam[2] = fparam[3] = 0.0F;
4474    save_TexParameterfv(target, pname, fparam);
4475 }
4476 
4477 
4478 static void GLAPIENTRY
save_TexImage1D(GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4479 save_TexImage1D(GLenum target,
4480                 GLint level, GLint components,
4481                 GLsizei width, GLint border,
4482                 GLenum format, GLenum type, const GLvoid * pixels)
4483 {
4484    GET_CURRENT_CONTEXT(ctx);
4485    if (target == GL_PROXY_TEXTURE_1D) {
4486       /* don't compile, execute immediately */
4487       CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4488                                   border, format, type, pixels));
4489    }
4490    else {
4491       Node *n;
4492       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4493       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 7 + POINTER_DWORDS);
4494       if (n) {
4495          n[1].e = target;
4496          n[2].i = level;
4497          n[3].i = components;
4498          n[4].i = (GLint) width;
4499          n[5].i = border;
4500          n[6].e = format;
4501          n[7].e = type;
4502          save_pointer(&n[8],
4503                       unpack_image(ctx, 1, width, 1, 1, format, type,
4504                                    pixels, &ctx->Unpack));
4505       }
4506       if (ctx->ExecuteFlag) {
4507          CALL_TexImage1D(ctx->Exec, (target, level, components, width,
4508                                      border, format, type, pixels));
4509       }
4510    }
4511 }
4512 
4513 
4514 static void GLAPIENTRY
save_TexImage2D(GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid * pixels)4515 save_TexImage2D(GLenum target,
4516                 GLint level, GLint components,
4517                 GLsizei width, GLsizei height, GLint border,
4518                 GLenum format, GLenum type, const GLvoid * pixels)
4519 {
4520    GET_CURRENT_CONTEXT(ctx);
4521    if (target == GL_PROXY_TEXTURE_2D) {
4522       /* don't compile, execute immediately */
4523       CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4524                                   height, border, format, type, pixels));
4525    }
4526    else {
4527       Node *n;
4528       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4529       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 8 + POINTER_DWORDS);
4530       if (n) {
4531          n[1].e = target;
4532          n[2].i = level;
4533          n[3].i = components;
4534          n[4].i = (GLint) width;
4535          n[5].i = (GLint) height;
4536          n[6].i = border;
4537          n[7].e = format;
4538          n[8].e = type;
4539          save_pointer(&n[9],
4540                       unpack_image(ctx, 2, width, height, 1, format, type,
4541                                    pixels, &ctx->Unpack));
4542       }
4543       if (ctx->ExecuteFlag) {
4544          CALL_TexImage2D(ctx->Exec, (target, level, components, width,
4545                                      height, border, format, type, pixels));
4546       }
4547    }
4548 }
4549 
4550 
4551 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)4552 save_TexImage3D(GLenum target,
4553                 GLint level, GLint internalFormat,
4554                 GLsizei width, GLsizei height, GLsizei depth,
4555                 GLint border,
4556                 GLenum format, GLenum type, const GLvoid * pixels)
4557 {
4558    GET_CURRENT_CONTEXT(ctx);
4559    if (target == GL_PROXY_TEXTURE_3D) {
4560       /* don't compile, execute immediately */
4561       CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4562                                   height, depth, border, format, type,
4563                                   pixels));
4564    }
4565    else {
4566       Node *n;
4567       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4568       n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 9 + POINTER_DWORDS);
4569       if (n) {
4570          n[1].e = target;
4571          n[2].i = level;
4572          n[3].i = (GLint) internalFormat;
4573          n[4].i = (GLint) width;
4574          n[5].i = (GLint) height;
4575          n[6].i = (GLint) depth;
4576          n[7].i = border;
4577          n[8].e = format;
4578          n[9].e = type;
4579          save_pointer(&n[10],
4580                       unpack_image(ctx, 3, width, height, depth, format, type,
4581                                    pixels, &ctx->Unpack));
4582       }
4583       if (ctx->ExecuteFlag) {
4584          CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width,
4585                                      height, depth, border, format, type,
4586                                      pixels));
4587       }
4588    }
4589 }
4590 
4591 
4592 static void GLAPIENTRY
save_TexSubImage1D(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)4593 save_TexSubImage1D(GLenum target, GLint level, GLint xoffset,
4594                    GLsizei width, GLenum format, GLenum type,
4595                    const GLvoid * pixels)
4596 {
4597    GET_CURRENT_CONTEXT(ctx);
4598    Node *n;
4599 
4600    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4601 
4602    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 6 + POINTER_DWORDS);
4603    if (n) {
4604       n[1].e = target;
4605       n[2].i = level;
4606       n[3].i = xoffset;
4607       n[4].i = (GLint) width;
4608       n[5].e = format;
4609       n[6].e = type;
4610       save_pointer(&n[7],
4611                    unpack_image(ctx, 1, width, 1, 1, format, type,
4612                                 pixels, &ctx->Unpack));
4613    }
4614    if (ctx->ExecuteFlag) {
4615       CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width,
4616                                      format, type, pixels));
4617    }
4618 }
4619 
4620 
4621 static void GLAPIENTRY
save_TexSubImage2D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)4622 save_TexSubImage2D(GLenum target, GLint level,
4623                    GLint xoffset, GLint yoffset,
4624                    GLsizei width, GLsizei height,
4625                    GLenum format, GLenum type, const GLvoid * pixels)
4626 {
4627    GET_CURRENT_CONTEXT(ctx);
4628    Node *n;
4629 
4630    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4631 
4632    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 8 + POINTER_DWORDS);
4633    if (n) {
4634       n[1].e = target;
4635       n[2].i = level;
4636       n[3].i = xoffset;
4637       n[4].i = yoffset;
4638       n[5].i = (GLint) width;
4639       n[6].i = (GLint) height;
4640       n[7].e = format;
4641       n[8].e = type;
4642       save_pointer(&n[9],
4643                    unpack_image(ctx, 2, width, height, 1, format, type,
4644                                 pixels, &ctx->Unpack));
4645    }
4646    if (ctx->ExecuteFlag) {
4647       CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset,
4648                                      width, height, format, type, pixels));
4649    }
4650 }
4651 
4652 
4653 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)4654 save_TexSubImage3D(GLenum target, GLint level,
4655                    GLint xoffset, GLint yoffset, GLint zoffset,
4656                    GLsizei width, GLsizei height, GLsizei depth,
4657                    GLenum format, GLenum type, const GLvoid * pixels)
4658 {
4659    GET_CURRENT_CONTEXT(ctx);
4660    Node *n;
4661 
4662    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4663 
4664    n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 10 + POINTER_DWORDS);
4665    if (n) {
4666       n[1].e = target;
4667       n[2].i = level;
4668       n[3].i = xoffset;
4669       n[4].i = yoffset;
4670       n[5].i = zoffset;
4671       n[6].i = (GLint) width;
4672       n[7].i = (GLint) height;
4673       n[8].i = (GLint) depth;
4674       n[9].e = format;
4675       n[10].e = type;
4676       save_pointer(&n[11],
4677                    unpack_image(ctx, 3, width, height, depth, format, type,
4678                                 pixels, &ctx->Unpack));
4679    }
4680    if (ctx->ExecuteFlag) {
4681       CALL_TexSubImage3D(ctx->Exec, (target, level,
4682                                      xoffset, yoffset, zoffset,
4683                                      width, height, depth, format, type,
4684                                      pixels));
4685    }
4686 }
4687 
4688 
4689 static void GLAPIENTRY
save_Translatef(GLfloat x,GLfloat y,GLfloat z)4690 save_Translatef(GLfloat x, GLfloat y, GLfloat z)
4691 {
4692    GET_CURRENT_CONTEXT(ctx);
4693    Node *n;
4694    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4695    n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3);
4696    if (n) {
4697       n[1].f = x;
4698       n[2].f = y;
4699       n[3].f = z;
4700    }
4701    if (ctx->ExecuteFlag) {
4702       CALL_Translatef(ctx->Exec, (x, y, z));
4703    }
4704 }
4705 
4706 
4707 static void GLAPIENTRY
save_Translated(GLdouble x,GLdouble y,GLdouble z)4708 save_Translated(GLdouble x, GLdouble y, GLdouble z)
4709 {
4710    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
4711 }
4712 
4713 
4714 
4715 static void GLAPIENTRY
save_Viewport(GLint x,GLint y,GLsizei width,GLsizei height)4716 save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
4717 {
4718    GET_CURRENT_CONTEXT(ctx);
4719    Node *n;
4720    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4721    n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4);
4722    if (n) {
4723       n[1].i = x;
4724       n[2].i = y;
4725       n[3].i = (GLint) width;
4726       n[4].i = (GLint) height;
4727    }
4728    if (ctx->ExecuteFlag) {
4729       CALL_Viewport(ctx->Exec, (x, y, width, height));
4730    }
4731 }
4732 
4733 static void GLAPIENTRY
save_ViewportIndexedf(GLuint index,GLfloat x,GLfloat y,GLfloat width,GLfloat height)4734 save_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat width,
4735                       GLfloat height)
4736 {
4737    GET_CURRENT_CONTEXT(ctx);
4738    Node *n;
4739    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4740    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_F, 5);
4741    if (n) {
4742       n[1].ui = index;
4743       n[2].f = x;
4744       n[3].f = y;
4745       n[4].f = width;
4746       n[5].f = height;
4747    }
4748    if (ctx->ExecuteFlag) {
4749       CALL_ViewportIndexedf(ctx->Exec, (index, x, y, width, height));
4750    }
4751 }
4752 
4753 static void GLAPIENTRY
save_ViewportIndexedfv(GLuint index,const GLfloat * v)4754 save_ViewportIndexedfv(GLuint index, const GLfloat *v)
4755 {
4756    GET_CURRENT_CONTEXT(ctx);
4757    Node *n;
4758    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4759    n = alloc_instruction(ctx, OPCODE_VIEWPORT_INDEXED_FV, 5);
4760    if (n) {
4761       n[1].ui = index;
4762       n[2].f = v[0];
4763       n[3].f = v[1];
4764       n[4].f = v[2];
4765       n[5].f = v[3];
4766    }
4767    if (ctx->ExecuteFlag) {
4768       CALL_ViewportIndexedfv(ctx->Exec, (index, v));
4769    }
4770 }
4771 
4772 static void GLAPIENTRY
save_ViewportArrayv(GLuint first,GLsizei count,const GLfloat * v)4773 save_ViewportArrayv(GLuint first, GLsizei count, const GLfloat *v)
4774 {
4775    GET_CURRENT_CONTEXT(ctx);
4776    Node *n;
4777    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4778    n = alloc_instruction(ctx, OPCODE_VIEWPORT_ARRAY_V, 2 + POINTER_DWORDS);
4779    if (n) {
4780       n[1].ui = first;
4781       n[2].si = count;
4782       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
4783    }
4784    if (ctx->ExecuteFlag) {
4785       CALL_ViewportArrayv(ctx->Exec, (first, count, v));
4786    }
4787 }
4788 
4789 static void GLAPIENTRY
save_ScissorIndexed(GLuint index,GLint left,GLint bottom,GLsizei width,GLsizei height)4790 save_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width,
4791                     GLsizei height)
4792 {
4793    GET_CURRENT_CONTEXT(ctx);
4794    Node *n;
4795    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4796    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED, 5);
4797    if (n) {
4798       n[1].ui = index;
4799       n[2].i = left;
4800       n[3].i = bottom;
4801       n[4].si = width;
4802       n[5].si = height;
4803    }
4804    if (ctx->ExecuteFlag) {
4805       CALL_ScissorIndexed(ctx->Exec, (index, left, bottom, width, height));
4806    }
4807 }
4808 
4809 static void GLAPIENTRY
save_ScissorIndexedv(GLuint index,const GLint * v)4810 save_ScissorIndexedv(GLuint index, const GLint *v)
4811 {
4812    GET_CURRENT_CONTEXT(ctx);
4813    Node *n;
4814    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4815    n = alloc_instruction(ctx, OPCODE_SCISSOR_INDEXED_V, 5);
4816    if (n) {
4817       n[1].ui = index;
4818       n[2].i = v[0];
4819       n[3].i = v[1];
4820       n[4].si = v[2];
4821       n[5].si = v[3];
4822    }
4823    if (ctx->ExecuteFlag) {
4824       CALL_ScissorIndexedv(ctx->Exec, (index, v));
4825    }
4826 }
4827 
4828 static void GLAPIENTRY
save_ScissorArrayv(GLuint first,GLsizei count,const GLint * v)4829 save_ScissorArrayv(GLuint first, GLsizei count, const GLint *v)
4830 {
4831    GET_CURRENT_CONTEXT(ctx);
4832    Node *n;
4833    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4834    n = alloc_instruction(ctx, OPCODE_SCISSOR_ARRAY_V, 2 + POINTER_DWORDS);
4835    if (n) {
4836       n[1].ui = first;
4837       n[2].si = count;
4838       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint)));
4839    }
4840    if (ctx->ExecuteFlag) {
4841       CALL_ScissorArrayv(ctx->Exec, (first, count, v));
4842    }
4843 }
4844 
4845 static void GLAPIENTRY
save_DepthRangeIndexed(GLuint index,GLclampd n,GLclampd f)4846 save_DepthRangeIndexed(GLuint index, GLclampd n, GLclampd f)
4847 {
4848    GET_CURRENT_CONTEXT(ctx);
4849    Node *node;
4850    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4851    node = alloc_instruction(ctx, OPCODE_DEPTH_INDEXED, 3);
4852    if (node) {
4853       node[1].ui = index;
4854       /* Mesa stores these as floats internally so we deliberately convert
4855        * them to a float here.
4856        */
4857       node[2].f = n;
4858       node[3].f = f;
4859    }
4860    if (ctx->ExecuteFlag) {
4861       CALL_DepthRangeIndexed(ctx->Exec, (index, n, f));
4862    }
4863 }
4864 
4865 static void GLAPIENTRY
save_DepthRangeArrayv(GLuint first,GLsizei count,const GLclampd * v)4866 save_DepthRangeArrayv(GLuint first, GLsizei count, const GLclampd *v)
4867 {
4868    GET_CURRENT_CONTEXT(ctx);
4869    Node *n;
4870    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4871    n = alloc_instruction(ctx, OPCODE_DEPTH_ARRAY_V, 2 + POINTER_DWORDS);
4872    if (n) {
4873       n[1].ui = first;
4874       n[2].si = count;
4875       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLclampd)));
4876    }
4877    if (ctx->ExecuteFlag) {
4878       CALL_DepthRangeArrayv(ctx->Exec, (first, count, v));
4879    }
4880 }
4881 
4882 static void GLAPIENTRY
save_WindowPos4fMESA(GLfloat x,GLfloat y,GLfloat z,GLfloat w)4883 save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4884 {
4885    GET_CURRENT_CONTEXT(ctx);
4886    Node *n;
4887    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
4888    n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4);
4889    if (n) {
4890       n[1].f = x;
4891       n[2].f = y;
4892       n[3].f = z;
4893       n[4].f = w;
4894    }
4895    if (ctx->ExecuteFlag) {
4896       CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w));
4897    }
4898 }
4899 
4900 static void GLAPIENTRY
save_WindowPos2dMESA(GLdouble x,GLdouble y)4901 save_WindowPos2dMESA(GLdouble x, GLdouble y)
4902 {
4903    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4904 }
4905 
4906 static void GLAPIENTRY
save_WindowPos2fMESA(GLfloat x,GLfloat y)4907 save_WindowPos2fMESA(GLfloat x, GLfloat y)
4908 {
4909    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4910 }
4911 
4912 static void GLAPIENTRY
save_WindowPos2iMESA(GLint x,GLint y)4913 save_WindowPos2iMESA(GLint x, GLint y)
4914 {
4915    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
4916 }
4917 
4918 static void GLAPIENTRY
save_WindowPos2sMESA(GLshort x,GLshort y)4919 save_WindowPos2sMESA(GLshort x, GLshort y)
4920 {
4921    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
4922 }
4923 
4924 static void GLAPIENTRY
save_WindowPos3dMESA(GLdouble x,GLdouble y,GLdouble z)4925 save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
4926 {
4927    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4928 }
4929 
4930 static void GLAPIENTRY
save_WindowPos3fMESA(GLfloat x,GLfloat y,GLfloat z)4931 save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
4932 {
4933    save_WindowPos4fMESA(x, y, z, 1.0F);
4934 }
4935 
4936 static void GLAPIENTRY
save_WindowPos3iMESA(GLint x,GLint y,GLint z)4937 save_WindowPos3iMESA(GLint x, GLint y, GLint z)
4938 {
4939    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
4940 }
4941 
4942 static void GLAPIENTRY
save_WindowPos3sMESA(GLshort x,GLshort y,GLshort z)4943 save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
4944 {
4945    save_WindowPos4fMESA(x, y, z, 1.0F);
4946 }
4947 
4948 static void GLAPIENTRY
save_WindowPos4dMESA(GLdouble x,GLdouble y,GLdouble z,GLdouble w)4949 save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
4950 {
4951    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4952 }
4953 
4954 static void GLAPIENTRY
save_WindowPos4iMESA(GLint x,GLint y,GLint z,GLint w)4955 save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
4956 {
4957    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
4958 }
4959 
4960 static void GLAPIENTRY
save_WindowPos4sMESA(GLshort x,GLshort y,GLshort z,GLshort w)4961 save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
4962 {
4963    save_WindowPos4fMESA(x, y, z, w);
4964 }
4965 
4966 static void GLAPIENTRY
save_WindowPos2dvMESA(const GLdouble * v)4967 save_WindowPos2dvMESA(const GLdouble * v)
4968 {
4969    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4970 }
4971 
4972 static void GLAPIENTRY
save_WindowPos2fvMESA(const GLfloat * v)4973 save_WindowPos2fvMESA(const GLfloat * v)
4974 {
4975    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4976 }
4977 
4978 static void GLAPIENTRY
save_WindowPos2ivMESA(const GLint * v)4979 save_WindowPos2ivMESA(const GLint * v)
4980 {
4981    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
4982 }
4983 
4984 static void GLAPIENTRY
save_WindowPos2svMESA(const GLshort * v)4985 save_WindowPos2svMESA(const GLshort * v)
4986 {
4987    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
4988 }
4989 
4990 static void GLAPIENTRY
save_WindowPos3dvMESA(const GLdouble * v)4991 save_WindowPos3dvMESA(const GLdouble * v)
4992 {
4993    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
4994 }
4995 
4996 static void GLAPIENTRY
save_WindowPos3fvMESA(const GLfloat * v)4997 save_WindowPos3fvMESA(const GLfloat * v)
4998 {
4999    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
5000 }
5001 
5002 static void GLAPIENTRY
save_WindowPos3ivMESA(const GLint * v)5003 save_WindowPos3ivMESA(const GLint * v)
5004 {
5005    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
5006 }
5007 
5008 static void GLAPIENTRY
save_WindowPos3svMESA(const GLshort * v)5009 save_WindowPos3svMESA(const GLshort * v)
5010 {
5011    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
5012 }
5013 
5014 static void GLAPIENTRY
save_WindowPos4dvMESA(const GLdouble * v)5015 save_WindowPos4dvMESA(const GLdouble * v)
5016 {
5017    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
5018                         (GLfloat) v[2], (GLfloat) v[3]);
5019 }
5020 
5021 static void GLAPIENTRY
save_WindowPos4fvMESA(const GLfloat * v)5022 save_WindowPos4fvMESA(const GLfloat * v)
5023 {
5024    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
5025 }
5026 
5027 static void GLAPIENTRY
save_WindowPos4ivMESA(const GLint * v)5028 save_WindowPos4ivMESA(const GLint * v)
5029 {
5030    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
5031                         (GLfloat) v[2], (GLfloat) v[3]);
5032 }
5033 
5034 static void GLAPIENTRY
save_WindowPos4svMESA(const GLshort * v)5035 save_WindowPos4svMESA(const GLshort * v)
5036 {
5037    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
5038 }
5039 
5040 
5041 
5042 /* GL_ARB_multitexture */
5043 static void GLAPIENTRY
save_ActiveTextureARB(GLenum target)5044 save_ActiveTextureARB(GLenum target)
5045 {
5046    GET_CURRENT_CONTEXT(ctx);
5047    Node *n;
5048    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5049    n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1);
5050    if (n) {
5051       n[1].e = target;
5052    }
5053    if (ctx->ExecuteFlag) {
5054       CALL_ActiveTexture(ctx->Exec, (target));
5055    }
5056 }
5057 
5058 
5059 /* GL_ARB_transpose_matrix */
5060 
5061 static void GLAPIENTRY
save_LoadTransposeMatrixdARB(const GLdouble m[16])5062 save_LoadTransposeMatrixdARB(const GLdouble m[16])
5063 {
5064    GLfloat tm[16];
5065    _math_transposefd(tm, m);
5066    save_LoadMatrixf(tm);
5067 }
5068 
5069 
5070 static void GLAPIENTRY
save_LoadTransposeMatrixfARB(const GLfloat m[16])5071 save_LoadTransposeMatrixfARB(const GLfloat m[16])
5072 {
5073    GLfloat tm[16];
5074    _math_transposef(tm, m);
5075    save_LoadMatrixf(tm);
5076 }
5077 
5078 
5079 static void GLAPIENTRY
save_MultTransposeMatrixdARB(const GLdouble m[16])5080 save_MultTransposeMatrixdARB(const GLdouble m[16])
5081 {
5082    GLfloat tm[16];
5083    _math_transposefd(tm, m);
5084    save_MultMatrixf(tm);
5085 }
5086 
5087 
5088 static void GLAPIENTRY
save_MultTransposeMatrixfARB(const GLfloat m[16])5089 save_MultTransposeMatrixfARB(const GLfloat m[16])
5090 {
5091    GLfloat tm[16];
5092    _math_transposef(tm, m);
5093    save_MultMatrixf(tm);
5094 }
5095 
copy_data(const GLvoid * data,GLsizei size,const char * func)5096 static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func)
5097 {
5098    GET_CURRENT_CONTEXT(ctx);
5099    GLvoid *image;
5100 
5101    if (!data)
5102       return NULL;
5103 
5104    image = malloc(size);
5105    if (!image) {
5106       _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
5107       return NULL;
5108    }
5109    memcpy(image, data, size);
5110 
5111    return image;
5112 }
5113 
5114 
5115 /* GL_ARB_texture_compression */
5116 static void GLAPIENTRY
save_CompressedTexImage1DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)5117 save_CompressedTexImage1DARB(GLenum target, GLint level,
5118                              GLenum internalFormat, GLsizei width,
5119                              GLint border, GLsizei imageSize,
5120                              const GLvoid * data)
5121 {
5122    GET_CURRENT_CONTEXT(ctx);
5123    if (target == GL_PROXY_TEXTURE_1D) {
5124       /* don't compile, execute immediately */
5125       CALL_CompressedTexImage1D(ctx->Exec, (target, level, internalFormat,
5126                                                width, border, imageSize,
5127                                                data));
5128    }
5129    else {
5130       Node *n;
5131       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5132 
5133       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D,
5134                             6 + POINTER_DWORDS);
5135       if (n) {
5136          n[1].e = target;
5137          n[2].i = level;
5138          n[3].e = internalFormat;
5139          n[4].i = (GLint) width;
5140          n[5].i = border;
5141          n[6].i = imageSize;
5142          save_pointer(&n[7],
5143                       copy_data(data, imageSize, "glCompressedTexImage1DARB"));
5144       }
5145       if (ctx->ExecuteFlag) {
5146          CALL_CompressedTexImage1D(ctx->Exec,
5147                                       (target, level, internalFormat, width,
5148                                        border, imageSize, data));
5149       }
5150    }
5151 }
5152 
5153 
5154 static void GLAPIENTRY
save_CompressedTexImage2DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)5155 save_CompressedTexImage2DARB(GLenum target, GLint level,
5156                              GLenum internalFormat, GLsizei width,
5157                              GLsizei height, GLint border, GLsizei imageSize,
5158                              const GLvoid * data)
5159 {
5160    GET_CURRENT_CONTEXT(ctx);
5161    if (target == GL_PROXY_TEXTURE_2D) {
5162       /* don't compile, execute immediately */
5163       CALL_CompressedTexImage2D(ctx->Exec, (target, level, internalFormat,
5164                                                width, height, border,
5165                                                imageSize, data));
5166    }
5167    else {
5168       Node *n;
5169       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5170 
5171       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D,
5172                             7 + POINTER_DWORDS);
5173       if (n) {
5174          n[1].e = target;
5175          n[2].i = level;
5176          n[3].e = internalFormat;
5177          n[4].i = (GLint) width;
5178          n[5].i = (GLint) height;
5179          n[6].i = border;
5180          n[7].i = imageSize;
5181          save_pointer(&n[8],
5182                       copy_data(data, imageSize, "glCompressedTexImage2DARB"));
5183       }
5184       if (ctx->ExecuteFlag) {
5185          CALL_CompressedTexImage2D(ctx->Exec,
5186                                       (target, level, internalFormat, width,
5187                                        height, border, imageSize, data));
5188       }
5189    }
5190 }
5191 
5192 
5193 static void GLAPIENTRY
save_CompressedTexImage3DARB(GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)5194 save_CompressedTexImage3DARB(GLenum target, GLint level,
5195                              GLenum internalFormat, GLsizei width,
5196                              GLsizei height, GLsizei depth, GLint border,
5197                              GLsizei imageSize, const GLvoid * data)
5198 {
5199    GET_CURRENT_CONTEXT(ctx);
5200    if (target == GL_PROXY_TEXTURE_3D) {
5201       /* don't compile, execute immediately */
5202       CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat,
5203                                                width, height, depth, border,
5204                                                imageSize, data));
5205    }
5206    else {
5207       Node *n;
5208       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5209 
5210       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D,
5211                             8 + POINTER_DWORDS);
5212       if (n) {
5213          n[1].e = target;
5214          n[2].i = level;
5215          n[3].e = internalFormat;
5216          n[4].i = (GLint) width;
5217          n[5].i = (GLint) height;
5218          n[6].i = (GLint) depth;
5219          n[7].i = border;
5220          n[8].i = imageSize;
5221          save_pointer(&n[9],
5222                       copy_data(data, imageSize, "glCompressedTexImage3DARB"));
5223       }
5224       if (ctx->ExecuteFlag) {
5225          CALL_CompressedTexImage3D(ctx->Exec,
5226                                       (target, level, internalFormat, width,
5227                                        height, depth, border, imageSize,
5228                                        data));
5229       }
5230    }
5231 }
5232 
5233 
5234 static void GLAPIENTRY
save_CompressedTexSubImage1DARB(GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)5235 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
5236                                 GLsizei width, GLenum format,
5237                                 GLsizei imageSize, const GLvoid * data)
5238 {
5239    Node *n;
5240    GET_CURRENT_CONTEXT(ctx);
5241    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5242 
5243    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
5244                          6 + POINTER_DWORDS);
5245    if (n) {
5246       n[1].e = target;
5247       n[2].i = level;
5248       n[3].i = xoffset;
5249       n[4].i = (GLint) width;
5250       n[5].e = format;
5251       n[6].i = imageSize;
5252       save_pointer(&n[7],
5253                    copy_data(data, imageSize, "glCompressedTexSubImage1DARB"));
5254    }
5255    if (ctx->ExecuteFlag) {
5256       CALL_CompressedTexSubImage1D(ctx->Exec, (target, level, xoffset,
5257                                                   width, format, imageSize,
5258                                                   data));
5259    }
5260 }
5261 
5262 
5263 static void GLAPIENTRY
save_CompressedTexSubImage2DARB(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const GLvoid * data)5264 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
5265                                 GLint yoffset, GLsizei width, GLsizei height,
5266                                 GLenum format, GLsizei imageSize,
5267                                 const GLvoid * data)
5268 {
5269    Node *n;
5270    GET_CURRENT_CONTEXT(ctx);
5271    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5272 
5273    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
5274                          8 + POINTER_DWORDS);
5275    if (n) {
5276       n[1].e = target;
5277       n[2].i = level;
5278       n[3].i = xoffset;
5279       n[4].i = yoffset;
5280       n[5].i = (GLint) width;
5281       n[6].i = (GLint) height;
5282       n[7].e = format;
5283       n[8].i = imageSize;
5284       save_pointer(&n[9],
5285                    copy_data(data, imageSize, "glCompressedTexSubImage2DARB"));
5286    }
5287    if (ctx->ExecuteFlag) {
5288       CALL_CompressedTexSubImage2D(ctx->Exec,
5289                                       (target, level, xoffset, yoffset, width,
5290                                        height, format, imageSize, data));
5291    }
5292 }
5293 
5294 
5295 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)5296 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
5297                                 GLint yoffset, GLint zoffset, GLsizei width,
5298                                 GLsizei height, GLsizei depth, GLenum format,
5299                                 GLsizei imageSize, const GLvoid * data)
5300 {
5301    Node *n;
5302    GET_CURRENT_CONTEXT(ctx);
5303    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5304 
5305    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
5306                          10 + POINTER_DWORDS);
5307    if (n) {
5308       n[1].e = target;
5309       n[2].i = level;
5310       n[3].i = xoffset;
5311       n[4].i = yoffset;
5312       n[5].i = zoffset;
5313       n[6].i = (GLint) width;
5314       n[7].i = (GLint) height;
5315       n[8].i = (GLint) depth;
5316       n[9].e = format;
5317       n[10].i = imageSize;
5318       save_pointer(&n[11],
5319                    copy_data(data, imageSize, "glCompressedTexSubImage3DARB"));
5320    }
5321    if (ctx->ExecuteFlag) {
5322       CALL_CompressedTexSubImage3D(ctx->Exec,
5323                                       (target, level, xoffset, yoffset,
5324                                        zoffset, width, height, depth, format,
5325                                        imageSize, data));
5326    }
5327 }
5328 
5329 
5330 /* GL_ARB_multisample */
5331 static void GLAPIENTRY
save_SampleCoverageARB(GLclampf value,GLboolean invert)5332 save_SampleCoverageARB(GLclampf value, GLboolean invert)
5333 {
5334    GET_CURRENT_CONTEXT(ctx);
5335    Node *n;
5336    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5337    n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2);
5338    if (n) {
5339       n[1].f = value;
5340       n[2].b = invert;
5341    }
5342    if (ctx->ExecuteFlag) {
5343       CALL_SampleCoverage(ctx->Exec, (value, invert));
5344    }
5345 }
5346 
5347 
5348 /*
5349  * GL_ARB_vertex_program
5350  */
5351 static void GLAPIENTRY
save_BindProgramARB(GLenum target,GLuint id)5352 save_BindProgramARB(GLenum target, GLuint id)
5353 {
5354    GET_CURRENT_CONTEXT(ctx);
5355    Node *n;
5356    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5357    n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_ARB, 2);
5358    if (n) {
5359       n[1].e = target;
5360       n[2].ui = id;
5361    }
5362    if (ctx->ExecuteFlag) {
5363       CALL_BindProgramARB(ctx->Exec, (target, id));
5364    }
5365 }
5366 
5367 static void GLAPIENTRY
save_ProgramEnvParameter4fARB(GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5368 save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
5369                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5370 {
5371    GET_CURRENT_CONTEXT(ctx);
5372    Node *n;
5373    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5374    n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5375    if (n) {
5376       n[1].e = target;
5377       n[2].ui = index;
5378       n[3].f = x;
5379       n[4].f = y;
5380       n[5].f = z;
5381       n[6].f = w;
5382    }
5383    if (ctx->ExecuteFlag) {
5384       CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5385    }
5386 }
5387 
5388 
5389 static void GLAPIENTRY
save_ProgramEnvParameter4fvARB(GLenum target,GLuint index,const GLfloat * params)5390 save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
5391                                const GLfloat *params)
5392 {
5393    save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
5394                                  params[2], params[3]);
5395 }
5396 
5397 
5398 static void GLAPIENTRY
save_ProgramEnvParameters4fvEXT(GLenum target,GLuint index,GLsizei count,const GLfloat * params)5399 save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5400                                 const GLfloat * params)
5401 {
5402    GET_CURRENT_CONTEXT(ctx);
5403    Node *n;
5404    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5405 
5406    if (count > 0) {
5407       GLint i;
5408       const GLfloat * p = params;
5409 
5410       for (i = 0 ; i < count ; i++) {
5411          n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6);
5412          if (n) {
5413             n[1].e = target;
5414             n[2].ui = index;
5415             n[3].f = p[0];
5416             n[4].f = p[1];
5417             n[5].f = p[2];
5418             n[6].f = p[3];
5419             p += 4;
5420          }
5421       }
5422    }
5423 
5424    if (ctx->ExecuteFlag) {
5425       CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params));
5426    }
5427 }
5428 
5429 
5430 static void GLAPIENTRY
save_ProgramEnvParameter4dARB(GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)5431 save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
5432                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5433 {
5434    save_ProgramEnvParameter4fARB(target, index,
5435                                  (GLfloat) x,
5436                                  (GLfloat) y, (GLfloat) z, (GLfloat) w);
5437 }
5438 
5439 
5440 static void GLAPIENTRY
save_ProgramEnvParameter4dvARB(GLenum target,GLuint index,const GLdouble * params)5441 save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
5442                                const GLdouble *params)
5443 {
5444    save_ProgramEnvParameter4fARB(target, index,
5445                                  (GLfloat) params[0],
5446                                  (GLfloat) params[1],
5447                                  (GLfloat) params[2], (GLfloat) params[3]);
5448 }
5449 
5450 
5451 static void GLAPIENTRY
save_ProgramLocalParameter4fARB(GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)5452 save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
5453                                 GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5454 {
5455    GET_CURRENT_CONTEXT(ctx);
5456    Node *n;
5457    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5458    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5459    if (n) {
5460       n[1].e = target;
5461       n[2].ui = index;
5462       n[3].f = x;
5463       n[4].f = y;
5464       n[5].f = z;
5465       n[6].f = w;
5466    }
5467    if (ctx->ExecuteFlag) {
5468       CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
5469    }
5470 }
5471 
5472 
5473 static void GLAPIENTRY
save_ProgramLocalParameter4fvARB(GLenum target,GLuint index,const GLfloat * params)5474 save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
5475                                  const GLfloat *params)
5476 {
5477    GET_CURRENT_CONTEXT(ctx);
5478    Node *n;
5479    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5480    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5481    if (n) {
5482       n[1].e = target;
5483       n[2].ui = index;
5484       n[3].f = params[0];
5485       n[4].f = params[1];
5486       n[5].f = params[2];
5487       n[6].f = params[3];
5488    }
5489    if (ctx->ExecuteFlag) {
5490       CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
5491    }
5492 }
5493 
5494 
5495 static void GLAPIENTRY
save_ProgramLocalParameters4fvEXT(GLenum target,GLuint index,GLsizei count,const GLfloat * params)5496 save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
5497                                   const GLfloat *params)
5498 {
5499    GET_CURRENT_CONTEXT(ctx);
5500    Node *n;
5501    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5502 
5503    if (count > 0) {
5504       GLint i;
5505       const GLfloat * p = params;
5506 
5507       for (i = 0 ; i < count ; i++) {
5508          n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5509          if (n) {
5510             n[1].e = target;
5511             n[2].ui = index;
5512             n[3].f = p[0];
5513             n[4].f = p[1];
5514             n[5].f = p[2];
5515             n[6].f = p[3];
5516             p += 4;
5517          }
5518       }
5519    }
5520 
5521    if (ctx->ExecuteFlag) {
5522       CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params));
5523    }
5524 }
5525 
5526 
5527 static void GLAPIENTRY
save_ProgramLocalParameter4dARB(GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)5528 save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
5529                                 GLdouble x, GLdouble y,
5530                                 GLdouble z, GLdouble w)
5531 {
5532    GET_CURRENT_CONTEXT(ctx);
5533    Node *n;
5534    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5535    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5536    if (n) {
5537       n[1].e = target;
5538       n[2].ui = index;
5539       n[3].f = (GLfloat) x;
5540       n[4].f = (GLfloat) y;
5541       n[5].f = (GLfloat) z;
5542       n[6].f = (GLfloat) w;
5543    }
5544    if (ctx->ExecuteFlag) {
5545       CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
5546    }
5547 }
5548 
5549 
5550 static void GLAPIENTRY
save_ProgramLocalParameter4dvARB(GLenum target,GLuint index,const GLdouble * params)5551 save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
5552                                  const GLdouble *params)
5553 {
5554    GET_CURRENT_CONTEXT(ctx);
5555    Node *n;
5556    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5557    n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6);
5558    if (n) {
5559       n[1].e = target;
5560       n[2].ui = index;
5561       n[3].f = (GLfloat) params[0];
5562       n[4].f = (GLfloat) params[1];
5563       n[5].f = (GLfloat) params[2];
5564       n[6].f = (GLfloat) params[3];
5565    }
5566    if (ctx->ExecuteFlag) {
5567       CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
5568    }
5569 }
5570 
5571 
5572 /* GL_EXT_stencil_two_side */
5573 static void GLAPIENTRY
save_ActiveStencilFaceEXT(GLenum face)5574 save_ActiveStencilFaceEXT(GLenum face)
5575 {
5576    GET_CURRENT_CONTEXT(ctx);
5577    Node *n;
5578    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5579    n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1);
5580    if (n) {
5581       n[1].e = face;
5582    }
5583    if (ctx->ExecuteFlag) {
5584       CALL_ActiveStencilFaceEXT(ctx->Exec, (face));
5585    }
5586 }
5587 
5588 
5589 /* GL_EXT_depth_bounds_test */
5590 static void GLAPIENTRY
save_DepthBoundsEXT(GLclampd zmin,GLclampd zmax)5591 save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax)
5592 {
5593    GET_CURRENT_CONTEXT(ctx);
5594    Node *n;
5595    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5596    n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2);
5597    if (n) {
5598       n[1].f = (GLfloat) zmin;
5599       n[2].f = (GLfloat) zmax;
5600    }
5601    if (ctx->ExecuteFlag) {
5602       CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax));
5603    }
5604 }
5605 
5606 
5607 
5608 static void GLAPIENTRY
save_ProgramStringARB(GLenum target,GLenum format,GLsizei len,const GLvoid * string)5609 save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
5610                       const GLvoid * string)
5611 {
5612    GET_CURRENT_CONTEXT(ctx);
5613    Node *n;
5614 
5615    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5616 
5617    n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 3 + POINTER_DWORDS);
5618    if (n) {
5619       GLubyte *programCopy = malloc(len);
5620       if (!programCopy) {
5621          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
5622          return;
5623       }
5624       memcpy(programCopy, string, len);
5625       n[1].e = target;
5626       n[2].e = format;
5627       n[3].i = len;
5628       save_pointer(&n[4], programCopy);
5629    }
5630    if (ctx->ExecuteFlag) {
5631       CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
5632    }
5633 }
5634 
5635 
5636 static void GLAPIENTRY
save_BeginQueryARB(GLenum target,GLuint id)5637 save_BeginQueryARB(GLenum target, GLuint id)
5638 {
5639    GET_CURRENT_CONTEXT(ctx);
5640    Node *n;
5641    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5642    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2);
5643    if (n) {
5644       n[1].e = target;
5645       n[2].ui = id;
5646    }
5647    if (ctx->ExecuteFlag) {
5648       CALL_BeginQuery(ctx->Exec, (target, id));
5649    }
5650 }
5651 
5652 static void GLAPIENTRY
save_EndQueryARB(GLenum target)5653 save_EndQueryARB(GLenum target)
5654 {
5655    GET_CURRENT_CONTEXT(ctx);
5656    Node *n;
5657    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5658    n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1);
5659    if (n) {
5660       n[1].e = target;
5661    }
5662    if (ctx->ExecuteFlag) {
5663       CALL_EndQuery(ctx->Exec, (target));
5664    }
5665 }
5666 
5667 static void GLAPIENTRY
save_QueryCounter(GLuint id,GLenum target)5668 save_QueryCounter(GLuint id, GLenum target)
5669 {
5670    GET_CURRENT_CONTEXT(ctx);
5671    Node *n;
5672    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5673    n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2);
5674    if (n) {
5675       n[1].ui = id;
5676       n[2].e = target;
5677    }
5678    if (ctx->ExecuteFlag) {
5679       CALL_QueryCounter(ctx->Exec, (id, target));
5680    }
5681 }
5682 
5683 static void GLAPIENTRY
save_BeginQueryIndexed(GLenum target,GLuint index,GLuint id)5684 save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
5685 {
5686    GET_CURRENT_CONTEXT(ctx);
5687    Node *n;
5688    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5689    n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3);
5690    if (n) {
5691       n[1].e = target;
5692       n[2].ui = index;
5693       n[3].ui = id;
5694    }
5695    if (ctx->ExecuteFlag) {
5696       CALL_BeginQueryIndexed(ctx->Exec, (target, index, id));
5697    }
5698 }
5699 
5700 static void GLAPIENTRY
save_EndQueryIndexed(GLenum target,GLuint index)5701 save_EndQueryIndexed(GLenum target, GLuint index)
5702 {
5703    GET_CURRENT_CONTEXT(ctx);
5704    Node *n;
5705    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5706    n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2);
5707    if (n) {
5708       n[1].e = target;
5709       n[2].ui = index;
5710    }
5711    if (ctx->ExecuteFlag) {
5712       CALL_EndQueryIndexed(ctx->Exec, (target, index));
5713    }
5714 }
5715 
5716 
5717 static void GLAPIENTRY
save_DrawBuffersARB(GLsizei count,const GLenum * buffers)5718 save_DrawBuffersARB(GLsizei count, const GLenum * buffers)
5719 {
5720    GET_CURRENT_CONTEXT(ctx);
5721    Node *n;
5722    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5723    n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS);
5724    if (n) {
5725       GLint i;
5726       n[1].i = count;
5727       if (count > MAX_DRAW_BUFFERS)
5728          count = MAX_DRAW_BUFFERS;
5729       for (i = 0; i < count; i++) {
5730          n[2 + i].e = buffers[i];
5731       }
5732    }
5733    if (ctx->ExecuteFlag) {
5734       CALL_DrawBuffers(ctx->Exec, (count, buffers));
5735    }
5736 }
5737 
5738 static void GLAPIENTRY
save_BindFragmentShaderATI(GLuint id)5739 save_BindFragmentShaderATI(GLuint id)
5740 {
5741    GET_CURRENT_CONTEXT(ctx);
5742    Node *n;
5743 
5744    n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
5745    if (n) {
5746       n[1].ui = id;
5747    }
5748    if (ctx->ExecuteFlag) {
5749       CALL_BindFragmentShaderATI(ctx->Exec, (id));
5750    }
5751 }
5752 
5753 static void GLAPIENTRY
save_SetFragmentShaderConstantATI(GLuint dst,const GLfloat * value)5754 save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
5755 {
5756    GET_CURRENT_CONTEXT(ctx);
5757    Node *n;
5758 
5759    n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
5760    if (n) {
5761       n[1].ui = dst;
5762       n[2].f = value[0];
5763       n[3].f = value[1];
5764       n[4].f = value[2];
5765       n[5].f = value[3];
5766    }
5767    if (ctx->ExecuteFlag) {
5768       CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
5769    }
5770 }
5771 
5772 static void GLAPIENTRY
save_EvalCoord1f(GLfloat x)5773 save_EvalCoord1f(GLfloat x)
5774 {
5775    GET_CURRENT_CONTEXT(ctx);
5776    Node *n;
5777    SAVE_FLUSH_VERTICES(ctx);
5778    n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1);
5779    if (n) {
5780       n[1].f = x;
5781    }
5782    if (ctx->ExecuteFlag) {
5783       CALL_EvalCoord1f(ctx->Exec, (x));
5784    }
5785 }
5786 
5787 static void GLAPIENTRY
save_EvalCoord1fv(const GLfloat * v)5788 save_EvalCoord1fv(const GLfloat * v)
5789 {
5790    save_EvalCoord1f(v[0]);
5791 }
5792 
5793 static void GLAPIENTRY
save_EvalCoord2f(GLfloat x,GLfloat y)5794 save_EvalCoord2f(GLfloat x, GLfloat y)
5795 {
5796    GET_CURRENT_CONTEXT(ctx);
5797    Node *n;
5798    SAVE_FLUSH_VERTICES(ctx);
5799    n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2);
5800    if (n) {
5801       n[1].f = x;
5802       n[2].f = y;
5803    }
5804    if (ctx->ExecuteFlag) {
5805       CALL_EvalCoord2f(ctx->Exec, (x, y));
5806    }
5807 }
5808 
5809 static void GLAPIENTRY
save_EvalCoord2fv(const GLfloat * v)5810 save_EvalCoord2fv(const GLfloat * v)
5811 {
5812    save_EvalCoord2f(v[0], v[1]);
5813 }
5814 
5815 
5816 static void GLAPIENTRY
save_EvalPoint1(GLint x)5817 save_EvalPoint1(GLint x)
5818 {
5819    GET_CURRENT_CONTEXT(ctx);
5820    Node *n;
5821    SAVE_FLUSH_VERTICES(ctx);
5822    n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1);
5823    if (n) {
5824       n[1].i = x;
5825    }
5826    if (ctx->ExecuteFlag) {
5827       CALL_EvalPoint1(ctx->Exec, (x));
5828    }
5829 }
5830 
5831 static void GLAPIENTRY
save_EvalPoint2(GLint x,GLint y)5832 save_EvalPoint2(GLint x, GLint y)
5833 {
5834    GET_CURRENT_CONTEXT(ctx);
5835    Node *n;
5836    SAVE_FLUSH_VERTICES(ctx);
5837    n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2);
5838    if (n) {
5839       n[1].i = x;
5840       n[2].i = y;
5841    }
5842    if (ctx->ExecuteFlag) {
5843       CALL_EvalPoint2(ctx->Exec, (x, y));
5844    }
5845 }
5846 
5847 
5848 /**
5849  * Compare 'count' elements of vectors 'a' and 'b'.
5850  * \return GL_TRUE if equal, GL_FALSE if different.
5851  */
5852 static inline GLboolean
compare_vec(const GLfloat * a,const GLfloat * b,GLuint count)5853 compare_vec(const GLfloat *a, const GLfloat *b, GLuint count)
5854 {
5855    return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
5856 }
5857 
5858 
5859 /**
5860  * This glMaterial function is used for glMaterial calls that are outside
5861  * a glBegin/End pair.  For glMaterial inside glBegin/End, see the VBO code.
5862  */
5863 static void GLAPIENTRY
save_Materialfv(GLenum face,GLenum pname,const GLfloat * param)5864 save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
5865 {
5866    GET_CURRENT_CONTEXT(ctx);
5867    Node *n;
5868    int args, i;
5869    GLuint bitmask;
5870 
5871    switch (face) {
5872    case GL_BACK:
5873    case GL_FRONT:
5874    case GL_FRONT_AND_BACK:
5875       break;
5876    default:
5877       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)");
5878       return;
5879    }
5880 
5881    switch (pname) {
5882    case GL_EMISSION:
5883    case GL_AMBIENT:
5884    case GL_DIFFUSE:
5885    case GL_SPECULAR:
5886    case GL_AMBIENT_AND_DIFFUSE:
5887       args = 4;
5888       break;
5889    case GL_SHININESS:
5890       args = 1;
5891       break;
5892    case GL_COLOR_INDEXES:
5893       args = 3;
5894       break;
5895    default:
5896       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)");
5897       return;
5898    }
5899 
5900    if (ctx->ExecuteFlag) {
5901       CALL_Materialfv(ctx->Exec, (face, pname, param));
5902    }
5903 
5904    bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
5905 
5906    /* Try to eliminate redundant statechanges.  Because it is legal to
5907     * call glMaterial even inside begin/end calls, don't need to worry
5908     * about ctx->Driver.CurrentSavePrimitive here.
5909     */
5910    for (i = 0; i < MAT_ATTRIB_MAX; i++) {
5911       if (bitmask & (1 << i)) {
5912          if (ctx->ListState.ActiveMaterialSize[i] == args &&
5913              compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) {
5914             /* no change in material value */
5915             bitmask &= ~(1 << i);
5916          }
5917          else {
5918             ctx->ListState.ActiveMaterialSize[i] = args;
5919             COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
5920          }
5921       }
5922    }
5923 
5924    /* If this call has no effect, return early */
5925    if (bitmask == 0)
5926       return;
5927 
5928    SAVE_FLUSH_VERTICES(ctx);
5929 
5930    n = alloc_instruction(ctx, OPCODE_MATERIAL, 6);
5931    if (n) {
5932       n[1].e = face;
5933       n[2].e = pname;
5934       for (i = 0; i < args; i++)
5935          n[3 + i].f = param[i];
5936    }
5937 }
5938 
5939 static void GLAPIENTRY
save_Begin(GLenum mode)5940 save_Begin(GLenum mode)
5941 {
5942    GET_CURRENT_CONTEXT(ctx);
5943 
5944    if (!_mesa_is_valid_prim_mode(ctx, mode)) {
5945       /* compile this error into the display list */
5946       _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)");
5947    }
5948    else if (_mesa_inside_dlist_begin_end(ctx)) {
5949       /* compile this error into the display list */
5950       _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive glBegin");
5951    }
5952    else {
5953       ctx->Driver.CurrentSavePrimitive = mode;
5954 
5955       vbo_save_NotifyBegin(ctx, mode, false);
5956    }
5957 }
5958 
5959 static void GLAPIENTRY
save_End(void)5960 save_End(void)
5961 {
5962    GET_CURRENT_CONTEXT(ctx);
5963    SAVE_FLUSH_VERTICES(ctx);
5964    (void) alloc_instruction(ctx, OPCODE_END, 0);
5965    ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
5966    if (ctx->ExecuteFlag) {
5967       CALL_End(ctx->Exec, ());
5968    }
5969 }
5970 
5971 static void GLAPIENTRY
save_PrimitiveRestartNV(void)5972 save_PrimitiveRestartNV(void)
5973 {
5974    /* Note: this is used when outside a glBegin/End pair in a display list */
5975    GET_CURRENT_CONTEXT(ctx);
5976    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5977    (void) alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0);
5978    if (ctx->ExecuteFlag) {
5979       CALL_PrimitiveRestartNV(ctx->Exec, ());
5980    }
5981 }
5982 
5983 
5984 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)5985 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
5986                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
5987                         GLbitfield mask, GLenum filter)
5988 {
5989    GET_CURRENT_CONTEXT(ctx);
5990    Node *n;
5991    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
5992    n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10);
5993    if (n) {
5994       n[1].i = srcX0;
5995       n[2].i = srcY0;
5996       n[3].i = srcX1;
5997       n[4].i = srcY1;
5998       n[5].i = dstX0;
5999       n[6].i = dstY0;
6000       n[7].i = dstX1;
6001       n[8].i = dstY1;
6002       n[9].i = mask;
6003       n[10].e = filter;
6004    }
6005    if (ctx->ExecuteFlag) {
6006       CALL_BlitFramebuffer(ctx->Exec, (srcX0, srcY0, srcX1, srcY1,
6007                                           dstX0, dstY0, dstX1, dstY1,
6008                                           mask, filter));
6009    }
6010 }
6011 
6012 
6013 /** GL_EXT_provoking_vertex */
6014 static void GLAPIENTRY
save_ProvokingVertexEXT(GLenum mode)6015 save_ProvokingVertexEXT(GLenum mode)
6016 {
6017    GET_CURRENT_CONTEXT(ctx);
6018    Node *n;
6019    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6020    n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1);
6021    if (n) {
6022       n[1].e = mode;
6023    }
6024    if (ctx->ExecuteFlag) {
6025       /*CALL_ProvokingVertex(ctx->Exec, (mode));*/
6026       _mesa_ProvokingVertex(mode);
6027    }
6028 }
6029 
6030 
6031 /** GL_EXT_transform_feedback */
6032 static void GLAPIENTRY
save_BeginTransformFeedback(GLenum mode)6033 save_BeginTransformFeedback(GLenum mode)
6034 {
6035    GET_CURRENT_CONTEXT(ctx);
6036    Node *n;
6037    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6038    n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1);
6039    if (n) {
6040       n[1].e = mode;
6041    }
6042    if (ctx->ExecuteFlag) {
6043       CALL_BeginTransformFeedback(ctx->Exec, (mode));
6044    }
6045 }
6046 
6047 
6048 /** GL_EXT_transform_feedback */
6049 static void GLAPIENTRY
save_EndTransformFeedback(void)6050 save_EndTransformFeedback(void)
6051 {
6052    GET_CURRENT_CONTEXT(ctx);
6053    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6054    (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0);
6055    if (ctx->ExecuteFlag) {
6056       CALL_EndTransformFeedback(ctx->Exec, ());
6057    }
6058 }
6059 
6060 static void GLAPIENTRY
save_BindTransformFeedback(GLenum target,GLuint name)6061 save_BindTransformFeedback(GLenum target, GLuint name)
6062 {
6063    GET_CURRENT_CONTEXT(ctx);
6064    Node *n;
6065    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6066    n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2);
6067    if (n) {
6068       n[1].e = target;
6069       n[2].ui = name;
6070    }
6071    if (ctx->ExecuteFlag) {
6072       CALL_BindTransformFeedback(ctx->Exec, (target, name));
6073    }
6074 }
6075 
6076 static void GLAPIENTRY
save_PauseTransformFeedback(void)6077 save_PauseTransformFeedback(void)
6078 {
6079    GET_CURRENT_CONTEXT(ctx);
6080    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6081    (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0);
6082    if (ctx->ExecuteFlag) {
6083       CALL_PauseTransformFeedback(ctx->Exec, ());
6084    }
6085 }
6086 
6087 static void GLAPIENTRY
save_ResumeTransformFeedback(void)6088 save_ResumeTransformFeedback(void)
6089 {
6090    GET_CURRENT_CONTEXT(ctx);
6091    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6092    (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0);
6093    if (ctx->ExecuteFlag) {
6094       CALL_ResumeTransformFeedback(ctx->Exec, ());
6095    }
6096 }
6097 
6098 static void GLAPIENTRY
save_DrawTransformFeedback(GLenum mode,GLuint name)6099 save_DrawTransformFeedback(GLenum mode, GLuint name)
6100 {
6101    GET_CURRENT_CONTEXT(ctx);
6102    Node *n;
6103    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6104    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2);
6105    if (n) {
6106       n[1].e = mode;
6107       n[2].ui = name;
6108    }
6109    if (ctx->ExecuteFlag) {
6110       CALL_DrawTransformFeedback(ctx->Exec, (mode, name));
6111    }
6112 }
6113 
6114 static void GLAPIENTRY
save_DrawTransformFeedbackStream(GLenum mode,GLuint name,GLuint stream)6115 save_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream)
6116 {
6117    GET_CURRENT_CONTEXT(ctx);
6118    Node *n;
6119    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6120    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM, 3);
6121    if (n) {
6122       n[1].e = mode;
6123       n[2].ui = name;
6124       n[3].ui = stream;
6125    }
6126    if (ctx->ExecuteFlag) {
6127       CALL_DrawTransformFeedbackStream(ctx->Exec, (mode, name, stream));
6128    }
6129 }
6130 
6131 static void GLAPIENTRY
save_DrawTransformFeedbackInstanced(GLenum mode,GLuint name,GLsizei primcount)6132 save_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
6133                                     GLsizei primcount)
6134 {
6135    GET_CURRENT_CONTEXT(ctx);
6136    Node *n;
6137    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6138    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED, 3);
6139    if (n) {
6140       n[1].e = mode;
6141       n[2].ui = name;
6142       n[3].si = primcount;
6143    }
6144    if (ctx->ExecuteFlag) {
6145       CALL_DrawTransformFeedbackInstanced(ctx->Exec, (mode, name, primcount));
6146    }
6147 }
6148 
6149 static void GLAPIENTRY
save_DrawTransformFeedbackStreamInstanced(GLenum mode,GLuint name,GLuint stream,GLsizei primcount)6150 save_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
6151                                           GLuint stream, GLsizei primcount)
6152 {
6153    GET_CURRENT_CONTEXT(ctx);
6154    Node *n;
6155    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6156    n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED, 4);
6157    if (n) {
6158       n[1].e = mode;
6159       n[2].ui = name;
6160       n[3].ui = stream;
6161       n[4].si = primcount;
6162    }
6163    if (ctx->ExecuteFlag) {
6164       CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec, (mode, name, stream,
6165                                                             primcount));
6166    }
6167 }
6168 
6169 static void GLAPIENTRY
save_DispatchCompute(GLuint num_groups_x,GLuint num_groups_y,GLuint num_groups_z)6170 save_DispatchCompute(GLuint num_groups_x, GLuint num_groups_y,
6171                      GLuint num_groups_z)
6172 {
6173    GET_CURRENT_CONTEXT(ctx);
6174    Node *n;
6175    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6176    n = alloc_instruction(ctx, OPCODE_DISPATCH_COMPUTE, 3);
6177    if (n) {
6178       n[1].ui = num_groups_x;
6179       n[2].ui = num_groups_y;
6180       n[3].ui = num_groups_z;
6181    }
6182    if (ctx->ExecuteFlag) {
6183       CALL_DispatchCompute(ctx->Exec, (num_groups_x, num_groups_y,
6184                                        num_groups_z));
6185    }
6186 }
6187 
6188 static void GLAPIENTRY
save_DispatchComputeIndirect(GLintptr indirect)6189 save_DispatchComputeIndirect(GLintptr indirect)
6190 {
6191    GET_CURRENT_CONTEXT(ctx);
6192    _mesa_error(ctx, GL_INVALID_OPERATION,
6193                "glDispatchComputeIndirect() during display list compile");
6194 }
6195 
6196 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)6197 save_Attr32bit(struct gl_context *ctx, unsigned attr, unsigned size,
6198                GLenum type, uint32_t x, uint32_t y, uint32_t z, uint32_t w)
6199 {
6200    Node *n;
6201    SAVE_FLUSH_VERTICES(ctx);
6202    unsigned base_op;
6203    unsigned index = attr;
6204 
6205    /* We don't care about GL_INT vs GL_UNSIGNED_INT. The idea is to get W=1
6206     * right for 3 or lower number of components, so only distinguish between
6207     * FLOAT and INT.
6208     */
6209    if (type == GL_FLOAT) {
6210       if (VERT_BIT(attr) & VERT_BIT_GENERIC_ALL) {
6211          base_op = OPCODE_ATTR_1F_ARB;
6212          attr -= VERT_ATTRIB_GENERIC0;
6213       } else {
6214          base_op = OPCODE_ATTR_1F_NV;
6215       }
6216    } else {
6217       base_op = OPCODE_ATTR_1I;
6218       attr -= VERT_ATTRIB_GENERIC0;
6219    }
6220 
6221    n = alloc_instruction(ctx, base_op + size - 1, 1 + size);
6222    if (n) {
6223       n[1].ui = attr;
6224       n[2].ui = x;
6225       if (size >= 2) n[3].ui = y;
6226       if (size >= 3) n[4].ui = z;
6227       if (size >= 4) n[5].ui = w;
6228    }
6229 
6230    ctx->ListState.ActiveAttribSize[index] = size;
6231    ASSIGN_4V(ctx->ListState.CurrentAttrib[index], x, y, z, w);
6232 
6233    if (ctx->ExecuteFlag) {
6234       if (type == GL_FLOAT) {
6235          if (base_op == OPCODE_ATTR_1F_NV) {
6236             if (size == 4)
6237                CALL_VertexAttrib4fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
6238             else if (size == 3)
6239                CALL_VertexAttrib3fNV(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
6240             else if (size == 2)
6241                CALL_VertexAttrib2fNV(ctx->Exec, (attr, uif(x), uif(y)));
6242             else
6243                CALL_VertexAttrib1fNV(ctx->Exec, (attr, uif(x)));
6244          } else {
6245             if (size == 4)
6246                CALL_VertexAttrib4fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z), uif(w)));
6247             else if (size == 3)
6248                CALL_VertexAttrib3fARB(ctx->Exec, (attr, uif(x), uif(y), uif(z)));
6249             else if (size == 2)
6250                CALL_VertexAttrib2fARB(ctx->Exec, (attr, uif(x), uif(y)));
6251             else
6252                CALL_VertexAttrib1fARB(ctx->Exec, (attr, uif(x)));
6253          }
6254       } else {
6255          if (size == 4)
6256             CALL_VertexAttribI4iEXT(ctx->Exec, (attr, x, y, z, w));
6257          else if (size == 3)
6258             CALL_VertexAttribI3iEXT(ctx->Exec, (attr, x, y, z));
6259          else if (size == 2)
6260             CALL_VertexAttribI2iEXT(ctx->Exec, (attr, x, y));
6261          else
6262             CALL_VertexAttribI1iEXT(ctx->Exec, (attr, x));
6263       }
6264    }
6265 }
6266 
6267 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)6268 save_Attr64bit(struct gl_context *ctx, unsigned attr, unsigned size,
6269                GLenum type, uint64_t x, uint64_t y, uint64_t z, uint64_t w)
6270 {
6271    Node *n;
6272    SAVE_FLUSH_VERTICES(ctx);
6273    unsigned base_op;
6274    unsigned index = attr;
6275 
6276    if (type == GL_DOUBLE) {
6277       base_op = OPCODE_ATTR_1D;
6278    } else {
6279       base_op = OPCODE_ATTR_1UI64;
6280       assert(size == 1);
6281    }
6282 
6283    attr -= VERT_ATTRIB_GENERIC0;
6284    n = alloc_instruction(ctx, base_op + size - 1, 1 + size * 2);
6285    if (n) {
6286       n[1].ui = attr;
6287       ASSIGN_UINT64_TO_NODES(n, 2, x);
6288       if (size >= 2) ASSIGN_UINT64_TO_NODES(n, 4, y);
6289       if (size >= 3) ASSIGN_UINT64_TO_NODES(n, 6, z);
6290       if (size >= 4) ASSIGN_UINT64_TO_NODES(n, 8, w);
6291    }
6292 
6293    ctx->ListState.ActiveAttribSize[index] = size;
6294    memcpy(ctx->ListState.CurrentAttrib[index], &n[2], size * sizeof(uint64_t));
6295 
6296    if (ctx->ExecuteFlag) {
6297       uint64_t v[] = {x, y, z, w};
6298       if (type == GL_DOUBLE) {
6299          if (size == 4)
6300             CALL_VertexAttribL4dv(ctx->Exec, (attr, (GLdouble*)v));
6301          else if (size == 3)
6302             CALL_VertexAttribL3dv(ctx->Exec, (attr, (GLdouble*)v));
6303          else if (size == 2)
6304             CALL_VertexAttribL2dv(ctx->Exec, (attr, (GLdouble*)v));
6305          else
6306             CALL_VertexAttribL1d(ctx->Exec, (attr, UINT64_AS_DOUBLE(x)));
6307       } else {
6308          CALL_VertexAttribL1ui64ARB(ctx->Exec, (attr, x));
6309       }
6310    }
6311 }
6312 
6313 /**
6314  * If index=0, does glVertexAttrib*() alias glVertex() to emit a vertex?
6315  * It depends on a few things, including whether we're inside or outside
6316  * of glBegin/glEnd.
6317  */
6318 static inline bool
is_vertex_position(const struct gl_context * ctx,GLuint index)6319 is_vertex_position(const struct gl_context *ctx, GLuint index)
6320 {
6321    return (index == 0 &&
6322            _mesa_attr_zero_aliases_vertex(ctx) &&
6323            _mesa_inside_dlist_begin_end(ctx));
6324 }
6325 
6326 /**
6327  * This macro is used to implement all the glVertex, glColor, glTexCoord,
6328  * glVertexAttrib, etc functions.
6329  * \param A  VBO_ATTRIB_x attribute index
6330  * \param N  attribute size (1..4)
6331  * \param T  type (GL_FLOAT, GL_DOUBLE, GL_INT, GL_UNSIGNED_INT)
6332  * \param C  cast type (uint32_t or uint64_t)
6333  * \param V0, V1, v2, V3  attribute value
6334  */
6335 #define ATTR_UNION(A, N, T, C, V0, V1, V2, V3)                          \
6336 do {                                                                    \
6337    if (sizeof(C) == 4) {                                                \
6338       save_Attr32bit(ctx, A, N, T, V0, V1, V2, V3);                     \
6339    } else {                                                             \
6340       save_Attr64bit(ctx, A, N, T, V0, V1, V2, V3);                     \
6341    }                                                                    \
6342 } while (0)
6343 
6344 #undef ERROR
6345 #define ERROR(err) _mesa_error(ctx, err, __func__)
6346 #define TAG(x) save_##x
6347 
6348 #define VBO_ATTRIB_POS           VERT_ATTRIB_POS
6349 #define VBO_ATTRIB_NORMAL        VERT_ATTRIB_NORMAL
6350 #define VBO_ATTRIB_COLOR0        VERT_ATTRIB_COLOR0
6351 #define VBO_ATTRIB_COLOR1        VERT_ATTRIB_COLOR1
6352 #define VBO_ATTRIB_FOG           VERT_ATTRIB_FOG
6353 #define VBO_ATTRIB_COLOR_INDEX   VERT_ATTRIB_COLOR_INDEX
6354 #define VBO_ATTRIB_EDGEFLAG      VERT_ATTRIB_EDGEFLAG
6355 #define VBO_ATTRIB_TEX0          VERT_ATTRIB_TEX0
6356 #define VBO_ATTRIB_GENERIC0      VERT_ATTRIB_GENERIC0
6357 #define VBO_ATTRIB_MAX           VERT_ATTRIB_MAX
6358 
6359 #include "vbo/vbo_attrib_tmp.h"
6360 
6361 static void GLAPIENTRY
save_UseProgram(GLuint program)6362 save_UseProgram(GLuint program)
6363 {
6364    GET_CURRENT_CONTEXT(ctx);
6365    Node *n;
6366    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6367    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1);
6368    if (n) {
6369       n[1].ui = program;
6370    }
6371    if (ctx->ExecuteFlag) {
6372       CALL_UseProgram(ctx->Exec, (program));
6373    }
6374 }
6375 
6376 
6377 static void GLAPIENTRY
save_Uniform1fARB(GLint location,GLfloat x)6378 save_Uniform1fARB(GLint location, GLfloat x)
6379 {
6380    GET_CURRENT_CONTEXT(ctx);
6381    Node *n;
6382    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6383    n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2);
6384    if (n) {
6385       n[1].i = location;
6386       n[2].f = x;
6387    }
6388    if (ctx->ExecuteFlag) {
6389       CALL_Uniform1f(ctx->Exec, (location, x));
6390    }
6391 }
6392 
6393 
6394 static void GLAPIENTRY
save_Uniform2fARB(GLint location,GLfloat x,GLfloat y)6395 save_Uniform2fARB(GLint location, GLfloat x, GLfloat y)
6396 {
6397    GET_CURRENT_CONTEXT(ctx);
6398    Node *n;
6399    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6400    n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3);
6401    if (n) {
6402       n[1].i = location;
6403       n[2].f = x;
6404       n[3].f = y;
6405    }
6406    if (ctx->ExecuteFlag) {
6407       CALL_Uniform2f(ctx->Exec, (location, x, y));
6408    }
6409 }
6410 
6411 
6412 static void GLAPIENTRY
save_Uniform3fARB(GLint location,GLfloat x,GLfloat y,GLfloat z)6413 save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z)
6414 {
6415    GET_CURRENT_CONTEXT(ctx);
6416    Node *n;
6417    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6418    n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4);
6419    if (n) {
6420       n[1].i = location;
6421       n[2].f = x;
6422       n[3].f = y;
6423       n[4].f = z;
6424    }
6425    if (ctx->ExecuteFlag) {
6426       CALL_Uniform3f(ctx->Exec, (location, x, y, z));
6427    }
6428 }
6429 
6430 
6431 static void GLAPIENTRY
save_Uniform4fARB(GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)6432 save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6433 {
6434    GET_CURRENT_CONTEXT(ctx);
6435    Node *n;
6436    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6437    n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5);
6438    if (n) {
6439       n[1].i = location;
6440       n[2].f = x;
6441       n[3].f = y;
6442       n[4].f = z;
6443       n[5].f = w;
6444    }
6445    if (ctx->ExecuteFlag) {
6446       CALL_Uniform4f(ctx->Exec, (location, x, y, z, w));
6447    }
6448 }
6449 
6450 
6451 static void GLAPIENTRY
save_Uniform1fvARB(GLint location,GLsizei count,const GLfloat * v)6452 save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v)
6453 {
6454    GET_CURRENT_CONTEXT(ctx);
6455    Node *n;
6456    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6457    n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 2 + POINTER_DWORDS);
6458    if (n) {
6459       n[1].i = location;
6460       n[2].i = count;
6461       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLfloat)));
6462    }
6463    if (ctx->ExecuteFlag) {
6464       CALL_Uniform1fv(ctx->Exec, (location, count, v));
6465    }
6466 }
6467 
6468 static void GLAPIENTRY
save_Uniform2fvARB(GLint location,GLsizei count,const GLfloat * v)6469 save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v)
6470 {
6471    GET_CURRENT_CONTEXT(ctx);
6472    Node *n;
6473    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6474    n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 2 + POINTER_DWORDS);
6475    if (n) {
6476       n[1].i = location;
6477       n[2].i = count;
6478       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLfloat)));
6479    }
6480    if (ctx->ExecuteFlag) {
6481       CALL_Uniform2fv(ctx->Exec, (location, count, v));
6482    }
6483 }
6484 
6485 static void GLAPIENTRY
save_Uniform3fvARB(GLint location,GLsizei count,const GLfloat * v)6486 save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v)
6487 {
6488    GET_CURRENT_CONTEXT(ctx);
6489    Node *n;
6490    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6491    n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 2 + POINTER_DWORDS);
6492    if (n) {
6493       n[1].i = location;
6494       n[2].i = count;
6495       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLfloat)));
6496    }
6497    if (ctx->ExecuteFlag) {
6498       CALL_Uniform3fv(ctx->Exec, (location, count, v));
6499    }
6500 }
6501 
6502 static void GLAPIENTRY
save_Uniform4fvARB(GLint location,GLsizei count,const GLfloat * v)6503 save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v)
6504 {
6505    GET_CURRENT_CONTEXT(ctx);
6506    Node *n;
6507    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6508    n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 2 + POINTER_DWORDS);
6509    if (n) {
6510       n[1].i = location;
6511       n[2].i = count;
6512       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6513    }
6514    if (ctx->ExecuteFlag) {
6515       CALL_Uniform4fv(ctx->Exec, (location, count, v));
6516    }
6517 }
6518 
6519 
6520 static void GLAPIENTRY
save_Uniform1d(GLint location,GLdouble x)6521 save_Uniform1d(GLint location, GLdouble x)
6522 {
6523    GET_CURRENT_CONTEXT(ctx);
6524    Node *n;
6525    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6526    n = alloc_instruction(ctx, OPCODE_UNIFORM_1D, 3);
6527    if (n) {
6528       n[1].i = location;
6529       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6530    }
6531    if (ctx->ExecuteFlag) {
6532       CALL_Uniform1d(ctx->Exec, (location, x));
6533    }
6534 }
6535 
6536 
6537 static void GLAPIENTRY
save_Uniform2d(GLint location,GLdouble x,GLdouble y)6538 save_Uniform2d(GLint location, GLdouble x, GLdouble y)
6539 {
6540    GET_CURRENT_CONTEXT(ctx);
6541    Node *n;
6542    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6543    n = alloc_instruction(ctx, OPCODE_UNIFORM_2D, 5);
6544    if (n) {
6545       n[1].i = location;
6546       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6547       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6548    }
6549    if (ctx->ExecuteFlag) {
6550       CALL_Uniform2d(ctx->Exec, (location, x, y));
6551    }
6552 }
6553 
6554 
6555 static void GLAPIENTRY
save_Uniform3d(GLint location,GLdouble x,GLdouble y,GLdouble z)6556 save_Uniform3d(GLint location, GLdouble x, GLdouble y, GLdouble z)
6557 {
6558    GET_CURRENT_CONTEXT(ctx);
6559    Node *n;
6560    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6561    n = alloc_instruction(ctx, OPCODE_UNIFORM_3D, 7);
6562    if (n) {
6563       n[1].i = location;
6564       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6565       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6566       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6567    }
6568    if (ctx->ExecuteFlag) {
6569       CALL_Uniform3d(ctx->Exec, (location, x, y, z));
6570    }
6571 }
6572 
6573 
6574 static void GLAPIENTRY
save_Uniform4d(GLint location,GLdouble x,GLdouble y,GLdouble z,GLdouble w)6575 save_Uniform4d(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
6576 {
6577    GET_CURRENT_CONTEXT(ctx);
6578    Node *n;
6579    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6580    n = alloc_instruction(ctx, OPCODE_UNIFORM_4D, 9);
6581    if (n) {
6582       n[1].i = location;
6583       ASSIGN_DOUBLE_TO_NODES(n, 2, x);
6584       ASSIGN_DOUBLE_TO_NODES(n, 4, y);
6585       ASSIGN_DOUBLE_TO_NODES(n, 6, z);
6586       ASSIGN_DOUBLE_TO_NODES(n, 8, w);
6587    }
6588    if (ctx->ExecuteFlag) {
6589       CALL_Uniform4d(ctx->Exec, (location, x, y, z, w));
6590    }
6591 }
6592 
6593 
6594 static void GLAPIENTRY
save_Uniform1dv(GLint location,GLsizei count,const GLdouble * v)6595 save_Uniform1dv(GLint location, GLsizei count, const GLdouble *v)
6596 {
6597    GET_CURRENT_CONTEXT(ctx);
6598    Node *n;
6599    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6600    n = alloc_instruction(ctx, OPCODE_UNIFORM_1DV, 2 + POINTER_DWORDS);
6601    if (n) {
6602       n[1].i = location;
6603       n[2].i = count;
6604       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLdouble)));
6605    }
6606    if (ctx->ExecuteFlag) {
6607       CALL_Uniform1dv(ctx->Exec, (location, count, v));
6608    }
6609 }
6610 
6611 
6612 static void GLAPIENTRY
save_Uniform2dv(GLint location,GLsizei count,const GLdouble * v)6613 save_Uniform2dv(GLint location, GLsizei count, const GLdouble *v)
6614 {
6615    GET_CURRENT_CONTEXT(ctx);
6616    Node *n;
6617    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6618    n = alloc_instruction(ctx, OPCODE_UNIFORM_2DV, 2 + POINTER_DWORDS);
6619    if (n) {
6620       n[1].i = location;
6621       n[2].i = count;
6622       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLdouble)));
6623    }
6624    if (ctx->ExecuteFlag) {
6625       CALL_Uniform2dv(ctx->Exec, (location, count, v));
6626    }
6627 }
6628 
6629 
6630 static void GLAPIENTRY
save_Uniform3dv(GLint location,GLsizei count,const GLdouble * v)6631 save_Uniform3dv(GLint location, GLsizei count, const GLdouble *v)
6632 {
6633    GET_CURRENT_CONTEXT(ctx);
6634    Node *n;
6635    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6636    n = alloc_instruction(ctx, OPCODE_UNIFORM_3DV, 2 + POINTER_DWORDS);
6637    if (n) {
6638       n[1].i = location;
6639       n[2].i = count;
6640       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLdouble)));
6641    }
6642    if (ctx->ExecuteFlag) {
6643       CALL_Uniform3dv(ctx->Exec, (location, count, v));
6644    }
6645 }
6646 
6647 
6648 static void GLAPIENTRY
save_Uniform4dv(GLint location,GLsizei count,const GLdouble * v)6649 save_Uniform4dv(GLint location, GLsizei count, const GLdouble *v)
6650 {
6651    GET_CURRENT_CONTEXT(ctx);
6652    Node *n;
6653    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6654    n = alloc_instruction(ctx, OPCODE_UNIFORM_4DV, 2 + POINTER_DWORDS);
6655    if (n) {
6656       n[1].i = location;
6657       n[2].i = count;
6658       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLdouble)));
6659    }
6660    if (ctx->ExecuteFlag) {
6661       CALL_Uniform4dv(ctx->Exec, (location, count, v));
6662    }
6663 }
6664 
6665 
6666 static void GLAPIENTRY
save_Uniform1iARB(GLint location,GLint x)6667 save_Uniform1iARB(GLint location, GLint x)
6668 {
6669    GET_CURRENT_CONTEXT(ctx);
6670    Node *n;
6671    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6672    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2);
6673    if (n) {
6674       n[1].i = location;
6675       n[2].i = x;
6676    }
6677    if (ctx->ExecuteFlag) {
6678       CALL_Uniform1i(ctx->Exec, (location, x));
6679    }
6680 }
6681 
6682 static void GLAPIENTRY
save_Uniform2iARB(GLint location,GLint x,GLint y)6683 save_Uniform2iARB(GLint location, GLint x, GLint y)
6684 {
6685    GET_CURRENT_CONTEXT(ctx);
6686    Node *n;
6687    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6688    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3);
6689    if (n) {
6690       n[1].i = location;
6691       n[2].i = x;
6692       n[3].i = y;
6693    }
6694    if (ctx->ExecuteFlag) {
6695       CALL_Uniform2i(ctx->Exec, (location, x, y));
6696    }
6697 }
6698 
6699 static void GLAPIENTRY
save_Uniform3iARB(GLint location,GLint x,GLint y,GLint z)6700 save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z)
6701 {
6702    GET_CURRENT_CONTEXT(ctx);
6703    Node *n;
6704    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6705    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4);
6706    if (n) {
6707       n[1].i = location;
6708       n[2].i = x;
6709       n[3].i = y;
6710       n[4].i = z;
6711    }
6712    if (ctx->ExecuteFlag) {
6713       CALL_Uniform3i(ctx->Exec, (location, x, y, z));
6714    }
6715 }
6716 
6717 static void GLAPIENTRY
save_Uniform4iARB(GLint location,GLint x,GLint y,GLint z,GLint w)6718 save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w)
6719 {
6720    GET_CURRENT_CONTEXT(ctx);
6721    Node *n;
6722    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6723    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5);
6724    if (n) {
6725       n[1].i = location;
6726       n[2].i = x;
6727       n[3].i = y;
6728       n[4].i = z;
6729       n[5].i = w;
6730    }
6731    if (ctx->ExecuteFlag) {
6732       CALL_Uniform4i(ctx->Exec, (location, x, y, z, w));
6733    }
6734 }
6735 
6736 
6737 
6738 static void GLAPIENTRY
save_Uniform1ivARB(GLint location,GLsizei count,const GLint * v)6739 save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v)
6740 {
6741    GET_CURRENT_CONTEXT(ctx);
6742    Node *n;
6743    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6744    n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 2 + POINTER_DWORDS);
6745    if (n) {
6746       n[1].i = location;
6747       n[2].i = count;
6748       save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint)));
6749    }
6750    if (ctx->ExecuteFlag) {
6751       CALL_Uniform1iv(ctx->Exec, (location, count, v));
6752    }
6753 }
6754 
6755 static void GLAPIENTRY
save_Uniform2ivARB(GLint location,GLsizei count,const GLint * v)6756 save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v)
6757 {
6758    GET_CURRENT_CONTEXT(ctx);
6759    Node *n;
6760    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6761    n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 2 + POINTER_DWORDS);
6762    if (n) {
6763       n[1].i = location;
6764       n[2].i = count;
6765       save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint)));
6766    }
6767    if (ctx->ExecuteFlag) {
6768       CALL_Uniform2iv(ctx->Exec, (location, count, v));
6769    }
6770 }
6771 
6772 static void GLAPIENTRY
save_Uniform3ivARB(GLint location,GLsizei count,const GLint * v)6773 save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v)
6774 {
6775    GET_CURRENT_CONTEXT(ctx);
6776    Node *n;
6777    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6778    n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 2 + POINTER_DWORDS);
6779    if (n) {
6780       n[1].i = location;
6781       n[2].i = count;
6782       save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint)));
6783    }
6784    if (ctx->ExecuteFlag) {
6785       CALL_Uniform3iv(ctx->Exec, (location, count, v));
6786    }
6787 }
6788 
6789 static void GLAPIENTRY
save_Uniform4ivARB(GLint location,GLsizei count,const GLint * v)6790 save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v)
6791 {
6792    GET_CURRENT_CONTEXT(ctx);
6793    Node *n;
6794    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6795    n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 2 + POINTER_DWORDS);
6796    if (n) {
6797       n[1].i = location;
6798       n[2].i = count;
6799       save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat)));
6800    }
6801    if (ctx->ExecuteFlag) {
6802       CALL_Uniform4iv(ctx->Exec, (location, count, v));
6803    }
6804 }
6805 
6806 
6807 
6808 static void GLAPIENTRY
save_Uniform1ui(GLint location,GLuint x)6809 save_Uniform1ui(GLint location, GLuint x)
6810 {
6811    GET_CURRENT_CONTEXT(ctx);
6812    Node *n;
6813    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6814    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2);
6815    if (n) {
6816       n[1].i = location;
6817       n[2].i = x;
6818    }
6819    if (ctx->ExecuteFlag) {
6820       CALL_Uniform1ui(ctx->Exec, (location, x));
6821    }
6822 }
6823 
6824 static void GLAPIENTRY
save_Uniform2ui(GLint location,GLuint x,GLuint y)6825 save_Uniform2ui(GLint location, GLuint x, GLuint y)
6826 {
6827    GET_CURRENT_CONTEXT(ctx);
6828    Node *n;
6829    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6830    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3);
6831    if (n) {
6832       n[1].i = location;
6833       n[2].i = x;
6834       n[3].i = y;
6835    }
6836    if (ctx->ExecuteFlag) {
6837       CALL_Uniform2ui(ctx->Exec, (location, x, y));
6838    }
6839 }
6840 
6841 static void GLAPIENTRY
save_Uniform3ui(GLint location,GLuint x,GLuint y,GLuint z)6842 save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z)
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_3UI, 4);
6848    if (n) {
6849       n[1].i = location;
6850       n[2].i = x;
6851       n[3].i = y;
6852       n[4].i = z;
6853    }
6854    if (ctx->ExecuteFlag) {
6855       CALL_Uniform3ui(ctx->Exec, (location, x, y, z));
6856    }
6857 }
6858 
6859 static void GLAPIENTRY
save_Uniform4ui(GLint location,GLuint x,GLuint y,GLuint z,GLuint w)6860 save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w)
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_4UI, 5);
6866    if (n) {
6867       n[1].i = location;
6868       n[2].i = x;
6869       n[3].i = y;
6870       n[4].i = z;
6871       n[5].i = w;
6872    }
6873    if (ctx->ExecuteFlag) {
6874       CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));
6875    }
6876 }
6877 
6878 
6879 
6880 static void GLAPIENTRY
save_Uniform1uiv(GLint location,GLsizei count,const GLuint * v)6881 save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v)
6882 {
6883    GET_CURRENT_CONTEXT(ctx);
6884    Node *n;
6885    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6886    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 2 + POINTER_DWORDS);
6887    if (n) {
6888       n[1].i = location;
6889       n[2].i = count;
6890       save_pointer(&n[3], memdup(v, count * 1 * sizeof(*v)));
6891    }
6892    if (ctx->ExecuteFlag) {
6893       CALL_Uniform1uiv(ctx->Exec, (location, count, v));
6894    }
6895 }
6896 
6897 static void GLAPIENTRY
save_Uniform2uiv(GLint location,GLsizei count,const GLuint * v)6898 save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v)
6899 {
6900    GET_CURRENT_CONTEXT(ctx);
6901    Node *n;
6902    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6903    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 2 + POINTER_DWORDS);
6904    if (n) {
6905       n[1].i = location;
6906       n[2].i = count;
6907       save_pointer(&n[3], memdup(v, count * 2 * sizeof(*v)));
6908    }
6909    if (ctx->ExecuteFlag) {
6910       CALL_Uniform2uiv(ctx->Exec, (location, count, v));
6911    }
6912 }
6913 
6914 static void GLAPIENTRY
save_Uniform3uiv(GLint location,GLsizei count,const GLuint * v)6915 save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v)
6916 {
6917    GET_CURRENT_CONTEXT(ctx);
6918    Node *n;
6919    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6920    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 2 + POINTER_DWORDS);
6921    if (n) {
6922       n[1].i = location;
6923       n[2].i = count;
6924       save_pointer(&n[3], memdup(v, count * 3 * sizeof(*v)));
6925    }
6926    if (ctx->ExecuteFlag) {
6927       CALL_Uniform3uiv(ctx->Exec, (location, count, v));
6928    }
6929 }
6930 
6931 static void GLAPIENTRY
save_Uniform4uiv(GLint location,GLsizei count,const GLuint * v)6932 save_Uniform4uiv(GLint location, GLsizei count, const GLuint *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_4UIV, 2 + POINTER_DWORDS);
6938    if (n) {
6939       n[1].i = location;
6940       n[2].i = count;
6941       save_pointer(&n[3], memdup(v, count * 4 * sizeof(*v)));
6942    }
6943    if (ctx->ExecuteFlag) {
6944       CALL_Uniform4uiv(ctx->Exec, (location, count, v));
6945    }
6946 }
6947 
6948 
6949 
6950 static void GLAPIENTRY
save_UniformMatrix2fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)6951 save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
6952                          const GLfloat *m)
6953 {
6954    GET_CURRENT_CONTEXT(ctx);
6955    Node *n;
6956    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6957    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 3 + POINTER_DWORDS);
6958    if (n) {
6959       n[1].i = location;
6960       n[2].i = count;
6961       n[3].b = transpose;
6962       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLfloat)));
6963    }
6964    if (ctx->ExecuteFlag) {
6965       CALL_UniformMatrix2fv(ctx->Exec, (location, count, transpose, m));
6966    }
6967 }
6968 
6969 static void GLAPIENTRY
save_UniformMatrix3fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)6970 save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
6971                          const GLfloat *m)
6972 {
6973    GET_CURRENT_CONTEXT(ctx);
6974    Node *n;
6975    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6976    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 3 + POINTER_DWORDS);
6977    if (n) {
6978       n[1].i = location;
6979       n[2].i = count;
6980       n[3].b = transpose;
6981       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLfloat)));
6982    }
6983    if (ctx->ExecuteFlag) {
6984       CALL_UniformMatrix3fv(ctx->Exec, (location, count, transpose, m));
6985    }
6986 }
6987 
6988 static void GLAPIENTRY
save_UniformMatrix4fvARB(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)6989 save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
6990                          const GLfloat *m)
6991 {
6992    GET_CURRENT_CONTEXT(ctx);
6993    Node *n;
6994    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
6995    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 3 + POINTER_DWORDS);
6996    if (n) {
6997       n[1].i = location;
6998       n[2].i = count;
6999       n[3].b = transpose;
7000       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLfloat)));
7001    }
7002    if (ctx->ExecuteFlag) {
7003       CALL_UniformMatrix4fv(ctx->Exec, (location, count, transpose, m));
7004    }
7005 }
7006 
7007 
7008 static void GLAPIENTRY
save_UniformMatrix2x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7009 save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
7010                         const GLfloat *m)
7011 {
7012    GET_CURRENT_CONTEXT(ctx);
7013    Node *n;
7014    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7015    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 3 + POINTER_DWORDS);
7016    if (n) {
7017       n[1].i = location;
7018       n[2].i = count;
7019       n[3].b = transpose;
7020       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLfloat)));
7021    }
7022    if (ctx->ExecuteFlag) {
7023       CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m));
7024    }
7025 }
7026 
7027 static void GLAPIENTRY
save_UniformMatrix3x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7028 save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
7029                         const GLfloat *m)
7030 {
7031    GET_CURRENT_CONTEXT(ctx);
7032    Node *n;
7033    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7034    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 3 + POINTER_DWORDS);
7035    if (n) {
7036       n[1].i = location;
7037       n[2].i = count;
7038       n[3].b = transpose;
7039       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLfloat)));
7040    }
7041    if (ctx->ExecuteFlag) {
7042       CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m));
7043    }
7044 }
7045 
7046 
7047 static void GLAPIENTRY
save_UniformMatrix2x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7048 save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
7049                         const GLfloat *m)
7050 {
7051    GET_CURRENT_CONTEXT(ctx);
7052    Node *n;
7053    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7054    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 3 + POINTER_DWORDS);
7055    if (n) {
7056       n[1].i = location;
7057       n[2].i = count;
7058       n[3].b = transpose;
7059       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLfloat)));
7060    }
7061    if (ctx->ExecuteFlag) {
7062       CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m));
7063    }
7064 }
7065 
7066 static void GLAPIENTRY
save_UniformMatrix4x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7067 save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
7068                         const GLfloat *m)
7069 {
7070    GET_CURRENT_CONTEXT(ctx);
7071    Node *n;
7072    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7073    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 3 + POINTER_DWORDS);
7074    if (n) {
7075       n[1].i = location;
7076       n[2].i = count;
7077       n[3].b = transpose;
7078       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLfloat)));
7079    }
7080    if (ctx->ExecuteFlag) {
7081       CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m));
7082    }
7083 }
7084 
7085 
7086 static void GLAPIENTRY
save_UniformMatrix3x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7087 save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
7088                         const GLfloat *m)
7089 {
7090    GET_CURRENT_CONTEXT(ctx);
7091    Node *n;
7092    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7093    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 3 + POINTER_DWORDS);
7094    if (n) {
7095       n[1].i = location;
7096       n[2].i = count;
7097       n[3].b = transpose;
7098       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLfloat)));
7099    }
7100    if (ctx->ExecuteFlag) {
7101       CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m));
7102    }
7103 }
7104 
7105 static void GLAPIENTRY
save_UniformMatrix4x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * m)7106 save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
7107                         const GLfloat *m)
7108 {
7109    GET_CURRENT_CONTEXT(ctx);
7110    Node *n;
7111    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7112    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 3 + POINTER_DWORDS);
7113    if (n) {
7114       n[1].i = location;
7115       n[2].i = count;
7116       n[3].b = transpose;
7117       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLfloat)));
7118    }
7119    if (ctx->ExecuteFlag) {
7120       CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m));
7121    }
7122 }
7123 
7124 
7125 static void GLAPIENTRY
save_UniformMatrix2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7126 save_UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose,
7127                       const GLdouble *m)
7128 {
7129    GET_CURRENT_CONTEXT(ctx);
7130    Node *n;
7131    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7132    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22D, 3 + POINTER_DWORDS);
7133    if (n) {
7134       n[1].i = location;
7135       n[2].i = count;
7136       n[3].b = transpose;
7137       save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLdouble)));
7138    }
7139    if (ctx->ExecuteFlag) {
7140       CALL_UniformMatrix2dv(ctx->Exec, (location, count, transpose, m));
7141    }
7142 }
7143 
7144 static void GLAPIENTRY
save_UniformMatrix3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7145 save_UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose,
7146                       const GLdouble *m)
7147 {
7148    GET_CURRENT_CONTEXT(ctx);
7149    Node *n;
7150    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7151    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33D, 3 + POINTER_DWORDS);
7152    if (n) {
7153       n[1].i = location;
7154       n[2].i = count;
7155       n[3].b = transpose;
7156       save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLdouble)));
7157    }
7158    if (ctx->ExecuteFlag) {
7159       CALL_UniformMatrix3dv(ctx->Exec, (location, count, transpose, m));
7160    }
7161 }
7162 
7163 static void GLAPIENTRY
save_UniformMatrix4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7164 save_UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose,
7165                       const GLdouble *m)
7166 {
7167    GET_CURRENT_CONTEXT(ctx);
7168    Node *n;
7169    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7170    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44D, 3 + POINTER_DWORDS);
7171    if (n) {
7172       n[1].i = location;
7173       n[2].i = count;
7174       n[3].b = transpose;
7175       save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLdouble)));
7176    }
7177    if (ctx->ExecuteFlag) {
7178       CALL_UniformMatrix4dv(ctx->Exec, (location, count, transpose, m));
7179    }
7180 }
7181 
7182 
7183 static void GLAPIENTRY
save_UniformMatrix2x3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7184 save_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose,
7185                         const GLdouble *m)
7186 {
7187    GET_CURRENT_CONTEXT(ctx);
7188    Node *n;
7189    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7190    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23D, 3 + POINTER_DWORDS);
7191    if (n) {
7192       n[1].i = location;
7193       n[2].i = count;
7194       n[3].b = transpose;
7195       save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLdouble)));
7196    }
7197    if (ctx->ExecuteFlag) {
7198       CALL_UniformMatrix2x3dv(ctx->Exec, (location, count, transpose, m));
7199    }
7200 }
7201 
7202 
7203 static void GLAPIENTRY
save_UniformMatrix3x2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7204 save_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose,
7205                         const GLdouble *m)
7206 {
7207    GET_CURRENT_CONTEXT(ctx);
7208    Node *n;
7209    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7210    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32D, 3 + POINTER_DWORDS);
7211    if (n) {
7212       n[1].i = location;
7213       n[2].i = count;
7214       n[3].b = transpose;
7215       save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLdouble)));
7216    }
7217    if (ctx->ExecuteFlag) {
7218       CALL_UniformMatrix3x2dv(ctx->Exec, (location, count, transpose, m));
7219    }
7220 }
7221 
7222 
7223 static void GLAPIENTRY
save_UniformMatrix2x4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7224 save_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose,
7225                         const GLdouble *m)
7226 {
7227    GET_CURRENT_CONTEXT(ctx);
7228    Node *n;
7229    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7230    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24D, 3 + POINTER_DWORDS);
7231    if (n) {
7232       n[1].i = location;
7233       n[2].i = count;
7234       n[3].b = transpose;
7235       save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLdouble)));
7236    }
7237    if (ctx->ExecuteFlag) {
7238       CALL_UniformMatrix2x4dv(ctx->Exec, (location, count, transpose, m));
7239    }
7240 }
7241 
7242 static void GLAPIENTRY
save_UniformMatrix4x2dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7243 save_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose,
7244                         const GLdouble *m)
7245 {
7246    GET_CURRENT_CONTEXT(ctx);
7247    Node *n;
7248    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7249    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42D, 3 + POINTER_DWORDS);
7250    if (n) {
7251       n[1].i = location;
7252       n[2].i = count;
7253       n[3].b = transpose;
7254       save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLdouble)));
7255    }
7256    if (ctx->ExecuteFlag) {
7257       CALL_UniformMatrix4x2dv(ctx->Exec, (location, count, transpose, m));
7258    }
7259 }
7260 
7261 
7262 static void GLAPIENTRY
save_UniformMatrix3x4dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7263 save_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose,
7264                         const GLdouble *m)
7265 {
7266    GET_CURRENT_CONTEXT(ctx);
7267    Node *n;
7268    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7269    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34D, 3 + POINTER_DWORDS);
7270    if (n) {
7271       n[1].i = location;
7272       n[2].i = count;
7273       n[3].b = transpose;
7274       save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLdouble)));
7275    }
7276    if (ctx->ExecuteFlag) {
7277       CALL_UniformMatrix3x4dv(ctx->Exec, (location, count, transpose, m));
7278    }
7279 }
7280 
7281 
7282 static void GLAPIENTRY
save_UniformMatrix4x3dv(GLint location,GLsizei count,GLboolean transpose,const GLdouble * m)7283 save_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose,
7284                         const GLdouble *m)
7285 {
7286    GET_CURRENT_CONTEXT(ctx);
7287    Node *n;
7288    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7289    n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43D, 3 + POINTER_DWORDS);
7290    if (n) {
7291       n[1].i = location;
7292       n[2].i = count;
7293       n[3].b = transpose;
7294       save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLdouble)));
7295    }
7296    if (ctx->ExecuteFlag) {
7297       CALL_UniformMatrix4x3dv(ctx->Exec, (location, count, transpose, m));
7298    }
7299 }
7300 
7301 static void GLAPIENTRY
save_Uniform1i64ARB(GLint location,GLint64 x)7302 save_Uniform1i64ARB(GLint location, GLint64 x)
7303 {
7304    GET_CURRENT_CONTEXT(ctx);
7305    Node *n;
7306    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7307    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64, 3);
7308    if (n) {
7309       n[1].i = location;
7310       ASSIGN_INT64_TO_NODES(n, 2, x);
7311    }
7312    if (ctx->ExecuteFlag) {
7313       CALL_Uniform1i64ARB(ctx->Exec, (location, x));
7314    }
7315 }
7316 
7317 static void GLAPIENTRY
save_Uniform2i64ARB(GLint location,GLint64 x,GLint64 y)7318 save_Uniform2i64ARB(GLint location, GLint64 x, GLint64 y)
7319 {
7320    GET_CURRENT_CONTEXT(ctx);
7321    Node *n;
7322    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7323    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64, 5);
7324    if (n) {
7325       n[1].i = location;
7326       ASSIGN_INT64_TO_NODES(n, 2, x);
7327       ASSIGN_INT64_TO_NODES(n, 4, y);
7328    }
7329    if (ctx->ExecuteFlag) {
7330       CALL_Uniform2i64ARB(ctx->Exec, (location, x, y));
7331    }
7332 }
7333 
7334 static void GLAPIENTRY
save_Uniform3i64ARB(GLint location,GLint64 x,GLint64 y,GLint64 z)7335 save_Uniform3i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z)
7336 {
7337    GET_CURRENT_CONTEXT(ctx);
7338    Node *n;
7339    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7340    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64, 7);
7341    if (n) {
7342       n[1].i = location;
7343       ASSIGN_INT64_TO_NODES(n, 2, x);
7344       ASSIGN_INT64_TO_NODES(n, 4, y);
7345       ASSIGN_INT64_TO_NODES(n, 6, z);
7346    }
7347    if (ctx->ExecuteFlag) {
7348       CALL_Uniform3i64ARB(ctx->Exec, (location, x, y, z));
7349    }
7350 }
7351 
7352 static void GLAPIENTRY
save_Uniform4i64ARB(GLint location,GLint64 x,GLint64 y,GLint64 z,GLint64 w)7353 save_Uniform4i64ARB(GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w)
7354 {
7355    GET_CURRENT_CONTEXT(ctx);
7356    Node *n;
7357    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7358    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64, 9);
7359    if (n) {
7360       n[1].i = location;
7361       ASSIGN_INT64_TO_NODES(n, 2, x);
7362       ASSIGN_INT64_TO_NODES(n, 4, y);
7363       ASSIGN_INT64_TO_NODES(n, 6, z);
7364       ASSIGN_INT64_TO_NODES(n, 8, w);
7365    }
7366    if (ctx->ExecuteFlag) {
7367       CALL_Uniform4i64ARB(ctx->Exec, (location, x, y, z, w));
7368    }
7369 }
7370 
7371 static void GLAPIENTRY
save_Uniform1i64vARB(GLint location,GLsizei count,const GLint64 * v)7372 save_Uniform1i64vARB(GLint location, GLsizei count, const GLint64 *v)
7373 {
7374    GET_CURRENT_CONTEXT(ctx);
7375    Node *n;
7376    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7377    n = alloc_instruction(ctx, OPCODE_UNIFORM_1I64V, 2 + POINTER_DWORDS);
7378    if (n) {
7379      n[1].i = location;
7380      n[2].i = count;
7381      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint64)));
7382    }
7383    if (ctx->ExecuteFlag) {
7384       CALL_Uniform1i64vARB(ctx->Exec, (location, count, v));
7385    }
7386 }
7387 
7388 static void GLAPIENTRY
save_Uniform2i64vARB(GLint location,GLsizei count,const GLint64 * v)7389 save_Uniform2i64vARB(GLint location, GLsizei count, const GLint64 *v)
7390 {
7391    GET_CURRENT_CONTEXT(ctx);
7392    Node *n;
7393    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7394    n = alloc_instruction(ctx, OPCODE_UNIFORM_2I64V, 2 + POINTER_DWORDS);
7395    if (n) {
7396      n[1].i = location;
7397      n[2].i = count;
7398      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint64)));
7399    }
7400    if (ctx->ExecuteFlag) {
7401       CALL_Uniform2i64vARB(ctx->Exec, (location, count, v));
7402    }
7403 }
7404 
7405 static void GLAPIENTRY
save_Uniform3i64vARB(GLint location,GLsizei count,const GLint64 * v)7406 save_Uniform3i64vARB(GLint location, GLsizei count, const GLint64 *v)
7407 {
7408    GET_CURRENT_CONTEXT(ctx);
7409    Node *n;
7410    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7411    n = alloc_instruction(ctx, OPCODE_UNIFORM_3I64V, 2 + POINTER_DWORDS);
7412    if (n) {
7413      n[1].i = location;
7414      n[2].i = count;
7415      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint64)));
7416    }
7417    if (ctx->ExecuteFlag) {
7418       CALL_Uniform3i64vARB(ctx->Exec, (location, count, v));
7419    }
7420 }
7421 
7422 static void GLAPIENTRY
save_Uniform4i64vARB(GLint location,GLsizei count,const GLint64 * v)7423 save_Uniform4i64vARB(GLint location, GLsizei count, const GLint64 *v)
7424 {
7425    GET_CURRENT_CONTEXT(ctx);
7426    Node *n;
7427    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7428    n = alloc_instruction(ctx, OPCODE_UNIFORM_4I64V, 2 + POINTER_DWORDS);
7429    if (n) {
7430      n[1].i = location;
7431      n[2].i = count;
7432      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLint64)));
7433    }
7434    if (ctx->ExecuteFlag) {
7435       CALL_Uniform4i64vARB(ctx->Exec, (location, count, v));
7436    }
7437 }
7438 
7439 static void GLAPIENTRY
save_Uniform1ui64ARB(GLint location,GLuint64 x)7440 save_Uniform1ui64ARB(GLint location, GLuint64 x)
7441 {
7442    GET_CURRENT_CONTEXT(ctx);
7443    Node *n;
7444    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7445    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64, 3);
7446    if (n) {
7447       n[1].i = location;
7448       ASSIGN_UINT64_TO_NODES(n, 2, x);
7449    }
7450    if (ctx->ExecuteFlag) {
7451       CALL_Uniform1ui64ARB(ctx->Exec, (location, x));
7452    }
7453 }
7454 
7455 static void GLAPIENTRY
save_Uniform2ui64ARB(GLint location,GLuint64 x,GLuint64 y)7456 save_Uniform2ui64ARB(GLint location, GLuint64 x, GLuint64 y)
7457 {
7458    GET_CURRENT_CONTEXT(ctx);
7459    Node *n;
7460    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7461    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64, 5);
7462    if (n) {
7463       n[1].i = location;
7464       ASSIGN_UINT64_TO_NODES(n, 2, x);
7465       ASSIGN_UINT64_TO_NODES(n, 4, y);
7466    }
7467    if (ctx->ExecuteFlag) {
7468       CALL_Uniform2ui64ARB(ctx->Exec, (location, x, y));
7469    }
7470 }
7471 
7472 static void GLAPIENTRY
save_Uniform3ui64ARB(GLint location,GLuint64 x,GLuint64 y,GLuint64 z)7473 save_Uniform3ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z)
7474 {
7475    GET_CURRENT_CONTEXT(ctx);
7476    Node *n;
7477    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7478    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64, 7);
7479    if (n) {
7480       n[1].i = location;
7481       ASSIGN_UINT64_TO_NODES(n, 2, x);
7482       ASSIGN_UINT64_TO_NODES(n, 4, y);
7483       ASSIGN_UINT64_TO_NODES(n, 6, z);
7484    }
7485    if (ctx->ExecuteFlag) {
7486       CALL_Uniform3ui64ARB(ctx->Exec, (location, x, y, z));
7487    }
7488 }
7489 
7490 static void GLAPIENTRY
save_Uniform4ui64ARB(GLint location,GLuint64 x,GLuint64 y,GLuint64 z,GLuint64 w)7491 save_Uniform4ui64ARB(GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w)
7492 {
7493    GET_CURRENT_CONTEXT(ctx);
7494    Node *n;
7495    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7496    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64, 9);
7497    if (n) {
7498       n[1].i = location;
7499       ASSIGN_UINT64_TO_NODES(n, 2, x);
7500       ASSIGN_UINT64_TO_NODES(n, 4, y);
7501       ASSIGN_UINT64_TO_NODES(n, 6, z);
7502       ASSIGN_UINT64_TO_NODES(n, 8, w);
7503    }
7504    if (ctx->ExecuteFlag) {
7505       CALL_Uniform4ui64ARB(ctx->Exec, (location, x, y, z, w));
7506    }
7507 }
7508 
7509 static void GLAPIENTRY
save_Uniform1ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7510 save_Uniform1ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7511 {
7512    GET_CURRENT_CONTEXT(ctx);
7513    Node *n;
7514    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7515    n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI64V, 2 + POINTER_DWORDS);
7516    if (n) {
7517      n[1].i = location;
7518      n[2].i = count;
7519      save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLuint64)));
7520    }
7521    if (ctx->ExecuteFlag) {
7522       CALL_Uniform1ui64vARB(ctx->Exec, (location, count, v));
7523    }
7524 }
7525 
7526 static void GLAPIENTRY
save_Uniform2ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7527 save_Uniform2ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7528 {
7529    GET_CURRENT_CONTEXT(ctx);
7530    Node *n;
7531    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7532    n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI64V, 2 + POINTER_DWORDS);
7533    if (n) {
7534      n[1].i = location;
7535      n[2].i = count;
7536      save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLuint64)));
7537    }
7538    if (ctx->ExecuteFlag) {
7539       CALL_Uniform2ui64vARB(ctx->Exec, (location, count, v));
7540    }
7541 }
7542 
7543 static void GLAPIENTRY
save_Uniform3ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7544 save_Uniform3ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7545 {
7546    GET_CURRENT_CONTEXT(ctx);
7547    Node *n;
7548    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7549    n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI64V, 2 + POINTER_DWORDS);
7550    if (n) {
7551      n[1].i = location;
7552      n[2].i = count;
7553      save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLuint64)));
7554    }
7555    if (ctx->ExecuteFlag) {
7556       CALL_Uniform3ui64vARB(ctx->Exec, (location, count, v));
7557    }
7558 }
7559 
7560 static void GLAPIENTRY
save_Uniform4ui64vARB(GLint location,GLsizei count,const GLuint64 * v)7561 save_Uniform4ui64vARB(GLint location, GLsizei count, const GLuint64 *v)
7562 {
7563    GET_CURRENT_CONTEXT(ctx);
7564    Node *n;
7565    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7566    n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI64V, 2 + POINTER_DWORDS);
7567    if (n) {
7568      n[1].i = location;
7569      n[2].i = count;
7570      save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLuint64)));
7571    }
7572    if (ctx->ExecuteFlag) {
7573       CALL_Uniform4ui64vARB(ctx->Exec, (location, count, v));
7574    }
7575 }
7576 
7577 static void GLAPIENTRY
save_ProgramUniform1i64ARB(GLuint program,GLint location,GLint64 x)7578 save_ProgramUniform1i64ARB(GLuint program, GLint location, GLint64 x)
7579 {
7580    GET_CURRENT_CONTEXT(ctx);
7581    Node *n;
7582    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7583    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I64, 4);
7584    if (n) {
7585       n[1].ui = program;
7586       n[2].i = location;
7587       ASSIGN_INT64_TO_NODES(n, 3, x);
7588    }
7589    if (ctx->ExecuteFlag) {
7590       CALL_ProgramUniform1i64ARB(ctx->Exec, (program, location, x));
7591    }
7592 }
7593 
7594 static void GLAPIENTRY
save_ProgramUniform2i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y)7595 save_ProgramUniform2i64ARB(GLuint program, GLint location, GLint64 x,
7596                            GLint64 y)
7597 {
7598    GET_CURRENT_CONTEXT(ctx);
7599    Node *n;
7600    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7601    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64, 6);
7602    if (n) {
7603       n[1].ui = program;
7604       n[2].i = location;
7605       ASSIGN_INT64_TO_NODES(n, 3, x);
7606       ASSIGN_INT64_TO_NODES(n, 5, y);
7607    }
7608    if (ctx->ExecuteFlag) {
7609       CALL_ProgramUniform2i64ARB(ctx->Exec, (program, location, x, y));
7610    }
7611 }
7612 
7613 static void GLAPIENTRY
save_ProgramUniform3i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y,GLint64 z)7614 save_ProgramUniform3i64ARB(GLuint program, GLint location, GLint64 x,
7615                            GLint64 y, GLint64 z)
7616 {
7617    GET_CURRENT_CONTEXT(ctx);
7618    Node *n;
7619    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7620    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64, 8);
7621    if (n) {
7622       n[1].ui = program;
7623       n[2].i = location;
7624       ASSIGN_INT64_TO_NODES(n, 3, x);
7625       ASSIGN_INT64_TO_NODES(n, 5, y);
7626       ASSIGN_INT64_TO_NODES(n, 7, z);
7627    }
7628    if (ctx->ExecuteFlag) {
7629       CALL_ProgramUniform3i64ARB(ctx->Exec, (program, location, x, y, z));
7630    }
7631 }
7632 
7633 static void GLAPIENTRY
save_ProgramUniform4i64ARB(GLuint program,GLint location,GLint64 x,GLint64 y,GLint64 z,GLint64 w)7634 save_ProgramUniform4i64ARB(GLuint program, GLint location, GLint64 x,
7635                            GLint64 y, GLint64 z, GLint64 w)
7636 {
7637    GET_CURRENT_CONTEXT(ctx);
7638    Node *n;
7639    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7640    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I64, 10);
7641    if (n) {
7642       n[1].ui = program;
7643       n[2].i = location;
7644       ASSIGN_INT64_TO_NODES(n, 3, x);
7645       ASSIGN_INT64_TO_NODES(n, 5, y);
7646       ASSIGN_INT64_TO_NODES(n, 7, z);
7647       ASSIGN_INT64_TO_NODES(n, 9, w);
7648    }
7649    if (ctx->ExecuteFlag) {
7650       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7651    }
7652 }
7653 
7654 static void GLAPIENTRY
save_ProgramUniform1i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7655 save_ProgramUniform1i64vARB(GLuint program, GLint location, GLsizei count,
7656                             const GLint64 *v)
7657 {
7658    GET_CURRENT_CONTEXT(ctx);
7659    Node *n;
7660    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7661    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I64V, 3 + POINTER_DWORDS);
7662    if (n) {
7663       n[1].ui = program;
7664       n[2].i = location;
7665       n[3].i = count;
7666       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7667    }
7668    if (ctx->ExecuteFlag) {
7669       CALL_ProgramUniform1i64vARB(ctx->Exec, (program, location, count, v));
7670    }
7671 }
7672 
7673 static void GLAPIENTRY
save_ProgramUniform2i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7674 save_ProgramUniform2i64vARB(GLuint program, GLint location, GLsizei count,
7675                             const GLint64 *v)
7676 {
7677    GET_CURRENT_CONTEXT(ctx);
7678    Node *n;
7679    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7680    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I64V, 3 + POINTER_DWORDS);
7681    if (n) {
7682       n[1].ui = program;
7683       n[2].i = location;
7684       n[3].i = count;
7685       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7686    }
7687    if (ctx->ExecuteFlag) {
7688       CALL_ProgramUniform2i64vARB(ctx->Exec, (program, location, count, v));
7689    }
7690 }
7691 
7692 static void GLAPIENTRY
save_ProgramUniform3i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7693 save_ProgramUniform3i64vARB(GLuint program, GLint location, GLsizei count,
7694                             const GLint64 *v)
7695 {
7696    GET_CURRENT_CONTEXT(ctx);
7697    Node *n;
7698    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7699    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I64V, 3 + POINTER_DWORDS);
7700    if (n) {
7701       n[1].ui = program;
7702       n[2].i = location;
7703       n[3].i = count;
7704       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7705    }
7706    if (ctx->ExecuteFlag) {
7707       CALL_ProgramUniform3i64vARB(ctx->Exec, (program, location, count, v));
7708    }
7709 }
7710 
7711 static void GLAPIENTRY
save_ProgramUniform4i64vARB(GLuint program,GLint location,GLsizei count,const GLint64 * v)7712 save_ProgramUniform4i64vARB(GLuint program, GLint location, GLsizei count,
7713                             const GLint64 *v)
7714 {
7715    GET_CURRENT_CONTEXT(ctx);
7716    Node *n;
7717    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7718    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I64V, 3 + POINTER_DWORDS);
7719    if (n) {
7720       n[1].ui = program;
7721       n[2].i = location;
7722       n[3].i = count;
7723       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint64)));
7724    }
7725    if (ctx->ExecuteFlag) {
7726       CALL_ProgramUniform4i64vARB(ctx->Exec, (program, location, count, v));
7727    }
7728 }
7729 
7730 static void GLAPIENTRY
save_ProgramUniform1ui64ARB(GLuint program,GLint location,GLuint64 x)7731 save_ProgramUniform1ui64ARB(GLuint program, GLint location, GLuint64 x)
7732 {
7733    GET_CURRENT_CONTEXT(ctx);
7734    Node *n;
7735    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7736    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64, 4);
7737    if (n) {
7738       n[1].ui = program;
7739       n[2].i = location;
7740       ASSIGN_UINT64_TO_NODES(n, 3, x);
7741    }
7742    if (ctx->ExecuteFlag) {
7743       CALL_ProgramUniform1ui64ARB(ctx->Exec, (program, location, x));
7744    }
7745 }
7746 
7747 static void GLAPIENTRY
save_ProgramUniform2ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y)7748 save_ProgramUniform2ui64ARB(GLuint program, GLint location, GLuint64 x,
7749                             GLuint64 y)
7750 {
7751    GET_CURRENT_CONTEXT(ctx);
7752    Node *n;
7753    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7754    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI64, 6);
7755    if (n) {
7756       n[1].ui = program;
7757       n[2].i = location;
7758       ASSIGN_UINT64_TO_NODES(n, 3, x);
7759       ASSIGN_UINT64_TO_NODES(n, 5, y);
7760    }
7761    if (ctx->ExecuteFlag) {
7762       CALL_ProgramUniform2ui64ARB(ctx->Exec, (program, location, x, y));
7763    }
7764 }
7765 
7766 static void GLAPIENTRY
save_ProgramUniform3ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y,GLuint64 z)7767 save_ProgramUniform3ui64ARB(GLuint program, GLint location, GLuint64 x,
7768                             GLuint64 y, GLuint64 z)
7769 {
7770    GET_CURRENT_CONTEXT(ctx);
7771    Node *n;
7772    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7773    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI64, 8);
7774    if (n) {
7775       n[1].ui = program;
7776       n[2].i = location;
7777       ASSIGN_UINT64_TO_NODES(n, 3, x);
7778       ASSIGN_UINT64_TO_NODES(n, 5, y);
7779       ASSIGN_UINT64_TO_NODES(n, 7, z);
7780    }
7781    if (ctx->ExecuteFlag) {
7782       CALL_ProgramUniform3ui64ARB(ctx->Exec, (program, location, x, y, z));
7783    }
7784 }
7785 
7786 static void GLAPIENTRY
save_ProgramUniform4ui64ARB(GLuint program,GLint location,GLuint64 x,GLuint64 y,GLuint64 z,GLuint64 w)7787 save_ProgramUniform4ui64ARB(GLuint program, GLint location, GLuint64 x,
7788                             GLuint64 y, GLuint64 z, GLuint64 w)
7789 {
7790    GET_CURRENT_CONTEXT(ctx);
7791    Node *n;
7792    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7793    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64, 10);
7794    if (n) {
7795       n[1].ui = program;
7796       n[2].i = location;
7797       ASSIGN_UINT64_TO_NODES(n, 3, x);
7798       ASSIGN_UINT64_TO_NODES(n, 5, y);
7799       ASSIGN_UINT64_TO_NODES(n, 7, z);
7800       ASSIGN_UINT64_TO_NODES(n, 9, w);
7801    }
7802    if (ctx->ExecuteFlag) {
7803       CALL_ProgramUniform4i64ARB(ctx->Exec, (program, location, x, y, z, w));
7804    }
7805 }
7806 
7807 static void GLAPIENTRY
save_ProgramUniform1ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)7808 save_ProgramUniform1ui64vARB(GLuint program, GLint location, GLsizei count,
7809                              const GLuint64 *v)
7810 {
7811    GET_CURRENT_CONTEXT(ctx);
7812    Node *n;
7813    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7814    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI64V,
7815                          3 + POINTER_DWORDS);
7816    if (n) {
7817       n[1].ui = program;
7818       n[2].i = location;
7819       n[3].i = count;
7820       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7821    }
7822    if (ctx->ExecuteFlag) {
7823       CALL_ProgramUniform1ui64vARB(ctx->Exec, (program, location, count, v));
7824    }
7825 }
7826 
7827 static void GLAPIENTRY
save_ProgramUniform2ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)7828 save_ProgramUniform2ui64vARB(GLuint program, GLint location, GLsizei count,
7829                             const GLuint64 *v)
7830 {
7831    GET_CURRENT_CONTEXT(ctx);
7832    Node *n;
7833    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7834    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI64V,
7835                          3 + POINTER_DWORDS);
7836    if (n) {
7837       n[1].ui = program;
7838       n[2].i = location;
7839       n[3].i = count;
7840       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7841    }
7842    if (ctx->ExecuteFlag) {
7843       CALL_ProgramUniform2ui64vARB(ctx->Exec, (program, location, count, v));
7844    }
7845 }
7846 
7847 static void GLAPIENTRY
save_ProgramUniform3ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)7848 save_ProgramUniform3ui64vARB(GLuint program, GLint location, GLsizei count,
7849                              const GLuint64 *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_3UI64V,
7855                          3 + POINTER_DWORDS);
7856    if (n) {
7857       n[1].ui = program;
7858       n[2].i = location;
7859       n[3].i = count;
7860       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7861    }
7862    if (ctx->ExecuteFlag) {
7863       CALL_ProgramUniform3ui64vARB(ctx->Exec, (program, location, count, v));
7864    }
7865 }
7866 
7867 static void GLAPIENTRY
save_ProgramUniform4ui64vARB(GLuint program,GLint location,GLsizei count,const GLuint64 * v)7868 save_ProgramUniform4ui64vARB(GLuint program, GLint location, GLsizei count,
7869                              const GLuint64 *v)
7870 {
7871    GET_CURRENT_CONTEXT(ctx);
7872    Node *n;
7873    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7874    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI64V,
7875                          3 + POINTER_DWORDS);
7876    if (n) {
7877       n[1].ui = program;
7878       n[2].i = location;
7879       n[3].i = count;
7880       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint64)));
7881    }
7882    if (ctx->ExecuteFlag) {
7883       CALL_ProgramUniform4ui64vARB(ctx->Exec, (program, location, count, v));
7884    }
7885 }
7886 
7887 
7888 static void GLAPIENTRY
save_UseProgramStages(GLuint pipeline,GLbitfield stages,GLuint program)7889 save_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
7890 {
7891    GET_CURRENT_CONTEXT(ctx);
7892    Node *n;
7893    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7894    n = alloc_instruction(ctx, OPCODE_USE_PROGRAM_STAGES, 3);
7895    if (n) {
7896       n[1].ui = pipeline;
7897       n[2].ui = stages;
7898       n[3].ui = program;
7899    }
7900    if (ctx->ExecuteFlag) {
7901       CALL_UseProgramStages(ctx->Exec, (pipeline, stages, program));
7902    }
7903 }
7904 
7905 static void GLAPIENTRY
save_ProgramUniform1f(GLuint program,GLint location,GLfloat x)7906 save_ProgramUniform1f(GLuint program, GLint location, GLfloat x)
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_1F, 3);
7912    if (n) {
7913       n[1].ui = program;
7914       n[2].i = location;
7915       n[3].f = x;
7916    }
7917    if (ctx->ExecuteFlag) {
7918       CALL_ProgramUniform1f(ctx->Exec, (program, location, x));
7919    }
7920 }
7921 
7922 static void GLAPIENTRY
save_ProgramUniform2f(GLuint program,GLint location,GLfloat x,GLfloat y)7923 save_ProgramUniform2f(GLuint program, GLint location, GLfloat x, GLfloat y)
7924 {
7925    GET_CURRENT_CONTEXT(ctx);
7926    Node *n;
7927    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7928    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2F, 4);
7929    if (n) {
7930       n[1].ui = program;
7931       n[2].i = location;
7932       n[3].f = x;
7933       n[4].f = y;
7934    }
7935    if (ctx->ExecuteFlag) {
7936       CALL_ProgramUniform2f(ctx->Exec, (program, location, x, y));
7937    }
7938 }
7939 
7940 static void GLAPIENTRY
save_ProgramUniform3f(GLuint program,GLint location,GLfloat x,GLfloat y,GLfloat z)7941 save_ProgramUniform3f(GLuint program, GLint location,
7942                       GLfloat x, GLfloat y, GLfloat z)
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_3F, 5);
7948    if (n) {
7949       n[1].ui = program;
7950       n[2].i = location;
7951       n[3].f = x;
7952       n[4].f = y;
7953       n[5].f = z;
7954    }
7955    if (ctx->ExecuteFlag) {
7956       CALL_ProgramUniform3f(ctx->Exec, (program, location, x, y, z));
7957    }
7958 }
7959 
7960 static void GLAPIENTRY
save_ProgramUniform4f(GLuint program,GLint location,GLfloat x,GLfloat y,GLfloat z,GLfloat w)7961 save_ProgramUniform4f(GLuint program, GLint location,
7962                       GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7963 {
7964    GET_CURRENT_CONTEXT(ctx);
7965    Node *n;
7966    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7967    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4F, 6);
7968    if (n) {
7969       n[1].ui = program;
7970       n[2].i = location;
7971       n[3].f = x;
7972       n[4].f = y;
7973       n[5].f = z;
7974       n[6].f = w;
7975    }
7976    if (ctx->ExecuteFlag) {
7977       CALL_ProgramUniform4f(ctx->Exec, (program, location, x, y, z, w));
7978    }
7979 }
7980 
7981 static void GLAPIENTRY
save_ProgramUniform1fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)7982 save_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
7983                        const GLfloat *v)
7984 {
7985    GET_CURRENT_CONTEXT(ctx);
7986    Node *n;
7987    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
7988    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1FV, 3 + POINTER_DWORDS);
7989    if (n) {
7990       n[1].ui = program;
7991       n[2].i = location;
7992       n[3].i = count;
7993       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLfloat)));
7994    }
7995    if (ctx->ExecuteFlag) {
7996       CALL_ProgramUniform1fv(ctx->Exec, (program, location, count, v));
7997    }
7998 }
7999 
8000 static void GLAPIENTRY
save_ProgramUniform2fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8001 save_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
8002                        const GLfloat *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_2FV, 3 + POINTER_DWORDS);
8008    if (n) {
8009       n[1].ui = program;
8010       n[2].i = location;
8011       n[3].i = count;
8012       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLfloat)));
8013    }
8014    if (ctx->ExecuteFlag) {
8015       CALL_ProgramUniform2fv(ctx->Exec, (program, location, count, v));
8016    }
8017 }
8018 
8019 static void GLAPIENTRY
save_ProgramUniform3fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8020 save_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
8021                        const GLfloat *v)
8022 {
8023    GET_CURRENT_CONTEXT(ctx);
8024    Node *n;
8025    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8026    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3FV, 3 + POINTER_DWORDS);
8027    if (n) {
8028       n[1].ui = program;
8029       n[2].i = location;
8030       n[3].i = count;
8031       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLfloat)));
8032    }
8033    if (ctx->ExecuteFlag) {
8034       CALL_ProgramUniform3fv(ctx->Exec, (program, location, count, v));
8035    }
8036 }
8037 
8038 static void GLAPIENTRY
save_ProgramUniform4fv(GLuint program,GLint location,GLsizei count,const GLfloat * v)8039 save_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
8040                        const GLfloat *v)
8041 {
8042    GET_CURRENT_CONTEXT(ctx);
8043    Node *n;
8044    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8045    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4FV, 3 + POINTER_DWORDS);
8046    if (n) {
8047       n[1].ui = program;
8048       n[2].i = location;
8049       n[3].i = count;
8050       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLfloat)));
8051    }
8052    if (ctx->ExecuteFlag) {
8053       CALL_ProgramUniform4fv(ctx->Exec, (program, location, count, v));
8054    }
8055 }
8056 
8057 static void GLAPIENTRY
save_ProgramUniform1d(GLuint program,GLint location,GLdouble x)8058 save_ProgramUniform1d(GLuint program, GLint location, GLdouble x)
8059 {
8060    GET_CURRENT_CONTEXT(ctx);
8061    Node *n;
8062    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8063    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1D, 4);
8064    if (n) {
8065       n[1].ui = program;
8066       n[2].i = location;
8067       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8068    }
8069    if (ctx->ExecuteFlag) {
8070       CALL_ProgramUniform1d(ctx->Exec, (program, location, x));
8071    }
8072 }
8073 
8074 static void GLAPIENTRY
save_ProgramUniform2d(GLuint program,GLint location,GLdouble x,GLdouble y)8075 save_ProgramUniform2d(GLuint program, GLint location, GLdouble x, GLdouble y)
8076 {
8077    GET_CURRENT_CONTEXT(ctx);
8078    Node *n;
8079    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8080    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2D, 6);
8081    if (n) {
8082       n[1].ui = program;
8083       n[2].i = location;
8084       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8085       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8086    }
8087    if (ctx->ExecuteFlag) {
8088       CALL_ProgramUniform2d(ctx->Exec, (program, location, x, y));
8089    }
8090 }
8091 
8092 static void GLAPIENTRY
save_ProgramUniform3d(GLuint program,GLint location,GLdouble x,GLdouble y,GLdouble z)8093 save_ProgramUniform3d(GLuint program, GLint location,
8094                       GLdouble x, GLdouble y, GLdouble z)
8095 {
8096    GET_CURRENT_CONTEXT(ctx);
8097    Node *n;
8098    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8099    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3D, 8);
8100    if (n) {
8101       n[1].ui = program;
8102       n[2].i = location;
8103       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8104       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8105       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
8106    }
8107    if (ctx->ExecuteFlag) {
8108       CALL_ProgramUniform3d(ctx->Exec, (program, location, x, y, z));
8109    }
8110 }
8111 
8112 static void GLAPIENTRY
save_ProgramUniform4d(GLuint program,GLint location,GLdouble x,GLdouble y,GLdouble z,GLdouble w)8113 save_ProgramUniform4d(GLuint program, GLint location,
8114                       GLdouble x, GLdouble y, GLdouble z, GLdouble w)
8115 {
8116    GET_CURRENT_CONTEXT(ctx);
8117    Node *n;
8118    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8119    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4D, 10);
8120    if (n) {
8121       n[1].ui = program;
8122       n[2].i = location;
8123       ASSIGN_DOUBLE_TO_NODES(n, 3, x);
8124       ASSIGN_DOUBLE_TO_NODES(n, 5, y);
8125       ASSIGN_DOUBLE_TO_NODES(n, 7, z);
8126       ASSIGN_DOUBLE_TO_NODES(n, 9, w);
8127    }
8128    if (ctx->ExecuteFlag) {
8129       CALL_ProgramUniform4d(ctx->Exec, (program, location, x, y, z, w));
8130    }
8131 }
8132 
8133 static void GLAPIENTRY
save_ProgramUniform1dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8134 save_ProgramUniform1dv(GLuint program, GLint location, GLsizei count,
8135                        const GLdouble *v)
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_1DV, 3 + POINTER_DWORDS);
8141    if (n) {
8142       n[1].ui = program;
8143       n[2].i = location;
8144       n[3].i = count;
8145       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLdouble)));
8146    }
8147    if (ctx->ExecuteFlag) {
8148       CALL_ProgramUniform1dv(ctx->Exec, (program, location, count, v));
8149    }
8150 }
8151 
8152 static void GLAPIENTRY
save_ProgramUniform2dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8153 save_ProgramUniform2dv(GLuint program, GLint location, GLsizei count,
8154                        const GLdouble *v)
8155 {
8156    GET_CURRENT_CONTEXT(ctx);
8157    Node *n;
8158    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8159    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2DV, 3 + POINTER_DWORDS);
8160    if (n) {
8161       n[1].ui = program;
8162       n[2].i = location;
8163       n[3].i = count;
8164       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLdouble)));
8165    }
8166    if (ctx->ExecuteFlag) {
8167       CALL_ProgramUniform2dv(ctx->Exec, (program, location, count, v));
8168    }
8169 }
8170 
8171 static void GLAPIENTRY
save_ProgramUniform3dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8172 save_ProgramUniform3dv(GLuint program, GLint location, GLsizei count,
8173                        const GLdouble *v)
8174 {
8175    GET_CURRENT_CONTEXT(ctx);
8176    Node *n;
8177    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8178    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3DV, 3 + POINTER_DWORDS);
8179    if (n) {
8180       n[1].ui = program;
8181       n[2].i = location;
8182       n[3].i = count;
8183       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLdouble)));
8184    }
8185    if (ctx->ExecuteFlag) {
8186       CALL_ProgramUniform3dv(ctx->Exec, (program, location, count, v));
8187    }
8188 }
8189 
8190 static void GLAPIENTRY
save_ProgramUniform4dv(GLuint program,GLint location,GLsizei count,const GLdouble * v)8191 save_ProgramUniform4dv(GLuint program, GLint location, GLsizei count,
8192                        const GLdouble *v)
8193 {
8194    GET_CURRENT_CONTEXT(ctx);
8195    Node *n;
8196    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8197    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4DV, 3 + POINTER_DWORDS);
8198    if (n) {
8199       n[1].ui = program;
8200       n[2].i = location;
8201       n[3].i = count;
8202       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLdouble)));
8203    }
8204    if (ctx->ExecuteFlag) {
8205       CALL_ProgramUniform4dv(ctx->Exec, (program, location, count, v));
8206    }
8207 }
8208 
8209 static void GLAPIENTRY
save_ProgramUniform1i(GLuint program,GLint location,GLint x)8210 save_ProgramUniform1i(GLuint program, GLint location, GLint x)
8211 {
8212    GET_CURRENT_CONTEXT(ctx);
8213    Node *n;
8214    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8215    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I, 3);
8216    if (n) {
8217       n[1].ui = program;
8218       n[2].i = location;
8219       n[3].i = x;
8220    }
8221    if (ctx->ExecuteFlag) {
8222       CALL_ProgramUniform1i(ctx->Exec, (program, location, x));
8223    }
8224 }
8225 
8226 static void GLAPIENTRY
save_ProgramUniform2i(GLuint program,GLint location,GLint x,GLint y)8227 save_ProgramUniform2i(GLuint program, GLint location, GLint x, GLint y)
8228 {
8229    GET_CURRENT_CONTEXT(ctx);
8230    Node *n;
8231    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8232    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I, 4);
8233    if (n) {
8234       n[1].ui = program;
8235       n[2].i = location;
8236       n[3].i = x;
8237       n[4].i = y;
8238    }
8239    if (ctx->ExecuteFlag) {
8240       CALL_ProgramUniform2i(ctx->Exec, (program, location, x, y));
8241    }
8242 }
8243 
8244 static void GLAPIENTRY
save_ProgramUniform3i(GLuint program,GLint location,GLint x,GLint y,GLint z)8245 save_ProgramUniform3i(GLuint program, GLint location,
8246                       GLint x, GLint y, GLint z)
8247 {
8248    GET_CURRENT_CONTEXT(ctx);
8249    Node *n;
8250    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8251    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I, 5);
8252    if (n) {
8253       n[1].ui = program;
8254       n[2].i = location;
8255       n[3].i = x;
8256       n[4].i = y;
8257       n[5].i = z;
8258    }
8259    if (ctx->ExecuteFlag) {
8260       CALL_ProgramUniform3i(ctx->Exec, (program, location, x, y, z));
8261    }
8262 }
8263 
8264 static void GLAPIENTRY
save_ProgramUniform4i(GLuint program,GLint location,GLint x,GLint y,GLint z,GLint w)8265 save_ProgramUniform4i(GLuint program, GLint location,
8266                       GLint x, GLint y, GLint z, GLint w)
8267 {
8268    GET_CURRENT_CONTEXT(ctx);
8269    Node *n;
8270    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8271    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4I, 6);
8272    if (n) {
8273       n[1].ui = program;
8274       n[2].i = location;
8275       n[3].i = x;
8276       n[4].i = y;
8277       n[5].i = z;
8278       n[6].i = w;
8279    }
8280    if (ctx->ExecuteFlag) {
8281       CALL_ProgramUniform4i(ctx->Exec, (program, location, x, y, z, w));
8282    }
8283 }
8284 
8285 static void GLAPIENTRY
save_ProgramUniform1iv(GLuint program,GLint location,GLsizei count,const GLint * v)8286 save_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
8287                        const GLint *v)
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_1IV, 3 + POINTER_DWORDS);
8293    if (n) {
8294       n[1].ui = program;
8295       n[2].i = location;
8296       n[3].i = count;
8297       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint)));
8298    }
8299    if (ctx->ExecuteFlag) {
8300       CALL_ProgramUniform1iv(ctx->Exec, (program, location, count, v));
8301    }
8302 }
8303 
8304 static void GLAPIENTRY
save_ProgramUniform2iv(GLuint program,GLint location,GLsizei count,const GLint * v)8305 save_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
8306                        const GLint *v)
8307 {
8308    GET_CURRENT_CONTEXT(ctx);
8309    Node *n;
8310    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8311    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2IV, 3 + POINTER_DWORDS);
8312    if (n) {
8313       n[1].ui = program;
8314       n[2].i = location;
8315       n[3].i = count;
8316       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLint)));
8317    }
8318    if (ctx->ExecuteFlag) {
8319       CALL_ProgramUniform2iv(ctx->Exec, (program, location, count, v));
8320    }
8321 }
8322 
8323 static void GLAPIENTRY
save_ProgramUniform3iv(GLuint program,GLint location,GLsizei count,const GLint * v)8324 save_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
8325                        const GLint *v)
8326 {
8327    GET_CURRENT_CONTEXT(ctx);
8328    Node *n;
8329    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8330    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3IV, 3 + POINTER_DWORDS);
8331    if (n) {
8332       n[1].ui = program;
8333       n[2].i = location;
8334       n[3].i = count;
8335       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLint)));
8336    }
8337    if (ctx->ExecuteFlag) {
8338       CALL_ProgramUniform3iv(ctx->Exec, (program, location, count, v));
8339    }
8340 }
8341 
8342 static void GLAPIENTRY
save_ProgramUniform4iv(GLuint program,GLint location,GLsizei count,const GLint * v)8343 save_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
8344                        const GLint *v)
8345 {
8346    GET_CURRENT_CONTEXT(ctx);
8347    Node *n;
8348    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8349    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4IV, 3 + POINTER_DWORDS);
8350    if (n) {
8351       n[1].ui = program;
8352       n[2].i = location;
8353       n[3].i = count;
8354       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLint)));
8355    }
8356    if (ctx->ExecuteFlag) {
8357       CALL_ProgramUniform4iv(ctx->Exec, (program, location, count, v));
8358    }
8359 }
8360 
8361 static void GLAPIENTRY
save_ProgramUniform1ui(GLuint program,GLint location,GLuint x)8362 save_ProgramUniform1ui(GLuint program, GLint location, GLuint x)
8363 {
8364    GET_CURRENT_CONTEXT(ctx);
8365    Node *n;
8366    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8367    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI, 3);
8368    if (n) {
8369       n[1].ui = program;
8370       n[2].i = location;
8371       n[3].ui = x;
8372    }
8373    if (ctx->ExecuteFlag) {
8374       CALL_ProgramUniform1ui(ctx->Exec, (program, location, x));
8375    }
8376 }
8377 
8378 static void GLAPIENTRY
save_ProgramUniform2ui(GLuint program,GLint location,GLuint x,GLuint y)8379 save_ProgramUniform2ui(GLuint program, GLint location, GLuint x, GLuint y)
8380 {
8381    GET_CURRENT_CONTEXT(ctx);
8382    Node *n;
8383    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8384    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI, 4);
8385    if (n) {
8386       n[1].ui = program;
8387       n[2].i = location;
8388       n[3].ui = x;
8389       n[4].ui = y;
8390    }
8391    if (ctx->ExecuteFlag) {
8392       CALL_ProgramUniform2ui(ctx->Exec, (program, location, x, y));
8393    }
8394 }
8395 
8396 static void GLAPIENTRY
save_ProgramUniform3ui(GLuint program,GLint location,GLuint x,GLuint y,GLuint z)8397 save_ProgramUniform3ui(GLuint program, GLint location,
8398                        GLuint x, GLuint y, GLuint z)
8399 {
8400    GET_CURRENT_CONTEXT(ctx);
8401    Node *n;
8402    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8403    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UI, 5);
8404    if (n) {
8405       n[1].ui = program;
8406       n[2].i = location;
8407       n[3].ui = x;
8408       n[4].ui = y;
8409       n[5].ui = z;
8410    }
8411    if (ctx->ExecuteFlag) {
8412       CALL_ProgramUniform3ui(ctx->Exec, (program, location, x, y, z));
8413    }
8414 }
8415 
8416 static void GLAPIENTRY
save_ProgramUniform4ui(GLuint program,GLint location,GLuint x,GLuint y,GLuint z,GLuint w)8417 save_ProgramUniform4ui(GLuint program, GLint location,
8418                        GLuint x, GLuint y, GLuint z, GLuint w)
8419 {
8420    GET_CURRENT_CONTEXT(ctx);
8421    Node *n;
8422    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8423    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UI, 6);
8424    if (n) {
8425       n[1].ui = program;
8426       n[2].i = location;
8427       n[3].ui = x;
8428       n[4].ui = y;
8429       n[5].ui = z;
8430       n[6].ui = w;
8431    }
8432    if (ctx->ExecuteFlag) {
8433       CALL_ProgramUniform4ui(ctx->Exec, (program, location, x, y, z, w));
8434    }
8435 }
8436 
8437 static void GLAPIENTRY
save_ProgramUniform1uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8438 save_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
8439                         const GLuint *v)
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_1UIV, 3 + POINTER_DWORDS);
8445    if (n) {
8446       n[1].ui = program;
8447       n[2].i = location;
8448       n[3].i = count;
8449       save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint)));
8450    }
8451    if (ctx->ExecuteFlag) {
8452       CALL_ProgramUniform1uiv(ctx->Exec, (program, location, count, v));
8453    }
8454 }
8455 
8456 static void GLAPIENTRY
save_ProgramUniform2uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8457 save_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
8458                         const GLuint *v)
8459 {
8460    GET_CURRENT_CONTEXT(ctx);
8461    Node *n;
8462    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8463    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UIV, 3 + POINTER_DWORDS);
8464    if (n) {
8465       n[1].ui = program;
8466       n[2].i = location;
8467       n[3].i = count;
8468       save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLuint)));
8469    }
8470    if (ctx->ExecuteFlag) {
8471       CALL_ProgramUniform2uiv(ctx->Exec, (program, location, count, v));
8472    }
8473 }
8474 
8475 static void GLAPIENTRY
save_ProgramUniform3uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8476 save_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
8477                         const GLuint *v)
8478 {
8479    GET_CURRENT_CONTEXT(ctx);
8480    Node *n;
8481    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8482    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3UIV, 3 + POINTER_DWORDS);
8483    if (n) {
8484       n[1].ui = program;
8485       n[2].i = location;
8486       n[3].i = count;
8487       save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLuint)));
8488    }
8489    if (ctx->ExecuteFlag) {
8490       CALL_ProgramUniform3uiv(ctx->Exec, (program, location, count, v));
8491    }
8492 }
8493 
8494 static void GLAPIENTRY
save_ProgramUniform4uiv(GLuint program,GLint location,GLsizei count,const GLuint * v)8495 save_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
8496                         const GLuint *v)
8497 {
8498    GET_CURRENT_CONTEXT(ctx);
8499    Node *n;
8500    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8501    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4UIV, 3 + POINTER_DWORDS);
8502    if (n) {
8503       n[1].ui = program;
8504       n[2].i = location;
8505       n[3].i = count;
8506       save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLuint)));
8507    }
8508    if (ctx->ExecuteFlag) {
8509       CALL_ProgramUniform4uiv(ctx->Exec, (program, location, count, v));
8510    }
8511 }
8512 
8513 static void GLAPIENTRY
save_ProgramUniformMatrix2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8514 save_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count,
8515                              GLboolean transpose, const GLfloat *v)
8516 {
8517    GET_CURRENT_CONTEXT(ctx);
8518    Node *n;
8519    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8520    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22F,
8521                          4 + POINTER_DWORDS);
8522    if (n) {
8523       n[1].ui = program;
8524       n[2].i = location;
8525       n[3].i = count;
8526       n[4].b = transpose;
8527       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLfloat)));
8528    }
8529    if (ctx->ExecuteFlag) {
8530       CALL_ProgramUniformMatrix2fv(ctx->Exec,
8531                                    (program, location, count, transpose, v));
8532    }
8533 }
8534 
8535 static void GLAPIENTRY
save_ProgramUniformMatrix2x3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8536 save_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count,
8537                                GLboolean transpose, const GLfloat *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_MATRIX23F,
8543                          4 + POINTER_DWORDS);
8544    if (n) {
8545       n[1].ui = program;
8546       n[2].i = location;
8547       n[3].i = count;
8548       n[4].b = transpose;
8549       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLfloat)));
8550    }
8551    if (ctx->ExecuteFlag) {
8552       CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
8553                                      (program, location, count, transpose, v));
8554    }
8555 }
8556 
8557 static void GLAPIENTRY
save_ProgramUniformMatrix2x4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8558 save_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count,
8559                                GLboolean transpose, const GLfloat *v)
8560 {
8561    GET_CURRENT_CONTEXT(ctx);
8562    Node *n;
8563    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8564    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24F,
8565                          4 + POINTER_DWORDS);
8566    if (n) {
8567       n[1].ui = program;
8568       n[2].i = location;
8569       n[3].i = count;
8570       n[4].b = transpose;
8571       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLfloat)));
8572    }
8573    if (ctx->ExecuteFlag) {
8574       CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
8575                                      (program, location, count, transpose, v));
8576    }
8577 }
8578 
8579 static void GLAPIENTRY
save_ProgramUniformMatrix3x2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8580 save_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count,
8581                                GLboolean transpose, const GLfloat *v)
8582 {
8583    GET_CURRENT_CONTEXT(ctx);
8584    Node *n;
8585    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8586    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32F,
8587                          4 + POINTER_DWORDS);
8588    if (n) {
8589       n[1].ui = program;
8590       n[2].i = location;
8591       n[3].i = count;
8592       n[4].b = transpose;
8593       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLfloat)));
8594    }
8595    if (ctx->ExecuteFlag) {
8596       CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
8597                                      (program, location, count, transpose, v));
8598    }
8599 }
8600 
8601 static void GLAPIENTRY
save_ProgramUniformMatrix3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8602 save_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count,
8603                              GLboolean transpose, const GLfloat *v)
8604 {
8605    GET_CURRENT_CONTEXT(ctx);
8606    Node *n;
8607    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8608    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33F,
8609                          4 + POINTER_DWORDS);
8610    if (n) {
8611       n[1].ui = program;
8612       n[2].i = location;
8613       n[3].i = count;
8614       n[4].b = transpose;
8615       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLfloat)));
8616    }
8617    if (ctx->ExecuteFlag) {
8618       CALL_ProgramUniformMatrix3fv(ctx->Exec,
8619                                    (program, location, count, transpose, v));
8620    }
8621 }
8622 
8623 static void GLAPIENTRY
save_ProgramUniformMatrix3x4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8624 save_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count,
8625                                GLboolean transpose, const GLfloat *v)
8626 {
8627    GET_CURRENT_CONTEXT(ctx);
8628    Node *n;
8629    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8630    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34F,
8631                          4 + POINTER_DWORDS);
8632    if (n) {
8633       n[1].ui = program;
8634       n[2].i = location;
8635       n[3].i = count;
8636       n[4].b = transpose;
8637       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLfloat)));
8638    }
8639    if (ctx->ExecuteFlag) {
8640       CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
8641                                      (program, location, count, transpose, v));
8642    }
8643 }
8644 
8645 static void GLAPIENTRY
save_ProgramUniformMatrix4x2fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8646 save_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count,
8647                                GLboolean transpose, const GLfloat *v)
8648 {
8649    GET_CURRENT_CONTEXT(ctx);
8650    Node *n;
8651    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8652    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42F,
8653                          4 + POINTER_DWORDS);
8654    if (n) {
8655       n[1].ui = program;
8656       n[2].i = location;
8657       n[3].i = count;
8658       n[4].b = transpose;
8659       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLfloat)));
8660    }
8661    if (ctx->ExecuteFlag) {
8662       CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
8663                                      (program, location, count, transpose, v));
8664    }
8665 }
8666 
8667 static void GLAPIENTRY
save_ProgramUniformMatrix4x3fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8668 save_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count,
8669                                GLboolean transpose, const GLfloat *v)
8670 {
8671    GET_CURRENT_CONTEXT(ctx);
8672    Node *n;
8673    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8674    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43F,
8675                          4 + POINTER_DWORDS);
8676    if (n) {
8677       n[1].ui = program;
8678       n[2].i = location;
8679       n[3].i = count;
8680       n[4].b = transpose;
8681       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLfloat)));
8682    }
8683    if (ctx->ExecuteFlag) {
8684       CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
8685                                      (program, location, count, transpose, v));
8686    }
8687 }
8688 
8689 static void GLAPIENTRY
save_ProgramUniformMatrix4fv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLfloat * v)8690 save_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count,
8691                              GLboolean transpose, const GLfloat *v)
8692 {
8693    GET_CURRENT_CONTEXT(ctx);
8694    Node *n;
8695    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8696    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44F,
8697                          4 + POINTER_DWORDS);
8698    if (n) {
8699       n[1].ui = program;
8700       n[2].i = location;
8701       n[3].i = count;
8702       n[4].b = transpose;
8703       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLfloat)));
8704    }
8705    if (ctx->ExecuteFlag) {
8706       CALL_ProgramUniformMatrix4fv(ctx->Exec,
8707                                    (program, location, count, transpose, v));
8708    }
8709 }
8710 
8711 static void GLAPIENTRY
save_ProgramUniformMatrix2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8712 save_ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count,
8713                              GLboolean transpose, const GLdouble *v)
8714 {
8715    GET_CURRENT_CONTEXT(ctx);
8716    Node *n;
8717    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8718    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22D,
8719                          4 + POINTER_DWORDS);
8720    if (n) {
8721       n[1].ui = program;
8722       n[2].i = location;
8723       n[3].i = count;
8724       n[4].b = transpose;
8725       save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLdouble)));
8726    }
8727    if (ctx->ExecuteFlag) {
8728       CALL_ProgramUniformMatrix2dv(ctx->Exec,
8729                                    (program, location, count, transpose, v));
8730    }
8731 }
8732 
8733 static void GLAPIENTRY
save_ProgramUniformMatrix2x3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8734 save_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count,
8735                                GLboolean transpose, const GLdouble *v)
8736 {
8737    GET_CURRENT_CONTEXT(ctx);
8738    Node *n;
8739    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8740    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23D,
8741                          4 + POINTER_DWORDS);
8742    if (n) {
8743       n[1].ui = program;
8744       n[2].i = location;
8745       n[3].i = count;
8746       n[4].b = transpose;
8747       save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLdouble)));
8748    }
8749    if (ctx->ExecuteFlag) {
8750       CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
8751                                      (program, location, count, transpose, v));
8752    }
8753 }
8754 
8755 static void GLAPIENTRY
save_ProgramUniformMatrix2x4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8756 save_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count,
8757                                GLboolean transpose, const GLdouble *v)
8758 {
8759    GET_CURRENT_CONTEXT(ctx);
8760    Node *n;
8761    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8762    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24D,
8763                          4 + POINTER_DWORDS);
8764    if (n) {
8765       n[1].ui = program;
8766       n[2].i = location;
8767       n[3].i = count;
8768       n[4].b = transpose;
8769       save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLdouble)));
8770    }
8771    if (ctx->ExecuteFlag) {
8772       CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
8773                                      (program, location, count, transpose, v));
8774    }
8775 }
8776 
8777 static void GLAPIENTRY
save_ProgramUniformMatrix3x2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8778 save_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count,
8779                                GLboolean transpose, const GLdouble *v)
8780 {
8781    GET_CURRENT_CONTEXT(ctx);
8782    Node *n;
8783    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8784    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32D,
8785                          4 + POINTER_DWORDS);
8786    if (n) {
8787       n[1].ui = program;
8788       n[2].i = location;
8789       n[3].i = count;
8790       n[4].b = transpose;
8791       save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLdouble)));
8792    }
8793    if (ctx->ExecuteFlag) {
8794       CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
8795                                      (program, location, count, transpose, v));
8796    }
8797 }
8798 
8799 static void GLAPIENTRY
save_ProgramUniformMatrix3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8800 save_ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count,
8801                              GLboolean transpose, const GLdouble *v)
8802 {
8803    GET_CURRENT_CONTEXT(ctx);
8804    Node *n;
8805    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8806    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33D,
8807                          4 + POINTER_DWORDS);
8808    if (n) {
8809       n[1].ui = program;
8810       n[2].i = location;
8811       n[3].i = count;
8812       n[4].b = transpose;
8813       save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLdouble)));
8814    }
8815    if (ctx->ExecuteFlag) {
8816       CALL_ProgramUniformMatrix3dv(ctx->Exec,
8817                                    (program, location, count, transpose, v));
8818    }
8819 }
8820 
8821 static void GLAPIENTRY
save_ProgramUniformMatrix3x4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8822 save_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count,
8823                                GLboolean transpose, const GLdouble *v)
8824 {
8825    GET_CURRENT_CONTEXT(ctx);
8826    Node *n;
8827    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8828    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34D,
8829                          4 + POINTER_DWORDS);
8830    if (n) {
8831       n[1].ui = program;
8832       n[2].i = location;
8833       n[3].i = count;
8834       n[4].b = transpose;
8835       save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLdouble)));
8836    }
8837    if (ctx->ExecuteFlag) {
8838       CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
8839                                      (program, location, count, transpose, v));
8840    }
8841 }
8842 
8843 static void GLAPIENTRY
save_ProgramUniformMatrix4x2dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8844 save_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count,
8845                                GLboolean transpose, const GLdouble *v)
8846 {
8847    GET_CURRENT_CONTEXT(ctx);
8848    Node *n;
8849    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8850    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42D,
8851                          4 + POINTER_DWORDS);
8852    if (n) {
8853       n[1].ui = program;
8854       n[2].i = location;
8855       n[3].i = count;
8856       n[4].b = transpose;
8857       save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLdouble)));
8858    }
8859    if (ctx->ExecuteFlag) {
8860       CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
8861                                      (program, location, count, transpose, v));
8862    }
8863 }
8864 
8865 static void GLAPIENTRY
save_ProgramUniformMatrix4x3dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8866 save_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
8867                                GLboolean transpose, const GLdouble *v)
8868 {
8869    GET_CURRENT_CONTEXT(ctx);
8870    Node *n;
8871    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8872    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43D,
8873                          4 + POINTER_DWORDS);
8874    if (n) {
8875       n[1].ui = program;
8876       n[2].i = location;
8877       n[3].i = count;
8878       n[4].b = transpose;
8879       save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLdouble)));
8880    }
8881    if (ctx->ExecuteFlag) {
8882       CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
8883                                      (program, location, count, transpose, v));
8884    }
8885 }
8886 
8887 static void GLAPIENTRY
save_ProgramUniformMatrix4dv(GLuint program,GLint location,GLsizei count,GLboolean transpose,const GLdouble * v)8888 save_ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count,
8889                              GLboolean transpose, const GLdouble *v)
8890 {
8891    GET_CURRENT_CONTEXT(ctx);
8892    Node *n;
8893    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8894    n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44D,
8895                          4 + POINTER_DWORDS);
8896    if (n) {
8897       n[1].ui = program;
8898       n[2].i = location;
8899       n[3].i = count;
8900       n[4].b = transpose;
8901       save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLdouble)));
8902    }
8903    if (ctx->ExecuteFlag) {
8904       CALL_ProgramUniformMatrix4dv(ctx->Exec,
8905                                    (program, location, count, transpose, v));
8906    }
8907 }
8908 
8909 static void GLAPIENTRY
save_ClipControl(GLenum origin,GLenum depth)8910 save_ClipControl(GLenum origin, GLenum depth)
8911 {
8912    GET_CURRENT_CONTEXT(ctx);
8913    Node *n;
8914    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8915    n = alloc_instruction(ctx, OPCODE_CLIP_CONTROL, 2);
8916    if (n) {
8917       n[1].e = origin;
8918       n[2].e = depth;
8919    }
8920    if (ctx->ExecuteFlag) {
8921       CALL_ClipControl(ctx->Exec, (origin, depth));
8922    }
8923 }
8924 
8925 static void GLAPIENTRY
save_ClampColorARB(GLenum target,GLenum clamp)8926 save_ClampColorARB(GLenum target, GLenum clamp)
8927 {
8928    GET_CURRENT_CONTEXT(ctx);
8929    Node *n;
8930    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8931    n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2);
8932    if (n) {
8933       n[1].e = target;
8934       n[2].e = clamp;
8935    }
8936    if (ctx->ExecuteFlag) {
8937       CALL_ClampColor(ctx->Exec, (target, clamp));
8938    }
8939 }
8940 
8941 /** GL_EXT_texture_integer */
8942 static void GLAPIENTRY
save_ClearColorIi(GLint red,GLint green,GLint blue,GLint alpha)8943 save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha)
8944 {
8945    GET_CURRENT_CONTEXT(ctx);
8946    Node *n;
8947    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8948    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4);
8949    if (n) {
8950       n[1].i = red;
8951       n[2].i = green;
8952       n[3].i = blue;
8953       n[4].i = alpha;
8954    }
8955    if (ctx->ExecuteFlag) {
8956       CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha));
8957    }
8958 }
8959 
8960 /** GL_EXT_texture_integer */
8961 static void GLAPIENTRY
save_ClearColorIui(GLuint red,GLuint green,GLuint blue,GLuint alpha)8962 save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
8963 {
8964    GET_CURRENT_CONTEXT(ctx);
8965    Node *n;
8966    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8967    n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4);
8968    if (n) {
8969       n[1].ui = red;
8970       n[2].ui = green;
8971       n[3].ui = blue;
8972       n[4].ui = alpha;
8973    }
8974    if (ctx->ExecuteFlag) {
8975       CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha));
8976    }
8977 }
8978 
8979 /** GL_EXT_texture_integer */
8980 static void GLAPIENTRY
save_TexParameterIiv(GLenum target,GLenum pname,const GLint * params)8981 save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
8982 {
8983    GET_CURRENT_CONTEXT(ctx);
8984    Node *n;
8985    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
8986    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6);
8987    if (n) {
8988       n[1].e = target;
8989       n[2].e = pname;
8990       n[3].i = params[0];
8991       n[4].i = params[1];
8992       n[5].i = params[2];
8993       n[6].i = params[3];
8994    }
8995    if (ctx->ExecuteFlag) {
8996       CALL_TexParameterIiv(ctx->Exec, (target, pname, params));
8997    }
8998 }
8999 
9000 /** GL_EXT_texture_integer */
9001 static void GLAPIENTRY
save_TexParameterIuiv(GLenum target,GLenum pname,const GLuint * params)9002 save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
9003 {
9004    GET_CURRENT_CONTEXT(ctx);
9005    Node *n;
9006    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9007    n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6);
9008    if (n) {
9009       n[1].e = target;
9010       n[2].e = pname;
9011       n[3].ui = params[0];
9012       n[4].ui = params[1];
9013       n[5].ui = params[2];
9014       n[6].ui = params[3];
9015    }
9016    if (ctx->ExecuteFlag) {
9017       CALL_TexParameterIuiv(ctx->Exec, (target, pname, params));
9018    }
9019 }
9020 
9021 /* GL_ARB_instanced_arrays */
9022 static void GLAPIENTRY
save_VertexAttribDivisor(GLuint index,GLuint divisor)9023 save_VertexAttribDivisor(GLuint index, GLuint divisor)
9024 {
9025    GET_CURRENT_CONTEXT(ctx);
9026    Node *n;
9027    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9028    n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2);
9029    if (n) {
9030       n[1].ui = index;
9031       n[2].ui = divisor;
9032    }
9033    if (ctx->ExecuteFlag) {
9034       CALL_VertexAttribDivisor(ctx->Exec, (index, divisor));
9035    }
9036 }
9037 
9038 
9039 /* GL_NV_texture_barrier */
9040 static void GLAPIENTRY
save_TextureBarrierNV(void)9041 save_TextureBarrierNV(void)
9042 {
9043    GET_CURRENT_CONTEXT(ctx);
9044    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9045    alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0);
9046    if (ctx->ExecuteFlag) {
9047       CALL_TextureBarrierNV(ctx->Exec, ());
9048    }
9049 }
9050 
9051 
9052 /* GL_ARB_sampler_objects */
9053 static void GLAPIENTRY
save_BindSampler(GLuint unit,GLuint sampler)9054 save_BindSampler(GLuint unit, GLuint sampler)
9055 {
9056    Node *n;
9057    GET_CURRENT_CONTEXT(ctx);
9058    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9059    n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2);
9060    if (n) {
9061       n[1].ui = unit;
9062       n[2].ui = sampler;
9063    }
9064    if (ctx->ExecuteFlag) {
9065       CALL_BindSampler(ctx->Exec, (unit, sampler));
9066    }
9067 }
9068 
9069 static void GLAPIENTRY
save_SamplerParameteriv(GLuint sampler,GLenum pname,const GLint * params)9070 save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
9071 {
9072    Node *n;
9073    GET_CURRENT_CONTEXT(ctx);
9074    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9075    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6);
9076    if (n) {
9077       n[1].ui = sampler;
9078       n[2].e = pname;
9079       n[3].i = params[0];
9080       if (pname == GL_TEXTURE_BORDER_COLOR) {
9081          n[4].i = params[1];
9082          n[5].i = params[2];
9083          n[6].i = params[3];
9084       }
9085       else {
9086          n[4].i = n[5].i = n[6].i = 0;
9087       }
9088    }
9089    if (ctx->ExecuteFlag) {
9090       CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params));
9091    }
9092 }
9093 
9094 static void GLAPIENTRY
save_SamplerParameteri(GLuint sampler,GLenum pname,GLint param)9095 save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
9096 {
9097    GLint parray[4];
9098    parray[0] = param;
9099    parray[1] = parray[2] = parray[3] = 0;
9100    save_SamplerParameteriv(sampler, pname, parray);
9101 }
9102 
9103 static void GLAPIENTRY
save_SamplerParameterfv(GLuint sampler,GLenum pname,const GLfloat * params)9104 save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
9105 {
9106    Node *n;
9107    GET_CURRENT_CONTEXT(ctx);
9108    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9109    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6);
9110    if (n) {
9111       n[1].ui = sampler;
9112       n[2].e = pname;
9113       n[3].f = params[0];
9114       if (pname == GL_TEXTURE_BORDER_COLOR) {
9115          n[4].f = params[1];
9116          n[5].f = params[2];
9117          n[6].f = params[3];
9118       }
9119       else {
9120          n[4].f = n[5].f = n[6].f = 0.0F;
9121       }
9122    }
9123    if (ctx->ExecuteFlag) {
9124       CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params));
9125    }
9126 }
9127 
9128 static void GLAPIENTRY
save_SamplerParameterf(GLuint sampler,GLenum pname,GLfloat param)9129 save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
9130 {
9131    GLfloat parray[4];
9132    parray[0] = param;
9133    parray[1] = parray[2] = parray[3] = 0.0F;
9134    save_SamplerParameterfv(sampler, pname, parray);
9135 }
9136 
9137 static void GLAPIENTRY
save_SamplerParameterIiv(GLuint sampler,GLenum pname,const GLint * params)9138 save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
9139 {
9140    Node *n;
9141    GET_CURRENT_CONTEXT(ctx);
9142    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9143    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6);
9144    if (n) {
9145       n[1].ui = sampler;
9146       n[2].e = pname;
9147       n[3].i = params[0];
9148       if (pname == GL_TEXTURE_BORDER_COLOR) {
9149          n[4].i = params[1];
9150          n[5].i = params[2];
9151          n[6].i = params[3];
9152       }
9153       else {
9154          n[4].i = n[5].i = n[6].i = 0;
9155       }
9156    }
9157    if (ctx->ExecuteFlag) {
9158       CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params));
9159    }
9160 }
9161 
9162 static void GLAPIENTRY
save_SamplerParameterIuiv(GLuint sampler,GLenum pname,const GLuint * params)9163 save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
9164 {
9165    Node *n;
9166    GET_CURRENT_CONTEXT(ctx);
9167    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9168    n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6);
9169    if (n) {
9170       n[1].ui = sampler;
9171       n[2].e = pname;
9172       n[3].ui = params[0];
9173       if (pname == GL_TEXTURE_BORDER_COLOR) {
9174          n[4].ui = params[1];
9175          n[5].ui = params[2];
9176          n[6].ui = params[3];
9177       }
9178       else {
9179          n[4].ui = n[5].ui = n[6].ui = 0;
9180       }
9181    }
9182    if (ctx->ExecuteFlag) {
9183       CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params));
9184    }
9185 }
9186 
9187 static void GLAPIENTRY
save_WaitSync(GLsync sync,GLbitfield flags,GLuint64 timeout)9188 save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
9189 {
9190    Node *n;
9191    GET_CURRENT_CONTEXT(ctx);
9192    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9193    n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4);
9194    if (n) {
9195       union uint64_pair p;
9196       p.uint64 = timeout;
9197       n[1].bf = flags;
9198       n[2].ui = p.uint32[0];
9199       n[3].ui = p.uint32[1];
9200       save_pointer(&n[4], sync);
9201    }
9202    if (ctx->ExecuteFlag) {
9203       CALL_WaitSync(ctx->Exec, (sync, flags, timeout));
9204    }
9205 }
9206 
9207 
9208 /** GL_NV_conditional_render */
9209 static void GLAPIENTRY
save_BeginConditionalRender(GLuint queryId,GLenum mode)9210 save_BeginConditionalRender(GLuint queryId, GLenum mode)
9211 {
9212    GET_CURRENT_CONTEXT(ctx);
9213    Node *n;
9214    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9215    n = alloc_instruction(ctx, OPCODE_BEGIN_CONDITIONAL_RENDER, 2);
9216    if (n) {
9217       n[1].i = queryId;
9218       n[2].e = mode;
9219    }
9220    if (ctx->ExecuteFlag) {
9221       CALL_BeginConditionalRender(ctx->Exec, (queryId, mode));
9222    }
9223 }
9224 
9225 static void GLAPIENTRY
save_EndConditionalRender(void)9226 save_EndConditionalRender(void)
9227 {
9228    GET_CURRENT_CONTEXT(ctx);
9229    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9230    alloc_instruction(ctx, OPCODE_END_CONDITIONAL_RENDER, 0);
9231    if (ctx->ExecuteFlag) {
9232       CALL_EndConditionalRender(ctx->Exec, ());
9233    }
9234 }
9235 
9236 static void GLAPIENTRY
save_UniformBlockBinding(GLuint prog,GLuint index,GLuint binding)9237 save_UniformBlockBinding(GLuint prog, GLuint index, GLuint binding)
9238 {
9239    GET_CURRENT_CONTEXT(ctx);
9240    Node *n;
9241    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9242    n = alloc_instruction(ctx, OPCODE_UNIFORM_BLOCK_BINDING, 3);
9243    if (n) {
9244       n[1].ui = prog;
9245       n[2].ui = index;
9246       n[3].ui = binding;
9247    }
9248    if (ctx->ExecuteFlag) {
9249       CALL_UniformBlockBinding(ctx->Exec, (prog, index, binding));
9250    }
9251 }
9252 
9253 static void GLAPIENTRY
save_UniformSubroutinesuiv(GLenum shadertype,GLsizei count,const GLuint * indices)9254 save_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
9255                            const GLuint *indices)
9256 {
9257    GET_CURRENT_CONTEXT(ctx);
9258    Node *n;
9259    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9260    n = alloc_instruction(ctx, OPCODE_UNIFORM_SUBROUTINES, 2 + POINTER_DWORDS);
9261    if (n) {
9262       GLint *indices_copy = NULL;
9263 
9264       if (count > 0)
9265          indices_copy = memdup(indices, sizeof(GLuint) * 4 * count);
9266       n[1].e = shadertype;
9267       n[2].si = count;
9268       save_pointer(&n[3], indices_copy);
9269    }
9270    if (ctx->ExecuteFlag) {
9271       CALL_UniformSubroutinesuiv(ctx->Exec, (shadertype, count, indices));
9272    }
9273 }
9274 
9275 /** GL_EXT_window_rectangles */
9276 static void GLAPIENTRY
save_WindowRectanglesEXT(GLenum mode,GLsizei count,const GLint * box)9277 save_WindowRectanglesEXT(GLenum mode, GLsizei count, const GLint *box)
9278 {
9279    GET_CURRENT_CONTEXT(ctx);
9280    Node *n;
9281    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9282    n = alloc_instruction(ctx, OPCODE_WINDOW_RECTANGLES, 2 + POINTER_DWORDS);
9283    if (n) {
9284       GLint *box_copy = NULL;
9285 
9286       if (count > 0)
9287          box_copy = memdup(box, sizeof(GLint) * 4 * count);
9288       n[1].e = mode;
9289       n[2].si = count;
9290       save_pointer(&n[3], box_copy);
9291    }
9292    if (ctx->ExecuteFlag) {
9293       CALL_WindowRectanglesEXT(ctx->Exec, (mode, count, box));
9294    }
9295 }
9296 
9297 
9298 /** GL_NV_conservative_raster */
9299 static void GLAPIENTRY
save_SubpixelPrecisionBiasNV(GLuint xbits,GLuint ybits)9300 save_SubpixelPrecisionBiasNV(GLuint xbits, GLuint ybits)
9301 {
9302    GET_CURRENT_CONTEXT(ctx);
9303    Node *n;
9304    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9305    n = alloc_instruction(ctx, OPCODE_SUBPIXEL_PRECISION_BIAS, 2);
9306    if (n) {
9307       n[1].ui = xbits;
9308       n[2].ui = ybits;
9309    }
9310    if (ctx->ExecuteFlag) {
9311       CALL_SubpixelPrecisionBiasNV(ctx->Exec, (xbits, ybits));
9312    }
9313 }
9314 
9315 /** GL_NV_conservative_raster_dilate */
9316 static void GLAPIENTRY
save_ConservativeRasterParameterfNV(GLenum pname,GLfloat param)9317 save_ConservativeRasterParameterfNV(GLenum pname, GLfloat param)
9318 {
9319    GET_CURRENT_CONTEXT(ctx);
9320    Node *n;
9321    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9322    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_F, 2);
9323    if (n) {
9324       n[1].e = pname;
9325       n[2].f = param;
9326    }
9327    if (ctx->ExecuteFlag) {
9328       CALL_ConservativeRasterParameterfNV(ctx->Exec, (pname, param));
9329    }
9330 }
9331 
9332 /** GL_NV_conservative_raster_pre_snap_triangles */
9333 static void GLAPIENTRY
save_ConservativeRasterParameteriNV(GLenum pname,GLint param)9334 save_ConservativeRasterParameteriNV(GLenum pname, GLint param)
9335 {
9336    GET_CURRENT_CONTEXT(ctx);
9337    Node *n;
9338    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9339    n = alloc_instruction(ctx, OPCODE_CONSERVATIVE_RASTER_PARAMETER_I, 2);
9340    if (n) {
9341       n[1].e = pname;
9342       n[2].i = param;
9343    }
9344    if (ctx->ExecuteFlag) {
9345       CALL_ConservativeRasterParameteriNV(ctx->Exec, (pname, param));
9346    }
9347 }
9348 
9349 /** GL_EXT_direct_state_access */
9350 
9351 static void GLAPIENTRY
save_MatrixLoadfEXT(GLenum matrixMode,const GLfloat * m)9352 save_MatrixLoadfEXT(GLenum matrixMode, const GLfloat *m)
9353 {
9354    GET_CURRENT_CONTEXT(ctx);
9355    Node *n;
9356    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9357    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD, 17);
9358    if (n) {
9359       n[1].e = matrixMode;
9360       for (unsigned i = 0; i < 16; i++) {
9361          n[2 + i].f = m[i];
9362       }
9363    }
9364    if (ctx->ExecuteFlag) {
9365       CALL_MatrixLoadfEXT(ctx->Exec, (matrixMode, m));
9366    }
9367 }
9368 
9369 static void GLAPIENTRY
save_MatrixLoaddEXT(GLenum matrixMode,const GLdouble * m)9370 save_MatrixLoaddEXT(GLenum matrixMode, const GLdouble *m)
9371 {
9372    GLfloat f[16];
9373    for (unsigned i = 0; i < 16; i++) {
9374       f[i] = (GLfloat) m[i];
9375    }
9376    save_MatrixLoadfEXT(matrixMode, f);
9377 }
9378 
9379 static void GLAPIENTRY
save_MatrixMultfEXT(GLenum matrixMode,const GLfloat * m)9380 save_MatrixMultfEXT(GLenum matrixMode, const GLfloat * m)
9381 {
9382    GET_CURRENT_CONTEXT(ctx);
9383    Node *n;
9384    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9385    n = alloc_instruction(ctx, OPCODE_MATRIX_MULT, 17);
9386    if (n) {
9387       n[1].e = matrixMode;
9388       for (unsigned i = 0; i < 16; i++) {
9389          n[2 + i].f = m[i];
9390       }
9391    }
9392    if (ctx->ExecuteFlag) {
9393       CALL_MatrixMultfEXT(ctx->Exec, (matrixMode, m));
9394    }
9395 }
9396 
9397 static void GLAPIENTRY
save_MatrixMultdEXT(GLenum matrixMode,const GLdouble * m)9398 save_MatrixMultdEXT(GLenum matrixMode, const GLdouble * m)
9399 {
9400    GLfloat f[16];
9401    for (unsigned i = 0; i < 16; i++) {
9402       f[i] = (GLfloat) m[i];
9403    }
9404    save_MatrixMultfEXT(matrixMode, f);
9405 }
9406 
9407 static void GLAPIENTRY
save_MatrixRotatefEXT(GLenum matrixMode,GLfloat angle,GLfloat x,GLfloat y,GLfloat z)9408 save_MatrixRotatefEXT(GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
9409 {
9410    GET_CURRENT_CONTEXT(ctx);
9411    Node *n;
9412    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9413    n = alloc_instruction(ctx, OPCODE_MATRIX_ROTATE, 5);
9414    if (n) {
9415       n[1].e = matrixMode;
9416       n[2].f = angle;
9417       n[3].f = x;
9418       n[4].f = y;
9419       n[5].f = z;
9420    }
9421    if (ctx->ExecuteFlag) {
9422       CALL_MatrixRotatefEXT(ctx->Exec, (matrixMode, angle, x, y, z));
9423    }
9424 }
9425 
9426 static void GLAPIENTRY
save_MatrixRotatedEXT(GLenum matrixMode,GLdouble angle,GLdouble x,GLdouble y,GLdouble z)9427 save_MatrixRotatedEXT(GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
9428 {
9429    save_MatrixRotatefEXT(matrixMode, (GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9430 }
9431 
9432 static void GLAPIENTRY
save_MatrixScalefEXT(GLenum matrixMode,GLfloat x,GLfloat y,GLfloat z)9433 save_MatrixScalefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9434 {
9435    GET_CURRENT_CONTEXT(ctx);
9436    Node *n;
9437    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9438    n = alloc_instruction(ctx, OPCODE_MATRIX_SCALE, 4);
9439    if (n) {
9440       n[1].e = matrixMode;
9441       n[2].f = x;
9442       n[3].f = y;
9443       n[4].f = z;
9444    }
9445    if (ctx->ExecuteFlag) {
9446       CALL_MatrixScalefEXT(ctx->Exec, (matrixMode, x, y, z));
9447    }
9448 }
9449 
9450 static void GLAPIENTRY
save_MatrixScaledEXT(GLenum matrixMode,GLdouble x,GLdouble y,GLdouble z)9451 save_MatrixScaledEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9452 {
9453    save_MatrixScalefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9454 }
9455 
9456 static void GLAPIENTRY
save_MatrixTranslatefEXT(GLenum matrixMode,GLfloat x,GLfloat y,GLfloat z)9457 save_MatrixTranslatefEXT(GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z)
9458 {
9459    GET_CURRENT_CONTEXT(ctx);
9460    Node *n;
9461    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9462    n = alloc_instruction(ctx, OPCODE_MATRIX_TRANSLATE, 4);
9463    if (n) {
9464       n[1].e = matrixMode;
9465       n[2].f = x;
9466       n[3].f = y;
9467       n[4].f = z;
9468    }
9469    if (ctx->ExecuteFlag) {
9470       CALL_MatrixTranslatefEXT(ctx->Exec, (matrixMode, x, y, z));
9471    }
9472 }
9473 
9474 static void GLAPIENTRY
save_MatrixTranslatedEXT(GLenum matrixMode,GLdouble x,GLdouble y,GLdouble z)9475 save_MatrixTranslatedEXT(GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z)
9476 {
9477    save_MatrixTranslatefEXT(matrixMode, (GLfloat) x, (GLfloat) y, (GLfloat) z);
9478 }
9479 
9480 static void GLAPIENTRY
save_MatrixLoadIdentityEXT(GLenum matrixMode)9481 save_MatrixLoadIdentityEXT(GLenum matrixMode)
9482 {
9483    GET_CURRENT_CONTEXT(ctx);
9484    Node *n;
9485    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9486    n = alloc_instruction(ctx, OPCODE_MATRIX_LOAD_IDENTITY, 1);
9487    if (n) {
9488       n[1].e = matrixMode;
9489    }
9490    if (ctx->ExecuteFlag) {
9491       CALL_MatrixLoadIdentityEXT(ctx->Exec, (matrixMode));
9492    }
9493 }
9494 
9495 static void GLAPIENTRY
save_MatrixOrthoEXT(GLenum matrixMode,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)9496 save_MatrixOrthoEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9497                     GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9498 {
9499    GET_CURRENT_CONTEXT(ctx);
9500    Node *n;
9501    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9502    n = alloc_instruction(ctx, OPCODE_MATRIX_ORTHO, 7);
9503    if (n) {
9504       n[1].e = matrixMode;
9505       n[2].f = (GLfloat) left;
9506       n[3].f = (GLfloat) right;
9507       n[4].f = (GLfloat) bottom;
9508       n[5].f = (GLfloat) top;
9509       n[6].f = (GLfloat) nearval;
9510       n[7].f = (GLfloat) farval;
9511    }
9512    if (ctx->ExecuteFlag) {
9513       CALL_MatrixOrthoEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9514    }
9515 }
9516 
9517 
9518 static void GLAPIENTRY
save_MatrixFrustumEXT(GLenum matrixMode,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)9519 save_MatrixFrustumEXT(GLenum matrixMode, GLdouble left, GLdouble right,
9520                       GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
9521 {
9522    GET_CURRENT_CONTEXT(ctx);
9523    Node *n;
9524    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9525    n = alloc_instruction(ctx, OPCODE_MATRIX_FRUSTUM, 7);
9526    if (n) {
9527       n[1].e = matrixMode;
9528       n[2].f = (GLfloat) left;
9529       n[3].f = (GLfloat) right;
9530       n[4].f = (GLfloat) bottom;
9531       n[5].f = (GLfloat) top;
9532       n[6].f = (GLfloat) nearval;
9533       n[7].f = (GLfloat) farval;
9534    }
9535    if (ctx->ExecuteFlag) {
9536       CALL_MatrixFrustumEXT(ctx->Exec, (matrixMode, left, right, bottom, top, nearval, farval));
9537    }
9538 }
9539 
9540 static void GLAPIENTRY
save_MatrixPushEXT(GLenum matrixMode)9541 save_MatrixPushEXT(GLenum matrixMode)
9542 {
9543    GET_CURRENT_CONTEXT(ctx);
9544    Node* n;
9545    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9546    n = alloc_instruction(ctx, OPCODE_MATRIX_PUSH, 1);
9547    if (n) {
9548       n[1].e = matrixMode;
9549    }
9550    if (ctx->ExecuteFlag) {
9551       CALL_MatrixPushEXT(ctx->Exec, (matrixMode));
9552    }
9553 }
9554 
9555 static void GLAPIENTRY
save_MatrixPopEXT(GLenum matrixMode)9556 save_MatrixPopEXT(GLenum matrixMode)
9557 {
9558    GET_CURRENT_CONTEXT(ctx);
9559    Node* n;
9560    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9561    n = alloc_instruction(ctx, OPCODE_MATRIX_POP, 1);
9562    if (n) {
9563       n[1].e = matrixMode;
9564    }
9565    if (ctx->ExecuteFlag) {
9566       CALL_MatrixPopEXT(ctx->Exec, (matrixMode));
9567    }
9568 }
9569 
9570 static void GLAPIENTRY
save_MatrixLoadTransposefEXT(GLenum matrixMode,const GLfloat m[16])9571 save_MatrixLoadTransposefEXT(GLenum matrixMode, const GLfloat m[16])
9572 {
9573    GLfloat tm[16];
9574    _math_transposef(tm, m);
9575    save_MatrixLoadfEXT(matrixMode, tm);
9576 }
9577 
9578 static void GLAPIENTRY
save_MatrixLoadTransposedEXT(GLenum matrixMode,const GLdouble m[16])9579 save_MatrixLoadTransposedEXT(GLenum matrixMode, const GLdouble m[16])
9580 {
9581    GLfloat tm[16];
9582    _math_transposefd(tm, m);
9583    save_MatrixLoadfEXT(matrixMode, tm);
9584 }
9585 
9586 static void GLAPIENTRY
save_MatrixMultTransposefEXT(GLenum matrixMode,const GLfloat m[16])9587 save_MatrixMultTransposefEXT(GLenum matrixMode, const GLfloat m[16])
9588 {
9589    GLfloat tm[16];
9590    _math_transposef(tm, m);
9591    save_MatrixMultfEXT(matrixMode, tm);
9592 }
9593 
9594 static void GLAPIENTRY
save_MatrixMultTransposedEXT(GLenum matrixMode,const GLdouble m[16])9595 save_MatrixMultTransposedEXT(GLenum matrixMode, const GLdouble m[16])
9596 {
9597    GLfloat tm[16];
9598    _math_transposefd(tm, m);
9599    save_MatrixMultfEXT(matrixMode, tm);
9600 }
9601 
9602 static void GLAPIENTRY
save_TextureParameterfvEXT(GLuint texture,GLenum target,GLenum pname,const GLfloat * params)9603 save_TextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname,
9604                            const GLfloat *params)
9605 {
9606    GET_CURRENT_CONTEXT(ctx);
9607    Node *n;
9608    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9609    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_F, 7);
9610    if (n) {
9611       n[1].ui = texture;
9612       n[2].e = target;
9613       n[3].e = pname;
9614       n[4].f = params[0];
9615       n[5].f = params[1];
9616       n[6].f = params[2];
9617       n[7].f = params[3];
9618    }
9619    if (ctx->ExecuteFlag) {
9620       CALL_TextureParameterfvEXT(ctx->Exec, (texture, target, pname, params));
9621    }
9622 }
9623 
9624 
9625 static void GLAPIENTRY
save_TextureParameterfEXT(GLuint texture,GLenum target,GLenum pname,GLfloat param)9626 save_TextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
9627 {
9628    GLfloat parray[4];
9629    parray[0] = param;
9630    parray[1] = parray[2] = parray[3] = 0.0F;
9631    save_TextureParameterfvEXT(texture, target, pname, parray);
9632 }
9633 
9634 static void GLAPIENTRY
save_TextureParameterivEXT(GLuint texture,GLenum target,GLenum pname,const GLint * params)9635 save_TextureParameterivEXT(GLuint texture, GLenum target, GLenum pname, const GLint *params)
9636 {
9637    GET_CURRENT_CONTEXT(ctx);
9638    Node *n;
9639    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9640    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_I, 7);
9641    if (n) {
9642       n[1].ui = texture;
9643       n[2].e = target;
9644       n[3].e = pname;
9645       n[4].i = params[0];
9646       n[5].i = params[1];
9647       n[6].i = params[2];
9648       n[7].i = params[3];
9649    }
9650    if (ctx->ExecuteFlag) {
9651       CALL_TextureParameterivEXT(ctx->Exec, (texture, target, pname, params));
9652    }
9653 }
9654 
9655 static void GLAPIENTRY
save_TextureParameteriEXT(GLuint texture,GLenum target,GLenum pname,GLint param)9656 save_TextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
9657 {
9658    GLint fparam[4];
9659    fparam[0] = param;
9660    fparam[1] = fparam[2] = fparam[3] = 0;
9661    save_TextureParameterivEXT(texture, target, pname, fparam);
9662 }
9663 
9664 static void GLAPIENTRY
save_TextureParameterIivEXT(GLuint texture,GLenum target,GLenum pname,const GLint * params)9665 save_TextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, const GLint* params)
9666 {
9667    GET_CURRENT_CONTEXT(ctx);
9668    Node *n;
9669    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9670    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_II, 7);
9671    if (n) {
9672       n[1].ui = texture;
9673       n[2].e = target;
9674       n[3].e = pname;
9675       n[4].i = params[0];
9676       n[5].i = params[1];
9677       n[6].i = params[2];
9678       n[7].i = params[3];
9679    }
9680    if (ctx->ExecuteFlag) {
9681       CALL_TextureParameterIivEXT(ctx->Exec, (texture, target, pname, params));
9682    }
9683 }
9684 
9685 static void GLAPIENTRY
save_TextureParameterIuivEXT(GLuint texture,GLenum target,GLenum pname,const GLuint * params)9686 save_TextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname, const GLuint* params)
9687 {
9688    GET_CURRENT_CONTEXT(ctx);
9689    Node *n;
9690    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9691    n = alloc_instruction(ctx, OPCODE_TEXTUREPARAMETER_IUI, 7);
9692    if (n) {
9693       n[1].ui = texture;
9694       n[2].e = target;
9695       n[3].e = pname;
9696       n[4].ui = params[0];
9697       n[5].ui = params[1];
9698       n[6].ui = params[2];
9699       n[7].ui = params[3];
9700    }
9701    if (ctx->ExecuteFlag) {
9702       CALL_TextureParameterIuivEXT(ctx->Exec, (texture, target, pname, params));
9703    }
9704 }
9705 
9706 
9707 static void GLAPIENTRY
save_TextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)9708 save_TextureImage1DEXT(GLuint texture, GLenum target,
9709                        GLint level, GLint components,
9710                        GLsizei width, GLint border,
9711                        GLenum format, GLenum type, const GLvoid * pixels)
9712 {
9713    GET_CURRENT_CONTEXT(ctx);
9714    if (target == GL_PROXY_TEXTURE_1D) {
9715       /* don't compile, execute immediately */
9716       CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9717                                          border, format, type, pixels));
9718    }
9719    else {
9720       Node *n;
9721       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9722       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE1D, 8 + POINTER_DWORDS);
9723       if (n) {
9724          n[1].ui = texture;
9725          n[2].e = target;
9726          n[3].i = level;
9727          n[4].i = components;
9728          n[5].i = (GLint) width;
9729          n[6].i = border;
9730          n[7].e = format;
9731          n[8].e = type;
9732          save_pointer(&n[9],
9733                       unpack_image(ctx, 1, width, 1, 1, format, type,
9734                                    pixels, &ctx->Unpack));
9735       }
9736       if (ctx->ExecuteFlag) {
9737          CALL_TextureImage1DEXT(ctx->Exec, (texture, target, level, components, width,
9738                                             border, format, type, pixels));
9739       }
9740    }
9741 }
9742 
9743 
9744 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)9745 save_TextureImage2DEXT(GLuint texture, GLenum target,
9746                        GLint level, GLint components,
9747                        GLsizei width, GLsizei height, GLint border,
9748                        GLenum format, GLenum type, const GLvoid * pixels)
9749 {
9750    GET_CURRENT_CONTEXT(ctx);
9751    if (target == GL_PROXY_TEXTURE_2D) {
9752       /* don't compile, execute immediately */
9753       CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9754                                          height, border, format, type, pixels));
9755    }
9756    else {
9757       Node *n;
9758       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9759       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE2D, 9 + POINTER_DWORDS);
9760       if (n) {
9761          n[1].ui = texture;
9762          n[2].e = target;
9763          n[3].i = level;
9764          n[4].i = components;
9765          n[5].i = (GLint) width;
9766          n[6].i = (GLint) height;
9767          n[7].i = border;
9768          n[8].e = format;
9769          n[9].e = type;
9770          save_pointer(&n[10],
9771                       unpack_image(ctx, 2, width, height, 1, format, type,
9772                                    pixels, &ctx->Unpack));
9773       }
9774       if (ctx->ExecuteFlag) {
9775          CALL_TextureImage2DEXT(ctx->Exec, (texture, target, level, components, width,
9776                                             height, border, format, type, pixels));
9777       }
9778    }
9779 }
9780 
9781 
9782 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)9783 save_TextureImage3DEXT(GLuint texture, GLenum target,
9784                        GLint level, GLint internalFormat,
9785                        GLsizei width, GLsizei height, GLsizei depth,
9786                        GLint border,
9787                        GLenum format, GLenum type, const GLvoid * pixels)
9788 {
9789    GET_CURRENT_CONTEXT(ctx);
9790    if (target == GL_PROXY_TEXTURE_3D) {
9791       /* don't compile, execute immediately */
9792       CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat, width,
9793                                          height, depth, border, format, type,
9794                                          pixels));
9795    }
9796    else {
9797       Node *n;
9798       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9799       n = alloc_instruction(ctx, OPCODE_TEXTURE_IMAGE3D, 10 + POINTER_DWORDS);
9800       if (n) {
9801          n[1].ui = texture;
9802          n[2].e = target;
9803          n[3].i = level;
9804          n[4].i = (GLint) internalFormat;
9805          n[5].i = (GLint) width;
9806          n[6].i = (GLint) height;
9807          n[7].i = (GLint) depth;
9808          n[8].i = border;
9809          n[9].e = format;
9810          n[10].e = type;
9811          save_pointer(&n[11],
9812                       unpack_image(ctx, 3, width, height, depth, format, type,
9813                                    pixels, &ctx->Unpack));
9814       }
9815       if (ctx->ExecuteFlag) {
9816          CALL_TextureImage3DEXT(ctx->Exec, (texture, target, level, internalFormat,
9817                                             width, height, depth, border, format,
9818                                             type, pixels));
9819       }
9820    }
9821 }
9822 
9823 
9824 static void GLAPIENTRY
save_TextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)9825 save_TextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
9826                    GLsizei width, GLenum format, GLenum type,
9827                    const GLvoid * pixels)
9828 {
9829    GET_CURRENT_CONTEXT(ctx);
9830    Node *n;
9831 
9832    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9833 
9834    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE1D, 7 + POINTER_DWORDS);
9835    if (n) {
9836       n[1].ui = texture;
9837       n[2].e = target;
9838       n[3].i = level;
9839       n[4].i = xoffset;
9840       n[5].i = (GLint) width;
9841       n[6].e = format;
9842       n[7].e = type;
9843       save_pointer(&n[8],
9844                    unpack_image(ctx, 1, width, 1, 1, format, type,
9845                                 pixels, &ctx->Unpack));
9846    }
9847    if (ctx->ExecuteFlag) {
9848       CALL_TextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset, width,
9849                                             format, type, pixels));
9850    }
9851 }
9852 
9853 
9854 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)9855 save_TextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
9856                           GLint xoffset, GLint yoffset,
9857                           GLsizei width, GLsizei height,
9858                           GLenum format, GLenum type, const GLvoid * pixels)
9859 {
9860    GET_CURRENT_CONTEXT(ctx);
9861    Node *n;
9862 
9863    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9864 
9865    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE2D, 9 + POINTER_DWORDS);
9866    if (n) {
9867       n[1].ui = texture;
9868       n[2].e = target;
9869       n[3].i = level;
9870       n[4].i = xoffset;
9871       n[5].i = yoffset;
9872       n[6].i = (GLint) width;
9873       n[7].i = (GLint) height;
9874       n[8].e = format;
9875       n[9].e = type;
9876       save_pointer(&n[10],
9877                    unpack_image(ctx, 2, width, height, 1, format, type,
9878                                 pixels, &ctx->Unpack));
9879    }
9880    if (ctx->ExecuteFlag) {
9881       CALL_TextureSubImage2DEXT(ctx->Exec, (texture, target, level, xoffset, yoffset,
9882                                             width, height, format, type, pixels));
9883    }
9884 }
9885 
9886 
9887 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)9888 save_TextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
9889                           GLint xoffset, GLint yoffset, GLint zoffset,
9890                           GLsizei width, GLsizei height, GLsizei depth,
9891                           GLenum format, GLenum type, const GLvoid * pixels)
9892 {
9893    GET_CURRENT_CONTEXT(ctx);
9894    Node *n;
9895 
9896    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9897 
9898    n = alloc_instruction(ctx, OPCODE_TEXTURE_SUB_IMAGE3D, 11 + POINTER_DWORDS);
9899    if (n) {
9900       n[1].ui = texture;
9901       n[2].e = target;
9902       n[3].i = level;
9903       n[4].i = xoffset;
9904       n[5].i = yoffset;
9905       n[6].i = zoffset;
9906       n[7].i = (GLint) width;
9907       n[8].i = (GLint) height;
9908       n[9].i = (GLint) depth;
9909       n[10].e = format;
9910       n[11].e = type;
9911       save_pointer(&n[12],
9912                    unpack_image(ctx, 3, width, height, depth, format, type,
9913                                 pixels, &ctx->Unpack));
9914    }
9915    if (ctx->ExecuteFlag) {
9916       CALL_TextureSubImage3DEXT(ctx->Exec, (texture, target, level,
9917                                             xoffset, yoffset, zoffset,
9918                                             width, height, depth, format, type,
9919                                             pixels));
9920    }
9921 }
9922 
9923 static void GLAPIENTRY
save_CopyTextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)9924 save_CopyTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
9925                            GLenum internalformat, GLint x, GLint y,
9926                            GLsizei width, GLint border)
9927 {
9928    GET_CURRENT_CONTEXT(ctx);
9929    Node *n;
9930    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9931    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE1D, 8);
9932    if (n) {
9933       n[1].ui = texture;
9934       n[2].e = target;
9935       n[3].i = level;
9936       n[4].e = internalformat;
9937       n[5].i = x;
9938       n[6].i = y;
9939       n[7].i = width;
9940       n[8].i = border;
9941    }
9942    if (ctx->ExecuteFlag) {
9943       CALL_CopyTextureImage1DEXT(ctx->Exec, (texture, target, level,
9944                                              internalformat, x, y,
9945                                              width, border));
9946    }
9947 }
9948 
9949 static void GLAPIENTRY
save_CopyTextureImage2DEXT(GLuint texture,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)9950 save_CopyTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
9951                            GLenum internalformat,
9952                            GLint x, GLint y, GLsizei width,
9953                            GLsizei height, GLint border)
9954 {
9955    GET_CURRENT_CONTEXT(ctx);
9956    Node *n;
9957    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9958    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_IMAGE2D, 9);
9959    if (n) {
9960       n[1].ui = texture;
9961       n[2].e = target;
9962       n[3].i = level;
9963       n[4].e = internalformat;
9964       n[5].i = x;
9965       n[6].i = y;
9966       n[7].i = width;
9967       n[8].i = height;
9968       n[9].i = border;
9969    }
9970    if (ctx->ExecuteFlag) {
9971       CALL_CopyTextureImage2DEXT(ctx->Exec, (texture, target, level,
9972                                              internalformat, x, y,
9973                                              width, height, border));
9974    }
9975 }
9976 
9977 static void GLAPIENTRY
save_CopyTextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)9978 save_CopyTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level,
9979                               GLint xoffset, GLint x, GLint y, GLsizei width)
9980 {
9981    GET_CURRENT_CONTEXT(ctx);
9982    Node *n;
9983    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
9984    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE1D, 7);
9985    if (n) {
9986       n[1].ui = texture;
9987       n[2].e = target;
9988       n[3].i = level;
9989       n[4].i = xoffset;
9990       n[5].i = x;
9991       n[6].i = y;
9992       n[7].i = width;
9993    }
9994    if (ctx->ExecuteFlag) {
9995       CALL_CopyTextureSubImage1DEXT(ctx->Exec,
9996                              (texture, target, level, xoffset, x, y, width));
9997    }
9998 }
9999 
10000 static void GLAPIENTRY
save_CopyTextureSubImage2DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)10001 save_CopyTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
10002                               GLint xoffset, GLint yoffset,
10003                               GLint x, GLint y, GLsizei width, GLint height)
10004 {
10005    GET_CURRENT_CONTEXT(ctx);
10006    Node *n;
10007    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10008    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE2D, 9);
10009    if (n) {
10010       n[1].ui = texture;
10011       n[2].e = target;
10012       n[3].i = level;
10013       n[4].i = xoffset;
10014       n[5].i = yoffset;
10015       n[6].i = x;
10016       n[7].i = y;
10017       n[8].i = width;
10018       n[9].i = height;
10019    }
10020    if (ctx->ExecuteFlag) {
10021       CALL_CopyTextureSubImage2DEXT(ctx->Exec, (texture, target, level,
10022                                                 xoffset, yoffset,
10023                                                 x, y, width, height));
10024    }
10025 }
10026 
10027 
10028 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)10029 save_CopyTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
10030                               GLint xoffset, GLint yoffset, GLint zoffset,
10031                               GLint x, GLint y, GLsizei width, GLint height)
10032 {
10033    GET_CURRENT_CONTEXT(ctx);
10034    Node *n;
10035    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10036    n = alloc_instruction(ctx, OPCODE_COPY_TEXTURE_SUB_IMAGE3D, 10);
10037    if (n) {
10038       n[1].ui = texture;
10039       n[2].e = target;
10040       n[3].i = level;
10041       n[4].i = xoffset;
10042       n[5].i = yoffset;
10043       n[6].i = zoffset;
10044       n[7].i = x;
10045       n[8].i = y;
10046       n[9].i = width;
10047       n[10].i = height;
10048    }
10049    if (ctx->ExecuteFlag) {
10050       CALL_CopyTextureSubImage3DEXT(ctx->Exec, (texture, target, level,
10051                                                 xoffset, yoffset, zoffset,
10052                                                 x, y, width, height));
10053    }
10054 }
10055 
10056 
10057 static void GLAPIENTRY
save_BindMultiTextureEXT(GLenum texunit,GLenum target,GLuint texture)10058 save_BindMultiTextureEXT(GLenum texunit, GLenum target, GLuint texture)
10059 {
10060    GET_CURRENT_CONTEXT(ctx);
10061    Node *n;
10062    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10063    n = alloc_instruction(ctx, OPCODE_BIND_MULTITEXTURE, 3);
10064    if (n) {
10065       n[1].e = texunit;
10066       n[2].e = target;
10067       n[3].ui = texture;
10068    }
10069    if (ctx->ExecuteFlag) {
10070       CALL_BindMultiTextureEXT(ctx->Exec, (texunit, target, texture));
10071    }
10072 }
10073 
10074 
10075 static void GLAPIENTRY
save_MultiTexParameterfvEXT(GLenum texunit,GLenum target,GLenum pname,const GLfloat * params)10076 save_MultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname,
10077                            const GLfloat *params)
10078 {
10079    GET_CURRENT_CONTEXT(ctx);
10080    Node *n;
10081    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10082    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_F, 7);
10083    if (n) {
10084       n[1].e = texunit;
10085       n[2].e = target;
10086       n[3].e = pname;
10087       n[4].f = params[0];
10088       n[5].f = params[1];
10089       n[6].f = params[2];
10090       n[7].f = params[3];
10091    }
10092    if (ctx->ExecuteFlag) {
10093       CALL_MultiTexParameterfvEXT(ctx->Exec, (texunit, target, pname, params));
10094    }
10095 }
10096 
10097 
10098 static void GLAPIENTRY
save_MultiTexParameterfEXT(GLenum texunit,GLenum target,GLenum pname,GLfloat param)10099 save_MultiTexParameterfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
10100 {
10101    GLfloat parray[4];
10102    parray[0] = param;
10103    parray[1] = parray[2] = parray[3] = 0.0F;
10104    save_MultiTexParameterfvEXT(texunit, target, pname, parray);
10105 }
10106 
10107 static void GLAPIENTRY
save_MultiTexParameterivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * params)10108 save_MultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
10109 {
10110    GET_CURRENT_CONTEXT(ctx);
10111    Node *n;
10112    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10113    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_I, 7);
10114    if (n) {
10115       n[1].e = texunit;
10116       n[2].e = target;
10117       n[3].e = pname;
10118       n[4].i = params[0];
10119       n[5].i = params[1];
10120       n[6].i = params[2];
10121       n[7].i = params[3];
10122    }
10123    if (ctx->ExecuteFlag) {
10124       CALL_MultiTexParameterivEXT(ctx->Exec, (texunit, target, pname, params));
10125    }
10126 }
10127 
10128 static void GLAPIENTRY
save_MultiTexParameterIivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * params)10129 save_MultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint *params)
10130 {
10131    GET_CURRENT_CONTEXT(ctx);
10132    Node *n;
10133    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10134    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_II, 7);
10135    if (n) {
10136       n[1].e = texunit;
10137       n[2].e = target;
10138       n[3].e = pname;
10139       n[4].i = params[0];
10140       n[5].i = params[1];
10141       n[6].i = params[2];
10142       n[7].i = params[3];
10143    }
10144    if (ctx->ExecuteFlag) {
10145       CALL_MultiTexParameterIivEXT(ctx->Exec, (texunit, target, pname, params));
10146    }
10147 }
10148 
10149 static void GLAPIENTRY
save_MultiTexParameterIuivEXT(GLenum texunit,GLenum target,GLenum pname,const GLuint * params)10150 save_MultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname, const GLuint *params)
10151 {
10152    GET_CURRENT_CONTEXT(ctx);
10153    Node *n;
10154    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10155    n = alloc_instruction(ctx, OPCODE_MULTITEXPARAMETER_IUI, 7);
10156    if (n) {
10157       n[1].e = texunit;
10158       n[2].e = target;
10159       n[3].e = pname;
10160       n[4].ui = params[0];
10161       n[5].ui = params[1];
10162       n[6].ui = params[2];
10163       n[7].ui = params[3];
10164    }
10165    if (ctx->ExecuteFlag) {
10166       CALL_MultiTexParameterIuivEXT(ctx->Exec, (texunit, target, pname, params));
10167    }
10168 }
10169 
10170 static void GLAPIENTRY
save_MultiTexParameteriEXT(GLenum texunit,GLenum target,GLenum pname,GLint param)10171 save_MultiTexParameteriEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
10172 {
10173    GLint fparam[4];
10174    fparam[0] = param;
10175    fparam[1] = fparam[2] = fparam[3] = 0;
10176    save_MultiTexParameterivEXT(texunit, target, pname, fparam);
10177 }
10178 
10179 
10180 static void GLAPIENTRY
save_MultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,const GLvoid * pixels)10181 save_MultiTexImage1DEXT(GLenum texunit, GLenum target,
10182                         GLint level, GLint components,
10183                         GLsizei width, GLint border,
10184                         GLenum format, GLenum type, const GLvoid * pixels)
10185 {
10186    GET_CURRENT_CONTEXT(ctx);
10187    if (target == GL_PROXY_TEXTURE_1D) {
10188       /* don't compile, execute immediately */
10189       CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
10190                                          border, format, type, pixels));
10191    }
10192    else {
10193       Node *n;
10194       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10195       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE1D, 8 + POINTER_DWORDS);
10196       if (n) {
10197          n[1].e = texunit;
10198          n[2].e = target;
10199          n[3].i = level;
10200          n[4].i = components;
10201          n[5].i = (GLint) width;
10202          n[6].i = border;
10203          n[7].e = format;
10204          n[8].e = type;
10205          save_pointer(&n[9],
10206                       unpack_image(ctx, 1, width, 1, 1, format, type,
10207                                    pixels, &ctx->Unpack));
10208       }
10209       if (ctx->ExecuteFlag) {
10210          CALL_MultiTexImage1DEXT(ctx->Exec, (texunit, target, level, components, width,
10211                                             border, format, type, pixels));
10212       }
10213    }
10214 }
10215 
10216 
10217 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)10218 save_MultiTexImage2DEXT(GLenum texunit, GLenum target,
10219                        GLint level, GLint components,
10220                        GLsizei width, GLsizei height, GLint border,
10221                        GLenum format, GLenum type, const GLvoid * pixels)
10222 {
10223    GET_CURRENT_CONTEXT(ctx);
10224    if (target == GL_PROXY_TEXTURE_2D) {
10225       /* don't compile, execute immediately */
10226       CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
10227                                          height, border, format, type, pixels));
10228    }
10229    else {
10230       Node *n;
10231       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10232       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE2D, 9 + POINTER_DWORDS);
10233       if (n) {
10234          n[1].e = texunit;
10235          n[2].e = target;
10236          n[3].i = level;
10237          n[4].i = components;
10238          n[5].i = (GLint) width;
10239          n[6].i = (GLint) height;
10240          n[7].i = border;
10241          n[8].e = format;
10242          n[9].e = type;
10243          save_pointer(&n[10],
10244                       unpack_image(ctx, 2, width, height, 1, format, type,
10245                                    pixels, &ctx->Unpack));
10246       }
10247       if (ctx->ExecuteFlag) {
10248          CALL_MultiTexImage2DEXT(ctx->Exec, (texunit, target, level, components, width,
10249                                             height, border, format, type, pixels));
10250       }
10251    }
10252 }
10253 
10254 
10255 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)10256 save_MultiTexImage3DEXT(GLenum texunit, GLenum target,
10257                        GLint level, GLint internalFormat,
10258                        GLsizei width, GLsizei height, GLsizei depth,
10259                        GLint border,
10260                        GLenum format, GLenum type, const GLvoid * pixels)
10261 {
10262    GET_CURRENT_CONTEXT(ctx);
10263    if (target == GL_PROXY_TEXTURE_3D) {
10264       /* don't compile, execute immediately */
10265       CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat, width,
10266                                          height, depth, border, format, type,
10267                                          pixels));
10268    }
10269    else {
10270       Node *n;
10271       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10272       n = alloc_instruction(ctx, OPCODE_MULTITEX_IMAGE3D, 10 + POINTER_DWORDS);
10273       if (n) {
10274          n[1].e = texunit;
10275          n[2].e = target;
10276          n[3].i = level;
10277          n[4].i = (GLint) internalFormat;
10278          n[5].i = (GLint) width;
10279          n[6].i = (GLint) height;
10280          n[7].i = (GLint) depth;
10281          n[8].i = border;
10282          n[9].e = format;
10283          n[10].e = type;
10284          save_pointer(&n[11],
10285                       unpack_image(ctx, 3, width, height, depth, format, type,
10286                                    pixels, &ctx->Unpack));
10287       }
10288       if (ctx->ExecuteFlag) {
10289          CALL_MultiTexImage3DEXT(ctx->Exec, (texunit, target, level, internalFormat,
10290                                             width, height, depth, border, format,
10291                                             type, pixels));
10292       }
10293    }
10294 }
10295 
10296 
10297 static void GLAPIENTRY
save_MultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,const GLvoid * pixels)10298 save_MultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10299                    GLsizei width, GLenum format, GLenum type,
10300                    const GLvoid * pixels)
10301 {
10302    GET_CURRENT_CONTEXT(ctx);
10303    Node *n;
10304 
10305    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10306 
10307    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE1D, 7 + POINTER_DWORDS);
10308    if (n) {
10309       n[1].e = texunit;
10310       n[2].e = target;
10311       n[3].i = level;
10312       n[4].i = xoffset;
10313       n[5].i = (GLint) width;
10314       n[6].e = format;
10315       n[7].e = type;
10316       save_pointer(&n[8],
10317                    unpack_image(ctx, 1, width, 1, 1, format, type,
10318                                 pixels, &ctx->Unpack));
10319    }
10320    if (ctx->ExecuteFlag) {
10321       CALL_MultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset, width,
10322                                             format, type, pixels));
10323    }
10324 }
10325 
10326 
10327 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)10328 save_MultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
10329                           GLint xoffset, GLint yoffset,
10330                           GLsizei width, GLsizei height,
10331                           GLenum format, GLenum type, const GLvoid * pixels)
10332 {
10333    GET_CURRENT_CONTEXT(ctx);
10334    Node *n;
10335 
10336    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10337 
10338    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE2D, 9 + POINTER_DWORDS);
10339    if (n) {
10340       n[1].e = texunit;
10341       n[2].e = target;
10342       n[3].i = level;
10343       n[4].i = xoffset;
10344       n[5].i = yoffset;
10345       n[6].i = (GLint) width;
10346       n[7].i = (GLint) height;
10347       n[8].e = format;
10348       n[9].e = type;
10349       save_pointer(&n[10],
10350                    unpack_image(ctx, 2, width, height, 1, format, type,
10351                                 pixels, &ctx->Unpack));
10352    }
10353    if (ctx->ExecuteFlag) {
10354       CALL_MultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level, xoffset, yoffset,
10355                                             width, height, format, type, pixels));
10356    }
10357 }
10358 
10359 
10360 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)10361 save_MultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
10362                           GLint xoffset, GLint yoffset, GLint zoffset,
10363                           GLsizei width, GLsizei height, GLsizei depth,
10364                           GLenum format, GLenum type, const GLvoid * pixels)
10365 {
10366    GET_CURRENT_CONTEXT(ctx);
10367    Node *n;
10368 
10369    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10370 
10371    n = alloc_instruction(ctx, OPCODE_MULTITEX_SUB_IMAGE3D, 11 + POINTER_DWORDS);
10372    if (n) {
10373       n[1].e = texunit;
10374       n[2].e = target;
10375       n[3].i = level;
10376       n[4].i = xoffset;
10377       n[5].i = yoffset;
10378       n[6].i = zoffset;
10379       n[7].i = (GLint) width;
10380       n[8].i = (GLint) height;
10381       n[9].i = (GLint) depth;
10382       n[10].e = format;
10383       n[11].e = type;
10384       save_pointer(&n[12],
10385                    unpack_image(ctx, 3, width, height, depth, format, type,
10386                                 pixels, &ctx->Unpack));
10387    }
10388    if (ctx->ExecuteFlag) {
10389       CALL_MultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10390                                             xoffset, yoffset, zoffset,
10391                                             width, height, depth, format, type,
10392                                             pixels));
10393    }
10394 }
10395 
10396 
10397 static void GLAPIENTRY
save_CopyMultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)10398 save_CopyMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
10399                            GLenum internalformat, GLint x, GLint y,
10400                            GLsizei width, GLint border)
10401 {
10402    GET_CURRENT_CONTEXT(ctx);
10403    Node *n;
10404    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10405    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE1D, 8);
10406    if (n) {
10407       n[1].e = texunit;
10408       n[2].e = target;
10409       n[3].i = level;
10410       n[4].e = internalformat;
10411       n[5].i = x;
10412       n[6].i = y;
10413       n[7].i = width;
10414       n[8].i = border;
10415    }
10416    if (ctx->ExecuteFlag) {
10417       CALL_CopyMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
10418                                              internalformat, x, y,
10419                                              width, border));
10420    }
10421 }
10422 
10423 
10424 static void GLAPIENTRY
save_CopyMultiTexImage2DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)10425 save_CopyMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
10426                            GLenum internalformat,
10427                            GLint x, GLint y, GLsizei width,
10428                            GLsizei height, GLint border)
10429 {
10430    GET_CURRENT_CONTEXT(ctx);
10431    Node *n;
10432    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10433    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_IMAGE2D, 9);
10434    if (n) {
10435       n[1].e = texunit;
10436       n[2].e = target;
10437       n[3].i = level;
10438       n[4].e = internalformat;
10439       n[5].i = x;
10440       n[6].i = y;
10441       n[7].i = width;
10442       n[8].i = height;
10443       n[9].i = border;
10444    }
10445    if (ctx->ExecuteFlag) {
10446       CALL_CopyMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
10447                                              internalformat, x, y,
10448                                              width, height, border));
10449    }
10450 }
10451 
10452 
10453 static void GLAPIENTRY
save_CopyMultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)10454 save_CopyMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level,
10455                               GLint xoffset, GLint x, GLint y, GLsizei width)
10456 {
10457    GET_CURRENT_CONTEXT(ctx);
10458    Node *n;
10459    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10460    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE1D, 7);
10461    if (n) {
10462       n[1].e = texunit;
10463       n[2].e = target;
10464       n[3].i = level;
10465       n[4].i = xoffset;
10466       n[5].i = x;
10467       n[6].i = y;
10468       n[7].i = width;
10469    }
10470    if (ctx->ExecuteFlag) {
10471       CALL_CopyMultiTexSubImage1DEXT(ctx->Exec,
10472                              (texunit, target, level, xoffset, x, y, width));
10473    }
10474 }
10475 
10476 
10477 static void GLAPIENTRY
save_CopyMultiTexSubImage2DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)10478 save_CopyMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level,
10479                               GLint xoffset, GLint yoffset,
10480                               GLint x, GLint y, GLsizei width, GLint height)
10481 {
10482    GET_CURRENT_CONTEXT(ctx);
10483    Node *n;
10484    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10485    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE2D, 9);
10486    if (n) {
10487       n[1].e = texunit;
10488       n[2].e = target;
10489       n[3].i = level;
10490       n[4].i = xoffset;
10491       n[5].i = yoffset;
10492       n[6].i = x;
10493       n[7].i = y;
10494       n[8].i = width;
10495       n[9].i = height;
10496    }
10497    if (ctx->ExecuteFlag) {
10498       CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (texunit, target, level,
10499                                                 xoffset, yoffset,
10500                                                 x, y, width, height));
10501    }
10502 }
10503 
10504 
10505 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)10506 save_CopyMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level,
10507                               GLint xoffset, GLint yoffset, GLint zoffset,
10508                               GLint x, GLint y, GLsizei width, GLint height)
10509 {
10510    GET_CURRENT_CONTEXT(ctx);
10511    Node *n;
10512    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10513    n = alloc_instruction(ctx, OPCODE_COPY_MULTITEX_SUB_IMAGE3D, 10);
10514    if (n) {
10515       n[1].e = texunit;
10516       n[2].e = target;
10517       n[3].i = level;
10518       n[4].i = xoffset;
10519       n[5].i = yoffset;
10520       n[6].i = zoffset;
10521       n[7].i = x;
10522       n[8].i = y;
10523       n[9].i = width;
10524       n[10].i = height;
10525    }
10526    if (ctx->ExecuteFlag) {
10527       CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (texunit, target, level,
10528                                                 xoffset, yoffset, zoffset,
10529                                                 x, y, width, height));
10530    }
10531 }
10532 
10533 
10534 static void GLAPIENTRY
save_MultiTexEnvfvEXT(GLenum texunit,GLenum target,GLenum pname,const GLfloat * params)10535 save_MultiTexEnvfvEXT(GLenum texunit, GLenum target, GLenum pname, const GLfloat *params)
10536 {
10537    GET_CURRENT_CONTEXT(ctx);
10538    Node *n;
10539    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10540    n = alloc_instruction(ctx, OPCODE_MULTITEXENV, 7);
10541    if (n) {
10542       n[1].e = texunit;
10543       n[2].e = target;
10544       n[3].e = pname;
10545       if (pname == GL_TEXTURE_ENV_COLOR) {
10546          n[4].f = params[0];
10547          n[5].f = params[1];
10548          n[6].f = params[2];
10549          n[7].f = params[3];
10550       }
10551       else {
10552          n[4].f = params[0];
10553          n[5].f = n[6].f = n[7].f = 0.0F;
10554       }
10555    }
10556    if (ctx->ExecuteFlag) {
10557       CALL_MultiTexEnvfvEXT(ctx->Exec, (texunit, target, pname, params));
10558    }
10559 }
10560 
10561 
10562 static void GLAPIENTRY
save_MultiTexEnvfEXT(GLenum texunit,GLenum target,GLenum pname,GLfloat param)10563 save_MultiTexEnvfEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat param)
10564 {
10565    GLfloat parray[4];
10566    parray[0] = (GLfloat) param;
10567    parray[1] = parray[2] = parray[3] = 0.0F;
10568    save_MultiTexEnvfvEXT(texunit, target, pname, parray);
10569 }
10570 
10571 
10572 static void GLAPIENTRY
save_MultiTexEnviEXT(GLenum texunit,GLenum target,GLenum pname,GLint param)10573 save_MultiTexEnviEXT(GLenum texunit, GLenum target, GLenum pname, GLint param)
10574 {
10575    GLfloat p[4];
10576    p[0] = (GLfloat) param;
10577    p[1] = p[2] = p[3] = 0.0F;
10578    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10579 }
10580 
10581 
10582 static void GLAPIENTRY
save_MultiTexEnvivEXT(GLenum texunit,GLenum target,GLenum pname,const GLint * param)10583 save_MultiTexEnvivEXT(GLenum texunit, GLenum target, GLenum pname, const GLint * param)
10584 {
10585    GLfloat p[4];
10586    if (pname == GL_TEXTURE_ENV_COLOR) {
10587       p[0] = INT_TO_FLOAT(param[0]);
10588       p[1] = INT_TO_FLOAT(param[1]);
10589       p[2] = INT_TO_FLOAT(param[2]);
10590       p[3] = INT_TO_FLOAT(param[3]);
10591    }
10592    else {
10593       p[0] = (GLfloat) param[0];
10594       p[1] = p[2] = p[3] = 0.0F;
10595    }
10596    save_MultiTexEnvfvEXT(texunit, target, pname, p);
10597 }
10598 
10599 
10600 static void GLAPIENTRY
save_CompressedTextureImage1DEXT(GLuint texture,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)10601 save_CompressedTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
10602                                  GLenum internalFormat, GLsizei width,
10603                                  GLint border, GLsizei imageSize,
10604                                  const GLvoid * data)
10605 {
10606    GET_CURRENT_CONTEXT(ctx);
10607    if (target == GL_PROXY_TEXTURE_1D) {
10608       /* don't compile, execute immediately */
10609       CALL_CompressedTextureImage1DEXT(ctx->Exec, (texture, target, level,
10610                                                    internalFormat, width,
10611                                                    border, imageSize,
10612                                                    data));
10613    }
10614    else {
10615       Node *n;
10616       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10617 
10618       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_1D,
10619                             7 + POINTER_DWORDS);
10620       if (n) {
10621          n[1].ui = texture;
10622          n[2].e = target;
10623          n[3].i = level;
10624          n[4].e = internalFormat;
10625          n[5].i = (GLint) width;
10626          n[6].i = border;
10627          n[7].i = imageSize;
10628          save_pointer(&n[8],
10629                       copy_data(data, imageSize, "glCompressedTextureImage1DEXT"));
10630       }
10631       if (ctx->ExecuteFlag) {
10632          CALL_CompressedTextureImage1DEXT(ctx->Exec,
10633                                           (texture, target, level, internalFormat,
10634                                            width, border, imageSize, data));
10635       }
10636    }
10637 }
10638 
10639 
10640 static void GLAPIENTRY
save_CompressedTextureImage2DEXT(GLuint texture,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)10641 save_CompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
10642                                  GLenum internalFormat, GLsizei width,
10643                                  GLsizei height, GLint border, GLsizei imageSize,
10644                                  const GLvoid * data)
10645 {
10646    GET_CURRENT_CONTEXT(ctx);
10647    if (target == GL_PROXY_TEXTURE_2D) {
10648       /* don't compile, execute immediately */
10649       CALL_CompressedTextureImage2DEXT(ctx->Exec, (texture, target, level,
10650                                                    internalFormat, width, height,
10651                                                    border, imageSize, data));
10652    }
10653    else {
10654       Node *n;
10655       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10656 
10657       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_2D,
10658                             8 + POINTER_DWORDS);
10659       if (n) {
10660          n[1].ui = texture;
10661          n[2].e = target;
10662          n[3].i = level;
10663          n[4].e = internalFormat;
10664          n[5].i = (GLint) width;
10665          n[6].i = (GLint) height;
10666          n[7].i = border;
10667          n[8].i = imageSize;
10668          save_pointer(&n[9],
10669                       copy_data(data, imageSize, "glCompressedTextureImage2DEXT"));
10670       }
10671       if (ctx->ExecuteFlag) {
10672          CALL_CompressedTextureImage2DEXT(ctx->Exec,
10673                                           (texture, target, level, internalFormat,
10674                                            width, height, border, imageSize, data));
10675       }
10676    }
10677 }
10678 
10679 
10680 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)10681 save_CompressedTextureImage3DEXT(GLuint texture, GLenum target, GLint level,
10682                                  GLenum internalFormat, GLsizei width,
10683                                  GLsizei height, GLsizei depth, GLint border,
10684                                  GLsizei imageSize, const GLvoid * data)
10685 {
10686    GET_CURRENT_CONTEXT(ctx);
10687    if (target == GL_PROXY_TEXTURE_3D) {
10688       /* don't compile, execute immediately */
10689       CALL_CompressedTextureImage3DEXT(ctx->Exec, (texture, target, level,
10690                                                    internalFormat, width,
10691                                                    height, depth, border,
10692                                                    imageSize, data));
10693    }
10694    else {
10695       Node *n;
10696       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10697 
10698       n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_IMAGE_3D,
10699                             9 + POINTER_DWORDS);
10700       if (n) {
10701          n[1].ui = texture;
10702          n[2].e = target;
10703          n[3].i = level;
10704          n[4].e = internalFormat;
10705          n[5].i = (GLint) width;
10706          n[6].i = (GLint) height;
10707          n[7].i = (GLint) depth;
10708          n[8].i = border;
10709          n[9].i = imageSize;
10710          save_pointer(&n[10],
10711                       copy_data(data, imageSize, "glCompressedTextureImage3DEXT"));
10712       }
10713       if (ctx->ExecuteFlag) {
10714          CALL_CompressedTextureImage3DEXT(ctx->Exec,
10715                                           (texture, target, level, internalFormat,
10716                                            width, height, depth, border, imageSize,
10717                                            data));
10718       }
10719    }
10720 }
10721 
10722 
10723 static void GLAPIENTRY
save_CompressedTextureSubImage1DEXT(GLuint texture,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)10724 save_CompressedTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10725                                     GLsizei width, GLenum format,
10726                                     GLsizei imageSize, const GLvoid * data)
10727 {
10728    Node *n;
10729    GET_CURRENT_CONTEXT(ctx);
10730    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10731 
10732    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D,
10733                          7 + POINTER_DWORDS);
10734    if (n) {
10735       n[1].ui = texture;
10736       n[2].e = target;
10737       n[3].i = level;
10738       n[4].i = xoffset;
10739       n[5].i = (GLint) width;
10740       n[6].e = format;
10741       n[7].i = imageSize;
10742       save_pointer(&n[8],
10743                    copy_data(data, imageSize, "glCompressedTextureSubImage1DEXT"));
10744    }
10745    if (ctx->ExecuteFlag) {
10746       CALL_CompressedTextureSubImage1DEXT(ctx->Exec, (texture, target, level, xoffset,
10747                                                       width, format, imageSize, data));
10748    }
10749 }
10750 
10751 
10752 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)10753 save_CompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10754                                     GLint yoffset, GLsizei width, GLsizei height,
10755                                     GLenum format, GLsizei imageSize,
10756                                     const GLvoid * data)
10757 {
10758    Node *n;
10759    GET_CURRENT_CONTEXT(ctx);
10760    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10761 
10762    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D,
10763                          9 + POINTER_DWORDS);
10764    if (n) {
10765       n[1].ui = texture;
10766       n[2].e = target;
10767       n[3].i = level;
10768       n[4].i = xoffset;
10769       n[5].i = yoffset;
10770       n[6].i = (GLint) width;
10771       n[7].i = (GLint) height;
10772       n[8].e = format;
10773       n[9].i = imageSize;
10774       save_pointer(&n[10],
10775                    copy_data(data, imageSize, "glCompressedTextureSubImage2DEXT"));
10776    }
10777    if (ctx->ExecuteFlag) {
10778       CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
10779                                           (texture, target, level, xoffset, yoffset,
10780                                            width, height, format, imageSize, data));
10781    }
10782 }
10783 
10784 
10785 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)10786 save_CompressedTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
10787                                     GLint yoffset, GLint zoffset, GLsizei width,
10788                                     GLsizei height, GLsizei depth, GLenum format,
10789                                     GLsizei imageSize, const GLvoid * data)
10790 {
10791    Node *n;
10792    GET_CURRENT_CONTEXT(ctx);
10793    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10794 
10795    n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D,
10796                          11 + POINTER_DWORDS);
10797    if (n) {
10798       n[1].ui = texture;
10799       n[2].e = target;
10800       n[3].i = level;
10801       n[4].i = xoffset;
10802       n[5].i = yoffset;
10803       n[6].i = zoffset;
10804       n[7].i = (GLint) width;
10805       n[8].i = (GLint) height;
10806       n[9].i = (GLint) depth;
10807       n[10].e = format;
10808       n[11].i = imageSize;
10809       save_pointer(&n[12],
10810                    copy_data(data, imageSize, "glCompressedTextureSubImage3DEXT"));
10811    }
10812    if (ctx->ExecuteFlag) {
10813       CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
10814                                           (texture, target, level, xoffset, yoffset,
10815                                            zoffset, width, height, depth, format,
10816                                            imageSize, data));
10817    }
10818 }
10819 
10820 
10821 static void GLAPIENTRY
save_CompressedMultiTexImage1DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLint border,GLsizei imageSize,const GLvoid * data)10822 save_CompressedMultiTexImage1DEXT(GLenum texunit, GLenum target, GLint level,
10823                                   GLenum internalFormat, GLsizei width,
10824                                   GLint border, GLsizei imageSize,
10825                                   const GLvoid * data)
10826 {
10827    GET_CURRENT_CONTEXT(ctx);
10828    if (target == GL_PROXY_TEXTURE_1D) {
10829       /* don't compile, execute immediately */
10830       CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (texunit, target, level,
10831                                                    internalFormat, width,
10832                                                    border, imageSize,
10833                                                    data));
10834    }
10835    else {
10836       Node *n;
10837       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10838 
10839       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_1D,
10840                             7 + POINTER_DWORDS);
10841       if (n) {
10842          n[1].e = texunit;
10843          n[2].e = target;
10844          n[3].i = level;
10845          n[4].e = internalFormat;
10846          n[5].i = (GLint) width;
10847          n[6].i = border;
10848          n[7].i = imageSize;
10849          save_pointer(&n[8],
10850                       copy_data(data, imageSize, "glCompressedMultiTexImage1DEXT"));
10851       }
10852       if (ctx->ExecuteFlag) {
10853          CALL_CompressedMultiTexImage1DEXT(ctx->Exec,
10854                                            (texunit, target, level, internalFormat,
10855                                             width, border, imageSize, data));
10856       }
10857    }
10858 }
10859 
10860 
10861 static void GLAPIENTRY
save_CompressedMultiTexImage2DEXT(GLenum texunit,GLenum target,GLint level,GLenum internalFormat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const GLvoid * data)10862 save_CompressedMultiTexImage2DEXT(GLenum texunit, GLenum target, GLint level,
10863                                   GLenum internalFormat, GLsizei width,
10864                                   GLsizei height, GLint border, GLsizei imageSize,
10865                                   const GLvoid * data)
10866 {
10867    GET_CURRENT_CONTEXT(ctx);
10868    if (target == GL_PROXY_TEXTURE_2D) {
10869       /* don't compile, execute immediately */
10870       CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (texunit, target, level,
10871                                                    internalFormat, width, height,
10872                                                    border, imageSize, data));
10873    }
10874    else {
10875       Node *n;
10876       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10877 
10878       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_2D,
10879                             8 + POINTER_DWORDS);
10880       if (n) {
10881          n[1].e = texunit;
10882          n[2].e = target;
10883          n[3].i = level;
10884          n[4].e = internalFormat;
10885          n[5].i = (GLint) width;
10886          n[6].i = (GLint) height;
10887          n[7].i = border;
10888          n[8].i = imageSize;
10889          save_pointer(&n[9],
10890                       copy_data(data, imageSize, "glCompressedMultiTexImage2DEXT"));
10891       }
10892       if (ctx->ExecuteFlag) {
10893          CALL_CompressedMultiTexImage2DEXT(ctx->Exec,
10894                                            (texunit, target, level, internalFormat,
10895                                             width, height, border, imageSize, data));
10896       }
10897    }
10898 }
10899 
10900 
10901 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)10902 save_CompressedMultiTexImage3DEXT(GLenum texunit, GLenum target, GLint level,
10903                                   GLenum internalFormat, GLsizei width,
10904                                   GLsizei height, GLsizei depth, GLint border,
10905                                   GLsizei imageSize, const GLvoid * data)
10906 {
10907    GET_CURRENT_CONTEXT(ctx);
10908    if (target == GL_PROXY_TEXTURE_3D) {
10909       /* don't compile, execute immediately */
10910       CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (texunit, target, level,
10911                                                    internalFormat, width,
10912                                                    height, depth, border,
10913                                                    imageSize, data));
10914    }
10915    else {
10916       Node *n;
10917       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10918 
10919       n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_IMAGE_3D,
10920                             9 + POINTER_DWORDS);
10921       if (n) {
10922          n[1].e = texunit;
10923          n[2].e = target;
10924          n[3].i = level;
10925          n[4].e = internalFormat;
10926          n[5].i = (GLint) width;
10927          n[6].i = (GLint) height;
10928          n[7].i = (GLint) depth;
10929          n[8].i = border;
10930          n[9].i = imageSize;
10931          save_pointer(&n[10],
10932                       copy_data(data, imageSize, "glCompressedMultiTexImage3DEXT"));
10933       }
10934       if (ctx->ExecuteFlag) {
10935          CALL_CompressedMultiTexImage3DEXT(ctx->Exec,
10936                                            (texunit, target, level, internalFormat,
10937                                             width, height, depth, border, imageSize,
10938                                             data));
10939       }
10940    }
10941 }
10942 
10943 
10944 static void GLAPIENTRY
save_CompressedMultiTexSubImage1DEXT(GLenum texunit,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLsizei imageSize,const GLvoid * data)10945 save_CompressedMultiTexSubImage1DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10946                                      GLsizei width, GLenum format,
10947                                      GLsizei imageSize, const GLvoid * data)
10948 {
10949    Node *n;
10950    GET_CURRENT_CONTEXT(ctx);
10951    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10952 
10953    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D,
10954                          7 + POINTER_DWORDS);
10955    if (n) {
10956       n[1].e = texunit;
10957       n[2].e = target;
10958       n[3].i = level;
10959       n[4].i = xoffset;
10960       n[5].i = (GLint) width;
10961       n[6].e = format;
10962       n[7].i = imageSize;
10963       save_pointer(&n[8],
10964                    copy_data(data, imageSize, "glCompressedMultiTexSubImage1DEXT"));
10965    }
10966    if (ctx->ExecuteFlag) {
10967       CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec, (texunit, target, level, xoffset,
10968                                                        width, format, imageSize, data));
10969    }
10970 }
10971 
10972 
10973 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)10974 save_CompressedMultiTexSubImage2DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
10975                                      GLint yoffset, GLsizei width, GLsizei height,
10976                                      GLenum format, GLsizei imageSize,
10977                                      const GLvoid * data)
10978 {
10979    Node *n;
10980    GET_CURRENT_CONTEXT(ctx);
10981    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
10982 
10983    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D,
10984                          9 + POINTER_DWORDS);
10985    if (n) {
10986       n[1].e = texunit;
10987       n[2].e = target;
10988       n[3].i = level;
10989       n[4].i = xoffset;
10990       n[5].i = yoffset;
10991       n[6].i = (GLint) width;
10992       n[7].i = (GLint) height;
10993       n[8].e = format;
10994       n[9].i = imageSize;
10995       save_pointer(&n[10],
10996                    copy_data(data, imageSize, "glCompressedMultiTexSubImage2DEXT"));
10997    }
10998    if (ctx->ExecuteFlag) {
10999       CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
11000                                            (texunit, target, level, xoffset, yoffset,
11001                                             width, height, format, imageSize, data));
11002    }
11003 }
11004 
11005 
11006 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)11007 save_CompressedMultiTexSubImage3DEXT(GLenum texunit, GLenum target, GLint level, GLint xoffset,
11008                                      GLint yoffset, GLint zoffset, GLsizei width,
11009                                      GLsizei height, GLsizei depth, GLenum format,
11010                                      GLsizei imageSize, const GLvoid * data)
11011 {
11012    Node *n;
11013    GET_CURRENT_CONTEXT(ctx);
11014    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11015 
11016    n = alloc_instruction(ctx, OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D,
11017                          11 + POINTER_DWORDS);
11018    if (n) {
11019       n[1].e = texunit;
11020       n[2].e = target;
11021       n[3].i = level;
11022       n[4].i = xoffset;
11023       n[5].i = yoffset;
11024       n[6].i = zoffset;
11025       n[7].i = (GLint) width;
11026       n[8].i = (GLint) height;
11027       n[9].i = (GLint) depth;
11028       n[10].e = format;
11029       n[11].i = imageSize;
11030       save_pointer(&n[12],
11031                    copy_data(data, imageSize, "glCompressedMultiTexSubImage3DEXT"));
11032    }
11033    if (ctx->ExecuteFlag) {
11034       CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
11035                                            (texunit, target, level, xoffset, yoffset,
11036                                             zoffset, width, height, depth, format,
11037                                             imageSize, data));
11038    }
11039 }
11040 
11041 
11042 static void GLAPIENTRY
save_NamedProgramStringEXT(GLuint program,GLenum target,GLenum format,GLsizei len,const GLvoid * string)11043 save_NamedProgramStringEXT(GLuint program, GLenum target, GLenum format, GLsizei len,
11044                            const GLvoid * string)
11045 {
11046    GET_CURRENT_CONTEXT(ctx);
11047    Node *n;
11048 
11049    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11050 
11051    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_STRING, 4 + POINTER_DWORDS);
11052    if (n) {
11053       GLubyte *programCopy = malloc(len);
11054       if (!programCopy) {
11055          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNamedProgramStringEXT");
11056          return;
11057       }
11058       memcpy(programCopy, string, len);
11059       n[1].ui = program;
11060       n[2].e = target;
11061       n[3].e = format;
11062       n[4].i = len;
11063       save_pointer(&n[5], programCopy);
11064    }
11065    if (ctx->ExecuteFlag) {
11066       CALL_NamedProgramStringEXT(ctx->Exec, (program, target, format, len, string));
11067    }
11068 }
11069 
11070 
11071 static void GLAPIENTRY
save_NamedProgramLocalParameter4fEXT(GLuint program,GLenum target,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)11072 save_NamedProgramLocalParameter4fEXT(GLuint program, GLenum target, GLuint index,
11073                                      GLfloat x, GLfloat y, GLfloat z, GLfloat w)
11074 {
11075    GET_CURRENT_CONTEXT(ctx);
11076    Node *n;
11077    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11078    n = alloc_instruction(ctx, OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER, 7);
11079    if (n) {
11080       n[1].ui = program;
11081       n[2].e = target;
11082       n[3].ui = index;
11083       n[4].f = x;
11084       n[5].f = y;
11085       n[6].f = z;
11086       n[7].f = w;
11087    }
11088    if (ctx->ExecuteFlag) {
11089       CALL_NamedProgramLocalParameter4fEXT(ctx->Exec, (program, target, index, x, y, z, w));
11090    }
11091 }
11092 
11093 
11094 static void GLAPIENTRY
save_NamedProgramLocalParameter4fvEXT(GLuint program,GLenum target,GLuint index,const GLfloat * params)11095 save_NamedProgramLocalParameter4fvEXT(GLuint program, GLenum target, GLuint index,
11096                                       const GLfloat *params)
11097 {
11098    save_NamedProgramLocalParameter4fEXT(program, target, index, params[0],
11099                                         params[1], params[2], params[3]);
11100 }
11101 
11102 
11103 static void GLAPIENTRY
save_NamedProgramLocalParameter4dEXT(GLuint program,GLenum target,GLuint index,GLdouble x,GLdouble y,GLdouble z,GLdouble w)11104 save_NamedProgramLocalParameter4dEXT(GLuint program, GLenum target, GLuint index,
11105                                     GLdouble x, GLdouble y,
11106                                     GLdouble z, GLdouble w)
11107 {
11108       save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) x,
11109                                            (GLfloat) y, (GLfloat) z, (GLfloat) w);
11110 }
11111 
11112 
11113 static void GLAPIENTRY
save_NamedProgramLocalParameter4dvEXT(GLuint program,GLenum target,GLuint index,const GLdouble * params)11114 save_NamedProgramLocalParameter4dvEXT(GLuint program, GLenum target, GLuint index,
11115                                       const GLdouble *params)
11116 {
11117    save_NamedProgramLocalParameter4fEXT(program, target, index, (GLfloat) params[0],
11118                                         (GLfloat) params[1], (GLfloat) params[2],
11119                                         (GLfloat) params[3]);
11120 }
11121 
11122 static void GLAPIENTRY
save_PrimitiveBoundingBox(float minX,float minY,float minZ,float minW,float maxX,float maxY,float maxZ,float maxW)11123 save_PrimitiveBoundingBox(float minX, float minY, float minZ, float minW,
11124                           float maxX, float maxY, float maxZ, float maxW)
11125 {
11126    GET_CURRENT_CONTEXT(ctx);
11127    Node *n;
11128    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
11129    n = alloc_instruction(ctx, OPCODE_PRIMITIVE_BOUNDING_BOX, 8);
11130    if (n) {
11131       n[1].f = minX;
11132       n[2].f = minY;
11133       n[3].f = minZ;
11134       n[4].f = minW;
11135       n[5].f = maxX;
11136       n[6].f = maxY;
11137       n[7].f = maxZ;
11138       n[8].f = maxW;
11139    }
11140    if (ctx->ExecuteFlag) {
11141       CALL_PrimitiveBoundingBox(ctx->Exec, (minX, minY, minZ, minW,
11142                                             maxX, maxY, maxZ, maxW));
11143    }
11144 }
11145 
11146 /**
11147  * Save an error-generating command into display list.
11148  *
11149  * KW: Will appear in the list before the vertex buffer containing the
11150  * command that provoked the error.  I don't see this as a problem.
11151  */
11152 static void
save_error(struct gl_context * ctx,GLenum error,const char * s)11153 save_error(struct gl_context *ctx, GLenum error, const char *s)
11154 {
11155    Node *n;
11156    n = alloc_instruction(ctx, OPCODE_ERROR, 1 + POINTER_DWORDS);
11157    if (n) {
11158       n[1].e = error;
11159       save_pointer(&n[2], (void *) s);
11160       /* note: the data/string here doesn't have to be freed in
11161        * _mesa_delete_list() since the string is never dynamically
11162        * allocated.
11163        */
11164    }
11165 }
11166 
11167 
11168 /**
11169  * Compile an error into current display list.
11170  */
11171 void
_mesa_compile_error(struct gl_context * ctx,GLenum error,const char * s)11172 _mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s)
11173 {
11174    if (ctx->CompileFlag)
11175       save_error(ctx, error, s);
11176    if (ctx->ExecuteFlag)
11177       _mesa_error(ctx, error, "%s", s);
11178 }
11179 
11180 
11181 /**
11182  * Test if ID names a display list.
11183  */
11184 bool
_mesa_get_list(struct gl_context * ctx,GLuint list,struct gl_display_list ** dlist,bool locked)11185 _mesa_get_list(struct gl_context *ctx, GLuint list,
11186                struct gl_display_list **dlist,
11187                bool locked)
11188 {
11189    struct gl_display_list * dl =
11190       list > 0 ? _mesa_lookup_list(ctx, list, locked) : NULL;
11191 
11192    if (dlist)
11193       *dlist = dl;
11194 
11195    return dl != NULL;
11196 }
11197 
11198 
11199 
11200 /**********************************************************************/
11201 /*                     Display list execution                         */
11202 /**********************************************************************/
11203 
11204 
11205 /*
11206  * Execute a display list.  Note that the ListBase offset must have already
11207  * been added before calling this function.  I.e. the list argument is
11208  * the absolute list number, not relative to ListBase.
11209  * Must be called with ctx->Shared->DisplayList locked.
11210  * \param list - display list number
11211  */
11212 static void
execute_list(struct gl_context * ctx,GLuint list)11213 execute_list(struct gl_context *ctx, GLuint list)
11214 {
11215    struct gl_display_list *dlist;
11216    Node *n;
11217 
11218    if (list == 0 || !_mesa_get_list(ctx, list, &dlist, true))
11219       return;
11220 
11221    n = get_list_head(ctx, dlist);
11222 
11223    while (1) {
11224       const OpCode opcode = n[0].opcode;
11225 
11226       switch (opcode) {
11227          case OPCODE_ERROR:
11228             _mesa_error(ctx, n[1].e, "%s", (const char *) get_pointer(&n[2]));
11229             break;
11230          case OPCODE_ACCUM:
11231             CALL_Accum(ctx->Exec, (n[1].e, n[2].f));
11232             break;
11233          case OPCODE_ALPHA_FUNC:
11234             CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f));
11235             break;
11236          case OPCODE_BIND_TEXTURE:
11237             CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui));
11238             break;
11239          case OPCODE_BITMAP:
11240             {
11241                const struct gl_pixelstore_attrib save = ctx->Unpack;
11242                ctx->Unpack = ctx->DefaultPacking;
11243                CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i,
11244                                        n[3].f, n[4].f, n[5].f, n[6].f,
11245                                        get_pointer(&n[7])));
11246                ctx->Unpack = save;      /* restore */
11247             }
11248             break;
11249          case OPCODE_BLEND_COLOR:
11250             CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11251             break;
11252          case OPCODE_BLEND_EQUATION:
11253             CALL_BlendEquation(ctx->Exec, (n[1].e));
11254             break;
11255          case OPCODE_BLEND_EQUATION_SEPARATE:
11256             CALL_BlendEquationSeparate(ctx->Exec, (n[1].e, n[2].e));
11257             break;
11258          case OPCODE_BLEND_FUNC_SEPARATE:
11259             CALL_BlendFuncSeparate(ctx->Exec,
11260                                       (n[1].e, n[2].e, n[3].e, n[4].e));
11261             break;
11262 
11263          case OPCODE_BLEND_FUNC_I:
11264             /* GL_ARB_draw_buffers_blend */
11265             CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e));
11266             break;
11267          case OPCODE_BLEND_FUNC_SEPARATE_I:
11268             /* GL_ARB_draw_buffers_blend */
11269             CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e,
11270                                                    n[4].e, n[5].e));
11271             break;
11272          case OPCODE_BLEND_EQUATION_I:
11273             /* GL_ARB_draw_buffers_blend */
11274             CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e));
11275             break;
11276          case OPCODE_BLEND_EQUATION_SEPARATE_I:
11277             /* GL_ARB_draw_buffers_blend */
11278             CALL_BlendEquationSeparateiARB(ctx->Exec,
11279                                            (n[1].ui, n[2].e, n[3].e));
11280             break;
11281 
11282          case OPCODE_CALL_LIST:
11283             /* Generated by glCallList(), don't add ListBase */
11284             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
11285                ctx->ListState.CallDepth++;
11286                execute_list(ctx, n[1].ui);
11287                ctx->ListState.CallDepth--;
11288             }
11289             break;
11290          case OPCODE_CALL_LISTS:
11291             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
11292                ctx->ListState.CallDepth++;
11293                _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
11294                CALL_CallLists(ctx->Exec, (n[1].i, n[2].e, get_pointer(&n[3])));
11295                _mesa_HashLockMutex(ctx->Shared->DisplayList);
11296                ctx->ListState.CallDepth--;
11297             }
11298             break;
11299          case OPCODE_CLEAR:
11300             CALL_Clear(ctx->Exec, (n[1].bf));
11301             break;
11302          case OPCODE_CLEAR_BUFFER_IV:
11303             {
11304                GLint value[4];
11305                value[0] = n[3].i;
11306                value[1] = n[4].i;
11307                value[2] = n[5].i;
11308                value[3] = n[6].i;
11309                CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));
11310             }
11311             break;
11312          case OPCODE_CLEAR_BUFFER_UIV:
11313             {
11314                GLuint value[4];
11315                value[0] = n[3].ui;
11316                value[1] = n[4].ui;
11317                value[2] = n[5].ui;
11318                value[3] = n[6].ui;
11319                CALL_ClearBufferuiv(ctx->Exec, (n[1].e, n[2].i, value));
11320             }
11321             break;
11322          case OPCODE_CLEAR_BUFFER_FV:
11323             {
11324                GLfloat value[4];
11325                value[0] = n[3].f;
11326                value[1] = n[4].f;
11327                value[2] = n[5].f;
11328                value[3] = n[6].f;
11329                CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));
11330             }
11331             break;
11332          case OPCODE_CLEAR_BUFFER_FI:
11333             CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));
11334             break;
11335          case OPCODE_CLEAR_COLOR:
11336             CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11337             break;
11338          case OPCODE_CLEAR_ACCUM:
11339             CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11340             break;
11341          case OPCODE_CLEAR_DEPTH:
11342             CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f));
11343             break;
11344          case OPCODE_CLEAR_INDEX:
11345             CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui));
11346             break;
11347          case OPCODE_CLEAR_STENCIL:
11348             CALL_ClearStencil(ctx->Exec, (n[1].i));
11349             break;
11350          case OPCODE_CLIP_PLANE:
11351             {
11352                GLdouble eq[4];
11353                eq[0] = n[2].f;
11354                eq[1] = n[3].f;
11355                eq[2] = n[4].f;
11356                eq[3] = n[5].f;
11357                CALL_ClipPlane(ctx->Exec, (n[1].e, eq));
11358             }
11359             break;
11360          case OPCODE_COLOR_MASK:
11361             CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b));
11362             break;
11363          case OPCODE_COLOR_MASK_INDEXED:
11364             CALL_ColorMaski(ctx->Exec, (n[1].ui, n[2].b, n[3].b,
11365                                                  n[4].b, n[5].b));
11366             break;
11367          case OPCODE_COLOR_MATERIAL:
11368             CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e));
11369             break;
11370          case OPCODE_COPY_PIXELS:
11371             CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i,
11372                                         (GLsizei) n[3].i, (GLsizei) n[4].i,
11373                                         n[5].e));
11374             break;
11375          case OPCODE_COPY_TEX_IMAGE1D:
11376             CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11377                                             n[5].i, n[6].i, n[7].i));
11378             break;
11379          case OPCODE_COPY_TEX_IMAGE2D:
11380             CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i,
11381                                             n[5].i, n[6].i, n[7].i, n[8].i));
11382             break;
11383          case OPCODE_COPY_TEX_SUB_IMAGE1D:
11384             CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11385                                                n[4].i, n[5].i, n[6].i));
11386             break;
11387          case OPCODE_COPY_TEX_SUB_IMAGE2D:
11388             CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11389                                                n[4].i, n[5].i, n[6].i, n[7].i,
11390                                                n[8].i));
11391             break;
11392          case OPCODE_COPY_TEX_SUB_IMAGE3D:
11393             CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11394                                                n[4].i, n[5].i, n[6].i, n[7].i,
11395                                                n[8].i, n[9].i));
11396             break;
11397          case OPCODE_CULL_FACE:
11398             CALL_CullFace(ctx->Exec, (n[1].e));
11399             break;
11400          case OPCODE_DEPTH_FUNC:
11401             CALL_DepthFunc(ctx->Exec, (n[1].e));
11402             break;
11403          case OPCODE_DEPTH_MASK:
11404             CALL_DepthMask(ctx->Exec, (n[1].b));
11405             break;
11406          case OPCODE_DEPTH_RANGE:
11407             CALL_DepthRange(ctx->Exec,
11408                             ((GLclampd) n[1].f, (GLclampd) n[2].f));
11409             break;
11410          case OPCODE_DISABLE:
11411             CALL_Disable(ctx->Exec, (n[1].e));
11412             break;
11413          case OPCODE_DISABLE_INDEXED:
11414             CALL_Disablei(ctx->Exec, (n[1].ui, n[2].e));
11415             break;
11416          case OPCODE_DRAW_BUFFER:
11417             CALL_DrawBuffer(ctx->Exec, (n[1].e));
11418             break;
11419          case OPCODE_DRAW_PIXELS:
11420             {
11421                const struct gl_pixelstore_attrib save = ctx->Unpack;
11422                ctx->Unpack = ctx->DefaultPacking;
11423                CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e,
11424                                            get_pointer(&n[5])));
11425                ctx->Unpack = save;      /* restore */
11426             }
11427             break;
11428          case OPCODE_ENABLE:
11429             CALL_Enable(ctx->Exec, (n[1].e));
11430             break;
11431          case OPCODE_ENABLE_INDEXED:
11432             CALL_Enablei(ctx->Exec, (n[1].ui, n[2].e));
11433             break;
11434          case OPCODE_EVALMESH1:
11435             CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i));
11436             break;
11437          case OPCODE_EVALMESH2:
11438             CALL_EvalMesh2(ctx->Exec,
11439                            (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i));
11440             break;
11441          case OPCODE_FOG:
11442             {
11443                GLfloat p[4];
11444                p[0] = n[2].f;
11445                p[1] = n[3].f;
11446                p[2] = n[4].f;
11447                p[3] = n[5].f;
11448                CALL_Fogfv(ctx->Exec, (n[1].e, p));
11449             }
11450             break;
11451          case OPCODE_FRONT_FACE:
11452             CALL_FrontFace(ctx->Exec, (n[1].e));
11453             break;
11454          case OPCODE_FRUSTUM:
11455             CALL_Frustum(ctx->Exec,
11456                          (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11457             break;
11458          case OPCODE_HINT:
11459             CALL_Hint(ctx->Exec, (n[1].e, n[2].e));
11460             break;
11461          case OPCODE_INDEX_MASK:
11462             CALL_IndexMask(ctx->Exec, (n[1].ui));
11463             break;
11464          case OPCODE_INIT_NAMES:
11465             CALL_InitNames(ctx->Exec, ());
11466             break;
11467          case OPCODE_LIGHT:
11468             {
11469                GLfloat p[4];
11470                p[0] = n[3].f;
11471                p[1] = n[4].f;
11472                p[2] = n[5].f;
11473                p[3] = n[6].f;
11474                CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p));
11475             }
11476             break;
11477          case OPCODE_LIGHT_MODEL:
11478             {
11479                GLfloat p[4];
11480                p[0] = n[2].f;
11481                p[1] = n[3].f;
11482                p[2] = n[4].f;
11483                p[3] = n[5].f;
11484                CALL_LightModelfv(ctx->Exec, (n[1].e, p));
11485             }
11486             break;
11487          case OPCODE_LINE_STIPPLE:
11488             CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us));
11489             break;
11490          case OPCODE_LINE_WIDTH:
11491             CALL_LineWidth(ctx->Exec, (n[1].f));
11492             break;
11493          case OPCODE_LIST_BASE:
11494             CALL_ListBase(ctx->Exec, (n[1].ui));
11495             break;
11496          case OPCODE_LOAD_IDENTITY:
11497             CALL_LoadIdentity(ctx->Exec, ());
11498             break;
11499          case OPCODE_LOAD_MATRIX:
11500             STATIC_ASSERT(sizeof(Node) == sizeof(GLfloat));
11501             CALL_LoadMatrixf(ctx->Exec, (&n[1].f));
11502             break;
11503          case OPCODE_LOAD_NAME:
11504             CALL_LoadName(ctx->Exec, (n[1].ui));
11505             break;
11506          case OPCODE_LOGIC_OP:
11507             CALL_LogicOp(ctx->Exec, (n[1].e));
11508             break;
11509          case OPCODE_MAP1:
11510             {
11511                GLenum target = n[1].e;
11512                GLint ustride = _mesa_evaluator_components(target);
11513                GLint uorder = n[5].i;
11514                GLfloat u1 = n[2].f;
11515                GLfloat u2 = n[3].f;
11516                CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder,
11517                                       (GLfloat *) get_pointer(&n[6])));
11518             }
11519             break;
11520          case OPCODE_MAP2:
11521             {
11522                GLenum target = n[1].e;
11523                GLfloat u1 = n[2].f;
11524                GLfloat u2 = n[3].f;
11525                GLfloat v1 = n[4].f;
11526                GLfloat v2 = n[5].f;
11527                GLint ustride = n[6].i;
11528                GLint vstride = n[7].i;
11529                GLint uorder = n[8].i;
11530                GLint vorder = n[9].i;
11531                CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder,
11532                                       v1, v2, vstride, vorder,
11533                                       (GLfloat *) get_pointer(&n[10])));
11534             }
11535             break;
11536          case OPCODE_MAPGRID1:
11537             CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
11538             break;
11539          case OPCODE_MAPGRID2:
11540             CALL_MapGrid2f(ctx->Exec,
11541                            (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
11542             break;
11543          case OPCODE_MATRIX_MODE:
11544             CALL_MatrixMode(ctx->Exec, (n[1].e));
11545             break;
11546          case OPCODE_MULT_MATRIX:
11547             CALL_MultMatrixf(ctx->Exec, (&n[1].f));
11548             break;
11549          case OPCODE_ORTHO:
11550             CALL_Ortho(ctx->Exec,
11551                        (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f));
11552             break;
11553          case OPCODE_PASSTHROUGH:
11554             CALL_PassThrough(ctx->Exec, (n[1].f));
11555             break;
11556          case OPCODE_PATCH_PARAMETER_I:
11557             CALL_PatchParameteri(ctx->Exec, (n[1].e, n[2].i));
11558             break;
11559          case OPCODE_PATCH_PARAMETER_FV_INNER:
11560             {
11561                GLfloat params[2];
11562                params[0] = n[2].f;
11563                params[1] = n[3].f;
11564                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11565             }
11566             break;
11567          case OPCODE_PATCH_PARAMETER_FV_OUTER:
11568             {
11569                GLfloat params[4];
11570                params[0] = n[2].f;
11571                params[1] = n[3].f;
11572                params[2] = n[4].f;
11573                params[3] = n[5].f;
11574                CALL_PatchParameterfv(ctx->Exec, (n[1].e, params));
11575             }
11576             break;
11577          case OPCODE_PIXEL_MAP:
11578             CALL_PixelMapfv(ctx->Exec,
11579                             (n[1].e, n[2].i, get_pointer(&n[3])));
11580             break;
11581          case OPCODE_PIXEL_TRANSFER:
11582             CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f));
11583             break;
11584          case OPCODE_PIXEL_ZOOM:
11585             CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f));
11586             break;
11587          case OPCODE_POINT_SIZE:
11588             CALL_PointSize(ctx->Exec, (n[1].f));
11589             break;
11590          case OPCODE_POINT_PARAMETERS:
11591             {
11592                GLfloat params[3];
11593                params[0] = n[2].f;
11594                params[1] = n[3].f;
11595                params[2] = n[4].f;
11596                CALL_PointParameterfv(ctx->Exec, (n[1].e, params));
11597             }
11598             break;
11599          case OPCODE_POLYGON_MODE:
11600             CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
11601             break;
11602          case OPCODE_POLYGON_STIPPLE:
11603             {
11604                const struct gl_pixelstore_attrib save = ctx->Unpack;
11605                ctx->Unpack = ctx->DefaultPacking;
11606                CALL_PolygonStipple(ctx->Exec, (get_pointer(&n[1])));
11607                ctx->Unpack = save;      /* restore */
11608             }
11609             break;
11610          case OPCODE_POLYGON_OFFSET:
11611             CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
11612             break;
11613          case OPCODE_POLYGON_OFFSET_CLAMP:
11614             CALL_PolygonOffsetClampEXT(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11615             break;
11616          case OPCODE_POP_ATTRIB:
11617             CALL_PopAttrib(ctx->Exec, ());
11618             break;
11619          case OPCODE_POP_MATRIX:
11620             CALL_PopMatrix(ctx->Exec, ());
11621             break;
11622          case OPCODE_POP_NAME:
11623             CALL_PopName(ctx->Exec, ());
11624             break;
11625          case OPCODE_PRIORITIZE_TEXTURE:
11626             CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f));
11627             break;
11628          case OPCODE_PUSH_ATTRIB:
11629             CALL_PushAttrib(ctx->Exec, (n[1].bf));
11630             break;
11631          case OPCODE_PUSH_MATRIX:
11632             CALL_PushMatrix(ctx->Exec, ());
11633             break;
11634          case OPCODE_PUSH_NAME:
11635             CALL_PushName(ctx->Exec, (n[1].ui));
11636             break;
11637          case OPCODE_RASTER_POS:
11638             CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11639             break;
11640          case OPCODE_READ_BUFFER:
11641             CALL_ReadBuffer(ctx->Exec, (n[1].e));
11642             break;
11643          case OPCODE_ROTATE:
11644             CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11645             break;
11646          case OPCODE_SCALE:
11647             CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11648             break;
11649          case OPCODE_SCISSOR:
11650             CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
11651             break;
11652          case OPCODE_SHADE_MODEL:
11653             CALL_ShadeModel(ctx->Exec, (n[1].e));
11654             break;
11655          case OPCODE_PROVOKING_VERTEX:
11656             CALL_ProvokingVertex(ctx->Exec, (n[1].e));
11657             break;
11658          case OPCODE_STENCIL_FUNC:
11659             CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui));
11660             break;
11661          case OPCODE_STENCIL_MASK:
11662             CALL_StencilMask(ctx->Exec, (n[1].ui));
11663             break;
11664          case OPCODE_STENCIL_OP:
11665             CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e));
11666             break;
11667          case OPCODE_STENCIL_FUNC_SEPARATE:
11668             CALL_StencilFuncSeparate(ctx->Exec,
11669                                      (n[1].e, n[2].e, n[3].i, n[4].ui));
11670             break;
11671          case OPCODE_STENCIL_MASK_SEPARATE:
11672             CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui));
11673             break;
11674          case OPCODE_STENCIL_OP_SEPARATE:
11675             CALL_StencilOpSeparate(ctx->Exec,
11676                                    (n[1].e, n[2].e, n[3].e, n[4].e));
11677             break;
11678          case OPCODE_TEXENV:
11679             {
11680                GLfloat params[4];
11681                params[0] = n[3].f;
11682                params[1] = n[4].f;
11683                params[2] = n[5].f;
11684                params[3] = n[6].f;
11685                CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params));
11686             }
11687             break;
11688          case OPCODE_TEXGEN:
11689             {
11690                GLfloat params[4];
11691                params[0] = n[3].f;
11692                params[1] = n[4].f;
11693                params[2] = n[5].f;
11694                params[3] = n[6].f;
11695                CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params));
11696             }
11697             break;
11698          case OPCODE_TEXPARAMETER:
11699             {
11700                GLfloat params[4];
11701                params[0] = n[3].f;
11702                params[1] = n[4].f;
11703                params[2] = n[5].f;
11704                params[3] = n[6].f;
11705                CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params));
11706             }
11707             break;
11708          case OPCODE_TEX_IMAGE1D:
11709             {
11710                const struct gl_pixelstore_attrib save = ctx->Unpack;
11711                ctx->Unpack = ctx->DefaultPacking;
11712                CALL_TexImage1D(ctx->Exec, (n[1].e,      /* target */
11713                                            n[2].i,      /* level */
11714                                            n[3].i,      /* components */
11715                                            n[4].i,      /* width */
11716                                            n[5].e,      /* border */
11717                                            n[6].e,      /* format */
11718                                            n[7].e,      /* type */
11719                                            get_pointer(&n[8])));
11720                ctx->Unpack = save;      /* restore */
11721             }
11722             break;
11723          case OPCODE_TEX_IMAGE2D:
11724             {
11725                const struct gl_pixelstore_attrib save = ctx->Unpack;
11726                ctx->Unpack = ctx->DefaultPacking;
11727                CALL_TexImage2D(ctx->Exec, (n[1].e,      /* target */
11728                                            n[2].i,      /* level */
11729                                            n[3].i,      /* components */
11730                                            n[4].i,      /* width */
11731                                            n[5].i,      /* height */
11732                                            n[6].e,      /* border */
11733                                            n[7].e,      /* format */
11734                                            n[8].e,      /* type */
11735                                            get_pointer(&n[9])));
11736                ctx->Unpack = save;      /* restore */
11737             }
11738             break;
11739          case OPCODE_TEX_IMAGE3D:
11740             {
11741                const struct gl_pixelstore_attrib save = ctx->Unpack;
11742                ctx->Unpack = ctx->DefaultPacking;
11743                CALL_TexImage3D(ctx->Exec, (n[1].e,      /* target */
11744                                            n[2].i,      /* level */
11745                                            n[3].i,      /* components */
11746                                            n[4].i,      /* width */
11747                                            n[5].i,      /* height */
11748                                            n[6].i,      /* depth  */
11749                                            n[7].e,      /* border */
11750                                            n[8].e,      /* format */
11751                                            n[9].e,      /* type */
11752                                            get_pointer(&n[10])));
11753                ctx->Unpack = save;      /* restore */
11754             }
11755             break;
11756          case OPCODE_TEX_SUB_IMAGE1D:
11757             {
11758                const struct gl_pixelstore_attrib save = ctx->Unpack;
11759                ctx->Unpack = ctx->DefaultPacking;
11760                CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11761                                               n[4].i, n[5].e,
11762                                               n[6].e, get_pointer(&n[7])));
11763                ctx->Unpack = save;      /* restore */
11764             }
11765             break;
11766          case OPCODE_TEX_SUB_IMAGE2D:
11767             {
11768                const struct gl_pixelstore_attrib save = ctx->Unpack;
11769                ctx->Unpack = ctx->DefaultPacking;
11770                CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11771                                               n[4].i, n[5].e,
11772                                               n[6].i, n[7].e, n[8].e,
11773                                               get_pointer(&n[9])));
11774                ctx->Unpack = save;      /* restore */
11775             }
11776             break;
11777          case OPCODE_TEX_SUB_IMAGE3D:
11778             {
11779                const struct gl_pixelstore_attrib save = ctx->Unpack;
11780                ctx->Unpack = ctx->DefaultPacking;
11781                CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i,
11782                                               n[4].i, n[5].i, n[6].i, n[7].i,
11783                                               n[8].i, n[9].e, n[10].e,
11784                                               get_pointer(&n[11])));
11785                ctx->Unpack = save;      /* restore */
11786             }
11787             break;
11788          case OPCODE_TRANSLATE:
11789             CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11790             break;
11791          case OPCODE_VIEWPORT:
11792             CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
11793                                       (GLsizei) n[3].i, (GLsizei) n[4].i));
11794             break;
11795          case OPCODE_WINDOW_POS:
11796             CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
11797             break;
11798          case OPCODE_VIEWPORT_ARRAY_V:
11799             CALL_ViewportArrayv(ctx->Exec, (n[1].ui, n[2].si,
11800                                             get_pointer(&n[3])));
11801             break;
11802          case OPCODE_VIEWPORT_INDEXED_F:
11803             CALL_ViewportIndexedf(ctx->Exec, (n[1].ui, n[2].f, n[3].f, n[4].f,
11804                                               n[5].f));
11805             break;
11806          case OPCODE_VIEWPORT_INDEXED_FV: {
11807             GLfloat v[4];
11808             v[0] = n[2].f;
11809             v[1] = n[3].f;
11810             v[2] = n[4].f;
11811             v[3] = n[5].f;
11812             CALL_ViewportIndexedfv(ctx->Exec, (n[1].ui, v));
11813             break;
11814          }
11815          case OPCODE_SCISSOR_ARRAY_V:
11816             CALL_ScissorArrayv(ctx->Exec, (n[1].ui, n[2].si,
11817                                            get_pointer(&n[3])));
11818             break;
11819          case OPCODE_SCISSOR_INDEXED:
11820             CALL_ScissorIndexed(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].si,
11821                                             n[5].si));
11822             break;
11823          case OPCODE_SCISSOR_INDEXED_V: {
11824             GLint v[4];
11825             v[0] = n[2].i;
11826             v[1] = n[3].i;
11827             v[2] = n[4].si;
11828             v[3] = n[5].si;
11829             CALL_ScissorIndexedv(ctx->Exec, (n[1].ui, v));
11830             break;
11831          }
11832          case OPCODE_DEPTH_ARRAY_V:
11833             CALL_DepthRangeArrayv(ctx->Exec, (n[1].ui, n[2].si,
11834                                               get_pointer(&n[3])));
11835             break;
11836          case OPCODE_DEPTH_INDEXED:
11837             CALL_DepthRangeIndexed(ctx->Exec, (n[1].ui, n[2].f, n[3].f));
11838             break;
11839          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
11840             CALL_ActiveTexture(ctx->Exec, (n[1].e));
11841             break;
11842          case OPCODE_COMPRESSED_TEX_IMAGE_1D:  /* GL_ARB_texture_compression */
11843             CALL_CompressedTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11844                                                   n[4].i, n[5].i, n[6].i,
11845                                                   get_pointer(&n[7])));
11846             break;
11847          case OPCODE_COMPRESSED_TEX_IMAGE_2D:  /* GL_ARB_texture_compression */
11848             CALL_CompressedTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11849                                                   n[4].i, n[5].i, n[6].i,
11850                                                   n[7].i, get_pointer(&n[8])));
11851             break;
11852          case OPCODE_COMPRESSED_TEX_IMAGE_3D:  /* GL_ARB_texture_compression */
11853             CALL_CompressedTexImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].e,
11854                                                   n[4].i, n[5].i, n[6].i,
11855                                                   n[7].i, n[8].i,
11856                                                   get_pointer(&n[9])));
11857             break;
11858          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:      /* GL_ARB_texture_compress */
11859             CALL_CompressedTexSubImage1D(ctx->Exec,
11860                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11861                                              n[5].e, n[6].i,
11862                                              get_pointer(&n[7])));
11863             break;
11864          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:      /* GL_ARB_texture_compress */
11865             CALL_CompressedTexSubImage2D(ctx->Exec,
11866                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11867                                              n[5].i, n[6].i, n[7].e, n[8].i,
11868                                              get_pointer(&n[9])));
11869             break;
11870          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:      /* GL_ARB_texture_compress */
11871             CALL_CompressedTexSubImage3D(ctx->Exec,
11872                                             (n[1].e, n[2].i, n[3].i, n[4].i,
11873                                              n[5].i, n[6].i, n[7].i, n[8].i,
11874                                              n[9].e, n[10].i,
11875                                              get_pointer(&n[11])));
11876             break;
11877          case OPCODE_SAMPLE_COVERAGE:  /* GL_ARB_multisample */
11878             CALL_SampleCoverage(ctx->Exec, (n[1].f, n[2].b));
11879             break;
11880          case OPCODE_WINDOW_POS_ARB:   /* GL_ARB_window_pos */
11881             CALL_WindowPos3f(ctx->Exec, (n[1].f, n[2].f, n[3].f));
11882             break;
11883          case OPCODE_BIND_PROGRAM_ARB:  /* GL_ARB_vertex_program */
11884             CALL_BindProgramARB(ctx->Exec, (n[1].e, n[2].ui));
11885             break;
11886          case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
11887             CALL_ProgramLocalParameter4fARB(ctx->Exec,
11888                                             (n[1].e, n[2].ui, n[3].f, n[4].f,
11889                                              n[5].f, n[6].f));
11890             break;
11891          case OPCODE_ACTIVE_STENCIL_FACE_EXT:
11892             CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
11893             break;
11894          case OPCODE_DEPTH_BOUNDS_EXT:
11895             CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
11896             break;
11897          case OPCODE_PROGRAM_STRING_ARB:
11898             CALL_ProgramStringARB(ctx->Exec,
11899                                   (n[1].e, n[2].e, n[3].i,
11900                                    get_pointer(&n[4])));
11901             break;
11902          case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
11903             CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
11904                                                       n[4].f, n[5].f,
11905                                                       n[6].f));
11906             break;
11907          case OPCODE_BEGIN_QUERY_ARB:
11908             CALL_BeginQuery(ctx->Exec, (n[1].e, n[2].ui));
11909             break;
11910          case OPCODE_END_QUERY_ARB:
11911             CALL_EndQuery(ctx->Exec, (n[1].e));
11912             break;
11913          case OPCODE_QUERY_COUNTER:
11914             CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e));
11915             break;
11916          case OPCODE_BEGIN_QUERY_INDEXED:
11917             CALL_BeginQueryIndexed(ctx->Exec, (n[1].e, n[2].ui, n[3].ui));
11918             break;
11919          case OPCODE_END_QUERY_INDEXED:
11920             CALL_EndQueryIndexed(ctx->Exec, (n[1].e, n[2].ui));
11921             break;
11922          case OPCODE_DRAW_BUFFERS_ARB:
11923             {
11924                GLenum buffers[MAX_DRAW_BUFFERS];
11925                GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
11926                for (i = 0; i < count; i++)
11927                   buffers[i] = n[2 + i].e;
11928                CALL_DrawBuffers(ctx->Exec, (n[1].i, buffers));
11929             }
11930             break;
11931          case OPCODE_BLIT_FRAMEBUFFER:
11932             CALL_BlitFramebuffer(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i,
11933                                                 n[5].i, n[6].i, n[7].i, n[8].i,
11934                                                 n[9].i, n[10].e));
11935             break;
11936          case OPCODE_PRIMITIVE_RESTART_NV:
11937             CALL_PrimitiveRestartNV(ctx->Exec, ());
11938             break;
11939 
11940          case OPCODE_USE_PROGRAM:
11941             CALL_UseProgram(ctx->Exec, (n[1].ui));
11942             break;
11943          case OPCODE_UNIFORM_1F:
11944             CALL_Uniform1f(ctx->Exec, (n[1].i, n[2].f));
11945             break;
11946          case OPCODE_UNIFORM_2F:
11947             CALL_Uniform2f(ctx->Exec, (n[1].i, n[2].f, n[3].f));
11948             break;
11949          case OPCODE_UNIFORM_3F:
11950             CALL_Uniform3f(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f));
11951             break;
11952          case OPCODE_UNIFORM_4F:
11953             CALL_Uniform4f(ctx->Exec,
11954                               (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f));
11955             break;
11956          case OPCODE_UNIFORM_1FV:
11957             CALL_Uniform1fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11958             break;
11959          case OPCODE_UNIFORM_2FV:
11960             CALL_Uniform2fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11961             break;
11962          case OPCODE_UNIFORM_3FV:
11963             CALL_Uniform3fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11964             break;
11965          case OPCODE_UNIFORM_4FV:
11966             CALL_Uniform4fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
11967             break;
11968          case OPCODE_UNIFORM_1D: {
11969             union float64_pair x;
11970 
11971             x.uint32[0] = n[2].ui;
11972             x.uint32[1] = n[3].ui;
11973 
11974             CALL_Uniform1d(ctx->Exec, (n[1].i, x.d));
11975             break;
11976          }
11977          case OPCODE_UNIFORM_2D: {
11978             union float64_pair x;
11979             union float64_pair y;
11980 
11981             x.uint32[0] = n[2].ui;
11982             x.uint32[1] = n[3].ui;
11983             y.uint32[0] = n[4].ui;
11984             y.uint32[1] = n[5].ui;
11985 
11986             CALL_Uniform2d(ctx->Exec, (n[1].i, x.d, y.d));
11987             break;
11988          }
11989          case OPCODE_UNIFORM_3D: {
11990             union float64_pair x;
11991             union float64_pair y;
11992             union float64_pair z;
11993 
11994             x.uint32[0] = n[2].ui;
11995             x.uint32[1] = n[3].ui;
11996             y.uint32[0] = n[4].ui;
11997             y.uint32[1] = n[5].ui;
11998             z.uint32[0] = n[6].ui;
11999             z.uint32[1] = n[7].ui;
12000 
12001             CALL_Uniform3d(ctx->Exec, (n[1].i, x.d, y.d, z.d));
12002             break;
12003          }
12004          case OPCODE_UNIFORM_4D: {
12005             union float64_pair x;
12006             union float64_pair y;
12007             union float64_pair z;
12008             union float64_pair w;
12009 
12010             x.uint32[0] = n[2].ui;
12011             x.uint32[1] = n[3].ui;
12012             y.uint32[0] = n[4].ui;
12013             y.uint32[1] = n[5].ui;
12014             z.uint32[0] = n[6].ui;
12015             z.uint32[1] = n[7].ui;
12016             w.uint32[0] = n[8].ui;
12017             w.uint32[1] = n[9].ui;
12018 
12019             CALL_Uniform4d(ctx->Exec, (n[1].i, x.d, y.d, z.d, w.d));
12020             break;
12021          }
12022          case OPCODE_UNIFORM_1DV:
12023             CALL_Uniform1dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12024             break;
12025          case OPCODE_UNIFORM_2DV:
12026             CALL_Uniform2dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12027             break;
12028          case OPCODE_UNIFORM_3DV:
12029             CALL_Uniform3dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12030             break;
12031          case OPCODE_UNIFORM_4DV:
12032             CALL_Uniform4dv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12033             break;
12034          case OPCODE_UNIFORM_1I:
12035             CALL_Uniform1i(ctx->Exec, (n[1].i, n[2].i));
12036             break;
12037          case OPCODE_UNIFORM_2I:
12038             CALL_Uniform2i(ctx->Exec, (n[1].i, n[2].i, n[3].i));
12039             break;
12040          case OPCODE_UNIFORM_3I:
12041             CALL_Uniform3i(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12042             break;
12043          case OPCODE_UNIFORM_4I:
12044             CALL_Uniform4i(ctx->Exec,
12045                               (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
12046             break;
12047          case OPCODE_UNIFORM_1IV:
12048             CALL_Uniform1iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12049             break;
12050          case OPCODE_UNIFORM_2IV:
12051             CALL_Uniform2iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12052             break;
12053          case OPCODE_UNIFORM_3IV:
12054             CALL_Uniform3iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12055             break;
12056          case OPCODE_UNIFORM_4IV:
12057             CALL_Uniform4iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12058             break;
12059          case OPCODE_UNIFORM_1UI:
12060             CALL_Uniform1ui(ctx->Exec, (n[1].i, n[2].i));
12061             break;
12062          case OPCODE_UNIFORM_2UI:
12063             CALL_Uniform2ui(ctx->Exec, (n[1].i, n[2].i, n[3].i));
12064             break;
12065          case OPCODE_UNIFORM_3UI:
12066             CALL_Uniform3ui(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12067             break;
12068          case OPCODE_UNIFORM_4UI:
12069             CALL_Uniform4ui(ctx->Exec,
12070                             (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i));
12071             break;
12072          case OPCODE_UNIFORM_1UIV:
12073             CALL_Uniform1uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12074             break;
12075          case OPCODE_UNIFORM_2UIV:
12076             CALL_Uniform2uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12077             break;
12078          case OPCODE_UNIFORM_3UIV:
12079             CALL_Uniform3uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12080             break;
12081          case OPCODE_UNIFORM_4UIV:
12082             CALL_Uniform4uiv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12083             break;
12084          case OPCODE_UNIFORM_MATRIX22:
12085             CALL_UniformMatrix2fv(ctx->Exec,
12086                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12087             break;
12088          case OPCODE_UNIFORM_MATRIX33:
12089             CALL_UniformMatrix3fv(ctx->Exec,
12090                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12091             break;
12092          case OPCODE_UNIFORM_MATRIX44:
12093             CALL_UniformMatrix4fv(ctx->Exec,
12094                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12095             break;
12096          case OPCODE_UNIFORM_MATRIX23:
12097             CALL_UniformMatrix2x3fv(ctx->Exec,
12098                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12099             break;
12100          case OPCODE_UNIFORM_MATRIX32:
12101             CALL_UniformMatrix3x2fv(ctx->Exec,
12102                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12103             break;
12104          case OPCODE_UNIFORM_MATRIX24:
12105             CALL_UniformMatrix2x4fv(ctx->Exec,
12106                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12107             break;
12108          case OPCODE_UNIFORM_MATRIX42:
12109             CALL_UniformMatrix4x2fv(ctx->Exec,
12110                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12111             break;
12112          case OPCODE_UNIFORM_MATRIX34:
12113             CALL_UniformMatrix3x4fv(ctx->Exec,
12114                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12115             break;
12116          case OPCODE_UNIFORM_MATRIX43:
12117             CALL_UniformMatrix4x3fv(ctx->Exec,
12118                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12119             break;
12120          case OPCODE_UNIFORM_MATRIX22D:
12121             CALL_UniformMatrix2dv(ctx->Exec,
12122                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12123             break;
12124          case OPCODE_UNIFORM_MATRIX33D:
12125             CALL_UniformMatrix3dv(ctx->Exec,
12126                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12127             break;
12128          case OPCODE_UNIFORM_MATRIX44D:
12129             CALL_UniformMatrix4dv(ctx->Exec,
12130                                   (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12131             break;
12132          case OPCODE_UNIFORM_MATRIX23D:
12133             CALL_UniformMatrix2x3dv(ctx->Exec,
12134                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12135             break;
12136          case OPCODE_UNIFORM_MATRIX32D:
12137             CALL_UniformMatrix3x2dv(ctx->Exec,
12138                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12139             break;
12140          case OPCODE_UNIFORM_MATRIX24D:
12141             CALL_UniformMatrix2x4dv(ctx->Exec,
12142                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12143             break;
12144          case OPCODE_UNIFORM_MATRIX42D:
12145             CALL_UniformMatrix4x2dv(ctx->Exec,
12146                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12147             break;
12148          case OPCODE_UNIFORM_MATRIX34D:
12149             CALL_UniformMatrix3x4dv(ctx->Exec,
12150                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12151             break;
12152          case OPCODE_UNIFORM_MATRIX43D:
12153             CALL_UniformMatrix4x3dv(ctx->Exec,
12154                                     (n[1].i, n[2].i, n[3].b, get_pointer(&n[4])));
12155             break;
12156 
12157          case OPCODE_UNIFORM_1I64: {
12158             union int64_pair x;
12159 
12160             x.int32[0] = n[2].i;
12161             x.int32[1] = n[3].i;
12162 
12163             CALL_Uniform1i64ARB(ctx->Exec, (n[1].i, x.int64));
12164             break;
12165          }
12166          case OPCODE_UNIFORM_2I64: {
12167             union int64_pair x;
12168             union int64_pair y;
12169 
12170             x.int32[0] = n[2].i;
12171             x.int32[1] = n[3].i;
12172             y.int32[0] = n[4].i;
12173             y.int32[1] = n[5].i;
12174 
12175             CALL_Uniform2i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64));
12176             break;
12177          }
12178          case OPCODE_UNIFORM_3I64: {
12179             union int64_pair x;
12180             union int64_pair y;
12181             union int64_pair z;
12182 
12183             x.int32[0] = n[2].i;
12184             x.int32[1] = n[3].i;
12185             y.int32[0] = n[4].i;
12186             y.int32[1] = n[5].i;
12187             z.int32[0] = n[6].i;
12188             z.int32[1] = n[7].i;
12189 
12190 
12191             CALL_Uniform3i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64));
12192             break;
12193          }
12194          case OPCODE_UNIFORM_4I64: {
12195             union int64_pair x;
12196             union int64_pair y;
12197             union int64_pair z;
12198             union int64_pair w;
12199 
12200             x.int32[0] = n[2].i;
12201             x.int32[1] = n[3].i;
12202             y.int32[0] = n[4].i;
12203             y.int32[1] = n[5].i;
12204             z.int32[0] = n[6].i;
12205             z.int32[1] = n[7].i;
12206             w.int32[0] = n[8].i;
12207             w.int32[1] = n[9].i;
12208 
12209             CALL_Uniform4i64ARB(ctx->Exec, (n[1].i, x.int64, y.int64, z.int64, w.int64));
12210             break;
12211          }
12212          case OPCODE_UNIFORM_1I64V:
12213             CALL_Uniform1i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12214             break;
12215          case OPCODE_UNIFORM_2I64V:
12216             CALL_Uniform2i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12217             break;
12218          case OPCODE_UNIFORM_3I64V:
12219             CALL_Uniform3i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12220             break;
12221          case OPCODE_UNIFORM_4I64V:
12222             CALL_Uniform4i64vARB(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3])));
12223             break;
12224          case OPCODE_UNIFORM_1UI64: {
12225             union uint64_pair x;
12226 
12227             x.uint32[0] = n[2].ui;
12228             x.uint32[1] = n[3].ui;
12229 
12230             CALL_Uniform1ui64ARB(ctx->Exec, (n[1].i, x.uint64));
12231             break;
12232          }
12233          case OPCODE_UNIFORM_2UI64: {
12234             union uint64_pair x;
12235             union uint64_pair y;
12236 
12237             x.uint32[0] = n[2].ui;
12238             x.uint32[1] = n[3].ui;
12239             y.uint32[0] = n[4].ui;
12240             y.uint32[1] = n[5].ui;
12241 
12242             CALL_Uniform2ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64));
12243             break;
12244          }
12245          case OPCODE_UNIFORM_3UI64: {
12246             union uint64_pair x;
12247             union uint64_pair y;
12248             union uint64_pair z;
12249 
12250             x.uint32[0] = n[2].ui;
12251             x.uint32[1] = n[3].ui;
12252             y.uint32[0] = n[4].ui;
12253             y.uint32[1] = n[5].ui;
12254             z.uint32[0] = n[6].ui;
12255             z.uint32[1] = n[7].ui;
12256 
12257 
12258             CALL_Uniform3ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
12259                                  z.uint64));
12260             break;
12261          }
12262          case OPCODE_UNIFORM_4UI64: {
12263             union uint64_pair x;
12264             union uint64_pair y;
12265             union uint64_pair z;
12266             union uint64_pair w;
12267 
12268             x.uint32[0] = n[2].ui;
12269             x.uint32[1] = n[3].ui;
12270             y.uint32[0] = n[4].ui;
12271             y.uint32[1] = n[5].ui;
12272             z.uint32[0] = n[6].ui;
12273             z.uint32[1] = n[7].ui;
12274             w.uint32[0] = n[8].ui;
12275             w.uint32[1] = n[9].ui;
12276 
12277             CALL_Uniform4ui64ARB(ctx->Exec, (n[1].i, x.uint64, y.uint64,
12278                                  z.uint64, w.uint64));
12279             break;
12280          }
12281          case OPCODE_UNIFORM_1UI64V:
12282             CALL_Uniform1ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12283                                   get_pointer(&n[3])));
12284             break;
12285          case OPCODE_UNIFORM_2UI64V:
12286             CALL_Uniform2ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12287                                   get_pointer(&n[3])));
12288             break;
12289          case OPCODE_UNIFORM_3UI64V:
12290             CALL_Uniform3ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12291                                   get_pointer(&n[3])));
12292             break;
12293          case OPCODE_UNIFORM_4UI64V:
12294             CALL_Uniform4ui64vARB(ctx->Exec, (n[1].i, n[2].i,
12295                                   get_pointer(&n[3])));
12296             break;
12297 
12298          case OPCODE_PROGRAM_UNIFORM_1I64: {
12299             union int64_pair x;
12300 
12301             x.int32[0] = n[3].i;
12302             x.int32[1] = n[4].i;
12303 
12304             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64));
12305             break;
12306          }
12307          case OPCODE_PROGRAM_UNIFORM_2I64: {
12308             union int64_pair x;
12309             union int64_pair y;
12310 
12311             x.int32[0] = n[3].i;
12312             x.int32[1] = n[4].i;
12313             y.int32[0] = n[5].i;
12314             y.int32[1] = n[6].i;
12315 
12316             CALL_ProgramUniform2i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12317                                        y.int64));
12318             break;
12319          }
12320          case OPCODE_PROGRAM_UNIFORM_3I64: {
12321             union int64_pair x;
12322             union int64_pair y;
12323             union int64_pair z;
12324 
12325             x.int32[0] = n[3].i;
12326             x.int32[1] = n[4].i;
12327             y.int32[0] = n[5].i;
12328             y.int32[1] = n[6].i;
12329             z.int32[0] = n[7].i;
12330             z.int32[1] = n[8].i;
12331 
12332             CALL_ProgramUniform3i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12333                                        y.int64, z.int64));
12334             break;
12335          }
12336          case OPCODE_PROGRAM_UNIFORM_4I64: {
12337             union int64_pair x;
12338             union int64_pair y;
12339             union int64_pair z;
12340             union int64_pair w;
12341 
12342             x.int32[0] = n[3].i;
12343             x.int32[1] = n[4].i;
12344             y.int32[0] = n[5].i;
12345             y.int32[1] = n[6].i;
12346             z.int32[0] = n[7].i;
12347             z.int32[1] = n[8].i;
12348             w.int32[0] = n[9].i;
12349             w.int32[1] = n[10].i;
12350 
12351             CALL_ProgramUniform4i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.int64,
12352                                        y.int64, z.int64, w.int64));
12353             break;
12354          }
12355          case OPCODE_PROGRAM_UNIFORM_1I64V:
12356             CALL_ProgramUniform1i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12357                                         get_pointer(&n[4])));
12358             break;
12359          case OPCODE_PROGRAM_UNIFORM_2I64V:
12360             CALL_ProgramUniform2i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12361                                         get_pointer(&n[4])));
12362             break;
12363          case OPCODE_PROGRAM_UNIFORM_3I64V:
12364             CALL_ProgramUniform3i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12365                                         get_pointer(&n[4])));
12366             break;
12367          case OPCODE_PROGRAM_UNIFORM_4I64V:
12368             CALL_ProgramUniform4i64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12369                                         get_pointer(&n[4])));
12370             break;
12371          case OPCODE_PROGRAM_UNIFORM_1UI64: {
12372             union uint64_pair x;
12373 
12374             x.uint32[0] = n[3].ui;
12375             x.uint32[1] = n[4].ui;
12376 
12377             CALL_ProgramUniform1i64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64));
12378             break;
12379          }
12380          case OPCODE_PROGRAM_UNIFORM_2UI64: {
12381             union uint64_pair x;
12382             union uint64_pair y;
12383 
12384             x.uint32[0] = n[3].ui;
12385             x.uint32[1] = n[4].ui;
12386             y.uint32[0] = n[5].ui;
12387             y.uint32[1] = n[6].ui;
12388 
12389             CALL_ProgramUniform2ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12390                                         y.uint64));
12391             break;
12392          }
12393          case OPCODE_PROGRAM_UNIFORM_3UI64: {
12394             union uint64_pair x;
12395             union uint64_pair y;
12396             union uint64_pair z;
12397 
12398             x.uint32[0] = n[3].ui;
12399             x.uint32[1] = n[4].ui;
12400             y.uint32[0] = n[5].ui;
12401             y.uint32[1] = n[6].ui;
12402             z.uint32[0] = n[7].ui;
12403             z.uint32[1] = n[8].ui;
12404 
12405             CALL_ProgramUniform3ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12406                                         y.uint64, z.uint64));
12407             break;
12408          }
12409          case OPCODE_PROGRAM_UNIFORM_4UI64: {
12410             union uint64_pair x;
12411             union uint64_pair y;
12412             union uint64_pair z;
12413             union uint64_pair w;
12414 
12415             x.uint32[0] = n[3].ui;
12416             x.uint32[1] = n[4].ui;
12417             y.uint32[0] = n[5].ui;
12418             y.uint32[1] = n[6].ui;
12419             z.uint32[0] = n[7].ui;
12420             z.uint32[1] = n[8].ui;
12421             w.uint32[0] = n[9].ui;
12422             w.uint32[1] = n[10].ui;
12423 
12424             CALL_ProgramUniform4ui64ARB(ctx->Exec, (n[1].ui, n[2].i, x.uint64,
12425                                         y.uint64, z.uint64, w.uint64));
12426             break;
12427          }
12428          case OPCODE_PROGRAM_UNIFORM_1UI64V:
12429             CALL_ProgramUniform1ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12430                                          get_pointer(&n[4])));
12431             break;
12432          case OPCODE_PROGRAM_UNIFORM_2UI64V:
12433             CALL_ProgramUniform2ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12434                                          get_pointer(&n[4])));
12435             break;
12436          case OPCODE_PROGRAM_UNIFORM_3UI64V:
12437             CALL_ProgramUniform3ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12438                                          get_pointer(&n[4])));
12439             break;
12440          case OPCODE_PROGRAM_UNIFORM_4UI64V:
12441             CALL_ProgramUniform4ui64vARB(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12442                                          get_pointer(&n[4])));
12443             break;
12444 
12445          case OPCODE_USE_PROGRAM_STAGES:
12446             CALL_UseProgramStages(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12447             break;
12448          case OPCODE_PROGRAM_UNIFORM_1F:
12449             CALL_ProgramUniform1f(ctx->Exec, (n[1].ui, n[2].i, n[3].f));
12450             break;
12451          case OPCODE_PROGRAM_UNIFORM_2F:
12452             CALL_ProgramUniform2f(ctx->Exec, (n[1].ui, n[2].i, n[3].f, n[4].f));
12453             break;
12454          case OPCODE_PROGRAM_UNIFORM_3F:
12455             CALL_ProgramUniform3f(ctx->Exec, (n[1].ui, n[2].i,
12456                                               n[3].f, n[4].f, n[5].f));
12457             break;
12458          case OPCODE_PROGRAM_UNIFORM_4F:
12459             CALL_ProgramUniform4f(ctx->Exec, (n[1].ui, n[2].i,
12460                                               n[3].f, n[4].f, n[5].f, n[6].f));
12461             break;
12462          case OPCODE_PROGRAM_UNIFORM_1FV:
12463             CALL_ProgramUniform1fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12464                                                get_pointer(&n[4])));
12465             break;
12466          case OPCODE_PROGRAM_UNIFORM_2FV:
12467             CALL_ProgramUniform2fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12468                                                get_pointer(&n[4])));
12469             break;
12470          case OPCODE_PROGRAM_UNIFORM_3FV:
12471             CALL_ProgramUniform3fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12472                                                get_pointer(&n[4])));
12473             break;
12474          case OPCODE_PROGRAM_UNIFORM_4FV:
12475             CALL_ProgramUniform4fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12476                                                get_pointer(&n[4])));
12477             break;
12478          case OPCODE_PROGRAM_UNIFORM_1D: {
12479             union float64_pair x;
12480 
12481             x.uint32[0] = n[3].ui;
12482             x.uint32[1] = n[4].ui;
12483 
12484             CALL_ProgramUniform1d(ctx->Exec, (n[1].ui, n[2].i, x.d));
12485             break;
12486          }
12487          case OPCODE_PROGRAM_UNIFORM_2D: {
12488             union float64_pair x;
12489             union float64_pair y;
12490 
12491             x.uint32[0] = n[3].ui;
12492             x.uint32[1] = n[4].ui;
12493             y.uint32[0] = n[5].ui;
12494             y.uint32[1] = n[6].ui;
12495 
12496             CALL_ProgramUniform2d(ctx->Exec, (n[1].ui, n[2].i, x.d, y.d));
12497             break;
12498          }
12499          case OPCODE_PROGRAM_UNIFORM_3D: {
12500             union float64_pair x;
12501             union float64_pair y;
12502             union float64_pair z;
12503 
12504             x.uint32[0] = n[3].ui;
12505             x.uint32[1] = n[4].ui;
12506             y.uint32[0] = n[5].ui;
12507             y.uint32[1] = n[6].ui;
12508             z.uint32[0] = n[7].ui;
12509             z.uint32[1] = n[8].ui;
12510 
12511             CALL_ProgramUniform3d(ctx->Exec, (n[1].ui, n[2].i,
12512                                               x.d, y.d, z.d));
12513             break;
12514          }
12515          case OPCODE_PROGRAM_UNIFORM_4D: {
12516             union float64_pair x;
12517             union float64_pair y;
12518             union float64_pair z;
12519             union float64_pair w;
12520 
12521             x.uint32[0] = n[3].ui;
12522             x.uint32[1] = n[4].ui;
12523             y.uint32[0] = n[5].ui;
12524             y.uint32[1] = n[6].ui;
12525             z.uint32[0] = n[7].ui;
12526             z.uint32[1] = n[8].ui;
12527             w.uint32[0] = n[9].ui;
12528             w.uint32[1] = n[10].ui;
12529 
12530             CALL_ProgramUniform4d(ctx->Exec, (n[1].ui, n[2].i,
12531                                               x.d, y.d, z.d, w.d));
12532             break;
12533          }
12534          case OPCODE_PROGRAM_UNIFORM_1DV:
12535             CALL_ProgramUniform1dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12536                                                get_pointer(&n[4])));
12537             break;
12538          case OPCODE_PROGRAM_UNIFORM_2DV:
12539             CALL_ProgramUniform2dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12540                                                get_pointer(&n[4])));
12541             break;
12542          case OPCODE_PROGRAM_UNIFORM_3DV:
12543             CALL_ProgramUniform3dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12544                                                get_pointer(&n[4])));
12545             break;
12546          case OPCODE_PROGRAM_UNIFORM_4DV:
12547             CALL_ProgramUniform4dv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12548                                                get_pointer(&n[4])));
12549             break;
12550          case OPCODE_PROGRAM_UNIFORM_1I:
12551             CALL_ProgramUniform1i(ctx->Exec, (n[1].ui, n[2].i, n[3].i));
12552             break;
12553          case OPCODE_PROGRAM_UNIFORM_2I:
12554             CALL_ProgramUniform2i(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].i));
12555             break;
12556          case OPCODE_PROGRAM_UNIFORM_3I:
12557             CALL_ProgramUniform3i(ctx->Exec, (n[1].ui, n[2].i,
12558                                               n[3].i, n[4].i, n[5].i));
12559             break;
12560          case OPCODE_PROGRAM_UNIFORM_4I:
12561             CALL_ProgramUniform4i(ctx->Exec, (n[1].ui, n[2].i,
12562                                               n[3].i, n[4].i, n[5].i, n[6].i));
12563             break;
12564          case OPCODE_PROGRAM_UNIFORM_1IV:
12565             CALL_ProgramUniform1iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12566                                                get_pointer(&n[4])));
12567             break;
12568          case OPCODE_PROGRAM_UNIFORM_2IV:
12569             CALL_ProgramUniform2iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12570                                                get_pointer(&n[4])));
12571             break;
12572          case OPCODE_PROGRAM_UNIFORM_3IV:
12573             CALL_ProgramUniform3iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12574                                                get_pointer(&n[4])));
12575             break;
12576          case OPCODE_PROGRAM_UNIFORM_4IV:
12577             CALL_ProgramUniform4iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12578                                                get_pointer(&n[4])));
12579             break;
12580          case OPCODE_PROGRAM_UNIFORM_1UI:
12581             CALL_ProgramUniform1ui(ctx->Exec, (n[1].ui, n[2].i, n[3].ui));
12582             break;
12583          case OPCODE_PROGRAM_UNIFORM_2UI:
12584             CALL_ProgramUniform2ui(ctx->Exec, (n[1].ui, n[2].i,
12585                                                n[3].ui, n[4].ui));
12586             break;
12587          case OPCODE_PROGRAM_UNIFORM_3UI:
12588             CALL_ProgramUniform3ui(ctx->Exec, (n[1].ui, n[2].i,
12589                                                n[3].ui, n[4].ui, n[5].ui));
12590             break;
12591          case OPCODE_PROGRAM_UNIFORM_4UI:
12592             CALL_ProgramUniform4ui(ctx->Exec, (n[1].ui, n[2].i,
12593                                                n[3].ui,
12594                                                n[4].ui, n[5].ui, n[6].ui));
12595             break;
12596          case OPCODE_PROGRAM_UNIFORM_1UIV:
12597             CALL_ProgramUniform1uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12598                                                 get_pointer(&n[4])));
12599             break;
12600          case OPCODE_PROGRAM_UNIFORM_2UIV:
12601             CALL_ProgramUniform2uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12602                                                 get_pointer(&n[4])));
12603             break;
12604          case OPCODE_PROGRAM_UNIFORM_3UIV:
12605             CALL_ProgramUniform3uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12606                                                 get_pointer(&n[4])));
12607             break;
12608          case OPCODE_PROGRAM_UNIFORM_4UIV:
12609             CALL_ProgramUniform4uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i,
12610                                                 get_pointer(&n[4])));
12611             break;
12612          case OPCODE_PROGRAM_UNIFORM_MATRIX22F:
12613             CALL_ProgramUniformMatrix2fv(ctx->Exec,
12614                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12615                                           get_pointer(&n[5])));
12616             break;
12617          case OPCODE_PROGRAM_UNIFORM_MATRIX23F:
12618             CALL_ProgramUniformMatrix2x3fv(ctx->Exec,
12619                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12620                                             get_pointer(&n[5])));
12621             break;
12622          case OPCODE_PROGRAM_UNIFORM_MATRIX24F:
12623             CALL_ProgramUniformMatrix2x4fv(ctx->Exec,
12624                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12625                                             get_pointer(&n[5])));
12626             break;
12627          case OPCODE_PROGRAM_UNIFORM_MATRIX32F:
12628             CALL_ProgramUniformMatrix3x2fv(ctx->Exec,
12629                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12630                                             get_pointer(&n[5])));
12631             break;
12632          case OPCODE_PROGRAM_UNIFORM_MATRIX33F:
12633             CALL_ProgramUniformMatrix3fv(ctx->Exec,
12634                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12635                                           get_pointer(&n[5])));
12636             break;
12637          case OPCODE_PROGRAM_UNIFORM_MATRIX34F:
12638             CALL_ProgramUniformMatrix3x4fv(ctx->Exec,
12639                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12640                                             get_pointer(&n[5])));
12641             break;
12642          case OPCODE_PROGRAM_UNIFORM_MATRIX42F:
12643             CALL_ProgramUniformMatrix4x2fv(ctx->Exec,
12644                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12645                                             get_pointer(&n[5])));
12646             break;
12647          case OPCODE_PROGRAM_UNIFORM_MATRIX43F:
12648             CALL_ProgramUniformMatrix4x3fv(ctx->Exec,
12649                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12650                                             get_pointer(&n[5])));
12651             break;
12652          case OPCODE_PROGRAM_UNIFORM_MATRIX44F:
12653             CALL_ProgramUniformMatrix4fv(ctx->Exec,
12654                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12655                                           get_pointer(&n[5])));
12656             break;
12657          case OPCODE_PROGRAM_UNIFORM_MATRIX22D:
12658             CALL_ProgramUniformMatrix2dv(ctx->Exec,
12659                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12660                                           get_pointer(&n[5])));
12661             break;
12662          case OPCODE_PROGRAM_UNIFORM_MATRIX23D:
12663             CALL_ProgramUniformMatrix2x3dv(ctx->Exec,
12664                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12665                                             get_pointer(&n[5])));
12666             break;
12667          case OPCODE_PROGRAM_UNIFORM_MATRIX24D:
12668             CALL_ProgramUniformMatrix2x4dv(ctx->Exec,
12669                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12670                                             get_pointer(&n[5])));
12671             break;
12672          case OPCODE_PROGRAM_UNIFORM_MATRIX32D:
12673             CALL_ProgramUniformMatrix3x2dv(ctx->Exec,
12674                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12675                                             get_pointer(&n[5])));
12676             break;
12677          case OPCODE_PROGRAM_UNIFORM_MATRIX33D:
12678             CALL_ProgramUniformMatrix3dv(ctx->Exec,
12679                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12680                                           get_pointer(&n[5])));
12681             break;
12682          case OPCODE_PROGRAM_UNIFORM_MATRIX34D:
12683             CALL_ProgramUniformMatrix3x4dv(ctx->Exec,
12684                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12685                                             get_pointer(&n[5])));
12686             break;
12687          case OPCODE_PROGRAM_UNIFORM_MATRIX42D:
12688             CALL_ProgramUniformMatrix4x2dv(ctx->Exec,
12689                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12690                                             get_pointer(&n[5])));
12691             break;
12692          case OPCODE_PROGRAM_UNIFORM_MATRIX43D:
12693             CALL_ProgramUniformMatrix4x3dv(ctx->Exec,
12694                                            (n[1].ui, n[2].i, n[3].i, n[4].b,
12695                                             get_pointer(&n[5])));
12696             break;
12697          case OPCODE_PROGRAM_UNIFORM_MATRIX44D:
12698             CALL_ProgramUniformMatrix4dv(ctx->Exec,
12699                                          (n[1].ui, n[2].i, n[3].i, n[4].b,
12700                                           get_pointer(&n[5])));
12701             break;
12702 
12703          case OPCODE_CLIP_CONTROL:
12704             CALL_ClipControl(ctx->Exec, (n[1].e, n[2].e));
12705             break;
12706 
12707          case OPCODE_CLAMP_COLOR:
12708             CALL_ClampColor(ctx->Exec, (n[1].e, n[2].e));
12709             break;
12710 
12711          case OPCODE_BIND_FRAGMENT_SHADER_ATI:
12712             CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
12713             break;
12714          case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
12715             CALL_SetFragmentShaderConstantATI(ctx->Exec, (n[1].ui, &n[2].f));
12716             break;
12717          case OPCODE_ATTR_1F_NV:
12718             CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
12719             break;
12720          case OPCODE_ATTR_2F_NV:
12721             CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
12722             break;
12723          case OPCODE_ATTR_3F_NV:
12724             CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
12725             break;
12726          case OPCODE_ATTR_4F_NV:
12727             CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
12728             break;
12729          case OPCODE_ATTR_1F_ARB:
12730             CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
12731             break;
12732          case OPCODE_ATTR_2F_ARB:
12733             CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
12734             break;
12735          case OPCODE_ATTR_3F_ARB:
12736             CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
12737             break;
12738          case OPCODE_ATTR_4F_ARB:
12739             CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
12740             break;
12741          case OPCODE_ATTR_1I:
12742             CALL_VertexAttribI1iEXT(ctx->Exec, (n[1].e, n[2].i));
12743             break;
12744          case OPCODE_ATTR_2I:
12745             CALL_VertexAttribI2ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12746             break;
12747          case OPCODE_ATTR_3I:
12748             CALL_VertexAttribI3ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12749             break;
12750          case OPCODE_ATTR_4I:
12751             CALL_VertexAttribI4ivEXT(ctx->Exec, (n[1].e, &n[2].i));
12752             break;
12753          case OPCODE_ATTR_1D: {
12754             GLdouble *d = (GLdouble *) &n[2];
12755             CALL_VertexAttribL1d(ctx->Exec, (n[1].ui, *d));
12756             break;
12757          }
12758          case OPCODE_ATTR_2D: {
12759             GLdouble *d = (GLdouble *) &n[2];
12760             CALL_VertexAttribL2dv(ctx->Exec, (n[1].ui, d));
12761             break;
12762          }
12763          case OPCODE_ATTR_3D: {
12764             GLdouble *d = (GLdouble *) &n[2];
12765             CALL_VertexAttribL3dv(ctx->Exec, (n[1].ui, d));
12766             break;
12767          }
12768          case OPCODE_ATTR_4D: {
12769             GLdouble *d = (GLdouble *) &n[2];
12770             CALL_VertexAttribL4dv(ctx->Exec, (n[1].ui, d));
12771             break;
12772          }
12773          case OPCODE_ATTR_1UI64: {
12774             uint64_t *ui64 = (uint64_t *) &n[2];
12775             CALL_VertexAttribL1ui64ARB(ctx->Exec, (n[1].ui, *ui64));
12776             break;
12777          }
12778          case OPCODE_MATERIAL:
12779             CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
12780             break;
12781          case OPCODE_BEGIN:
12782             CALL_Begin(ctx->Exec, (n[1].e));
12783             break;
12784          case OPCODE_END:
12785             CALL_End(ctx->Exec, ());
12786             break;
12787          case OPCODE_EVAL_C1:
12788             CALL_EvalCoord1f(ctx->Exec, (n[1].f));
12789             break;
12790          case OPCODE_EVAL_C2:
12791             CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
12792             break;
12793          case OPCODE_EVAL_P1:
12794             CALL_EvalPoint1(ctx->Exec, (n[1].i));
12795             break;
12796          case OPCODE_EVAL_P2:
12797             CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
12798             break;
12799 
12800          /* GL_EXT_texture_integer */
12801          case OPCODE_CLEARCOLOR_I:
12802             CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));
12803             break;
12804          case OPCODE_CLEARCOLOR_UI:
12805             CALL_ClearColorIuiEXT(ctx->Exec,
12806                                   (n[1].ui, n[2].ui, n[3].ui, n[4].ui));
12807             break;
12808          case OPCODE_TEXPARAMETER_I:
12809             {
12810                GLint params[4];
12811                params[0] = n[3].i;
12812                params[1] = n[4].i;
12813                params[2] = n[5].i;
12814                params[3] = n[6].i;
12815                CALL_TexParameterIiv(ctx->Exec, (n[1].e, n[2].e, params));
12816             }
12817             break;
12818          case OPCODE_TEXPARAMETER_UI:
12819             {
12820                GLuint params[4];
12821                params[0] = n[3].ui;
12822                params[1] = n[4].ui;
12823                params[2] = n[5].ui;
12824                params[3] = n[6].ui;
12825                CALL_TexParameterIuiv(ctx->Exec, (n[1].e, n[2].e, params));
12826             }
12827             break;
12828 
12829          case OPCODE_VERTEX_ATTRIB_DIVISOR:
12830             /* GL_ARB_instanced_arrays */
12831             CALL_VertexAttribDivisor(ctx->Exec, (n[1].ui, n[2].ui));
12832             break;
12833 
12834          case OPCODE_TEXTURE_BARRIER_NV:
12835             CALL_TextureBarrierNV(ctx->Exec, ());
12836             break;
12837 
12838          /* GL_EXT/ARB_transform_feedback */
12839          case OPCODE_BEGIN_TRANSFORM_FEEDBACK:
12840             CALL_BeginTransformFeedback(ctx->Exec, (n[1].e));
12841             break;
12842          case OPCODE_END_TRANSFORM_FEEDBACK:
12843             CALL_EndTransformFeedback(ctx->Exec, ());
12844             break;
12845          case OPCODE_BIND_TRANSFORM_FEEDBACK:
12846             CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
12847             break;
12848          case OPCODE_PAUSE_TRANSFORM_FEEDBACK:
12849             CALL_PauseTransformFeedback(ctx->Exec, ());
12850             break;
12851          case OPCODE_RESUME_TRANSFORM_FEEDBACK:
12852             CALL_ResumeTransformFeedback(ctx->Exec, ());
12853             break;
12854          case OPCODE_DRAW_TRANSFORM_FEEDBACK:
12855             CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui));
12856             break;
12857          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM:
12858             CALL_DrawTransformFeedbackStream(ctx->Exec,
12859                                              (n[1].e, n[2].ui, n[3].ui));
12860             break;
12861          case OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED:
12862             CALL_DrawTransformFeedbackInstanced(ctx->Exec,
12863                                                 (n[1].e, n[2].ui, n[3].si));
12864             break;
12865          case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED:
12866             CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec,
12867                                        (n[1].e, n[2].ui, n[3].ui, n[4].si));
12868             break;
12869 
12870 
12871          case OPCODE_BIND_SAMPLER:
12872             CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui));
12873             break;
12874          case OPCODE_SAMPLER_PARAMETERIV:
12875             {
12876                GLint params[4];
12877                params[0] = n[3].i;
12878                params[1] = n[4].i;
12879                params[2] = n[5].i;
12880                params[3] = n[6].i;
12881                CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params));
12882             }
12883             break;
12884          case OPCODE_SAMPLER_PARAMETERFV:
12885             {
12886                GLfloat params[4];
12887                params[0] = n[3].f;
12888                params[1] = n[4].f;
12889                params[2] = n[5].f;
12890                params[3] = n[6].f;
12891                CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params));
12892             }
12893             break;
12894          case OPCODE_SAMPLER_PARAMETERIIV:
12895             {
12896                GLint params[4];
12897                params[0] = n[3].i;
12898                params[1] = n[4].i;
12899                params[2] = n[5].i;
12900                params[3] = n[6].i;
12901                CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params));
12902             }
12903             break;
12904          case OPCODE_SAMPLER_PARAMETERUIV:
12905             {
12906                GLuint params[4];
12907                params[0] = n[3].ui;
12908                params[1] = n[4].ui;
12909                params[2] = n[5].ui;
12910                params[3] = n[6].ui;
12911                CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params));
12912             }
12913             break;
12914 
12915          /* ARB_compute_shader */
12916          case OPCODE_DISPATCH_COMPUTE:
12917             CALL_DispatchCompute(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12918             break;
12919 
12920          /* GL_ARB_sync */
12921          case OPCODE_WAIT_SYNC:
12922             {
12923                union uint64_pair p;
12924                p.uint32[0] = n[2].ui;
12925                p.uint32[1] = n[3].ui;
12926                CALL_WaitSync(ctx->Exec,
12927                              (get_pointer(&n[4]), n[1].bf, p.uint64));
12928             }
12929             break;
12930 
12931          /* GL_NV_conditional_render */
12932          case OPCODE_BEGIN_CONDITIONAL_RENDER:
12933             CALL_BeginConditionalRender(ctx->Exec, (n[1].i, n[2].e));
12934             break;
12935          case OPCODE_END_CONDITIONAL_RENDER:
12936             CALL_EndConditionalRender(ctx->Exec, ());
12937             break;
12938 
12939          case OPCODE_UNIFORM_BLOCK_BINDING:
12940             CALL_UniformBlockBinding(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui));
12941             break;
12942 
12943          case OPCODE_UNIFORM_SUBROUTINES:
12944             CALL_UniformSubroutinesuiv(ctx->Exec, (n[1].e, n[2].si,
12945                                                    get_pointer(&n[3])));
12946             break;
12947 
12948          /* GL_EXT_window_rectangles */
12949          case OPCODE_WINDOW_RECTANGLES:
12950             CALL_WindowRectanglesEXT(
12951                   ctx->Exec, (n[1].e, n[2].si, get_pointer(&n[3])));
12952             break;
12953 
12954          /* GL_NV_conservative_raster */
12955          case OPCODE_SUBPIXEL_PRECISION_BIAS:
12956             CALL_SubpixelPrecisionBiasNV(ctx->Exec, (n[1].ui, n[2].ui));
12957             break;
12958 
12959          /* GL_NV_conservative_raster_dilate */
12960          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_F:
12961             CALL_ConservativeRasterParameterfNV(ctx->Exec, (n[1].e, n[2].f));
12962             break;
12963 
12964          /* GL_NV_conservative_raster_pre_snap_triangles */
12965          case OPCODE_CONSERVATIVE_RASTER_PARAMETER_I:
12966             CALL_ConservativeRasterParameteriNV(ctx->Exec, (n[1].e, n[2].i));
12967             break;
12968 
12969          /* GL_EXT_direct_state_access */
12970          case OPCODE_MATRIX_LOAD:
12971             CALL_MatrixLoadfEXT(ctx->Exec, (n[1].e, &n[2].f));
12972             break;
12973          case OPCODE_MATRIX_MULT:
12974             CALL_MatrixMultfEXT(ctx->Exec, (n[1].e, &n[2].f));
12975             break;
12976          case OPCODE_MATRIX_ROTATE:
12977             CALL_MatrixRotatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f, n[5].f));
12978             break;
12979          case OPCODE_MATRIX_SCALE:
12980             CALL_MatrixScalefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
12981             break;
12982          case OPCODE_MATRIX_TRANSLATE:
12983             CALL_MatrixTranslatefEXT(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f));
12984             break;
12985          case OPCODE_MATRIX_LOAD_IDENTITY:
12986             CALL_MatrixLoadIdentityEXT(ctx->Exec, (n[1].e));
12987             break;
12988          case OPCODE_MATRIX_ORTHO:
12989             CALL_MatrixOrthoEXT(ctx->Exec, (n[1].e,
12990                                             n[2].f, n[3].f, n[4].f,
12991                                             n[5].f, n[6].f, n[7].f));
12992             break;
12993          case OPCODE_MATRIX_FRUSTUM:
12994             CALL_MatrixFrustumEXT(ctx->Exec, (n[1].e,
12995                                               n[2].f, n[3].f, n[4].f,
12996                                               n[5].f, n[6].f, n[7].f));
12997             break;
12998          case OPCODE_MATRIX_PUSH:
12999             CALL_MatrixPushEXT(ctx->Exec, (n[1].e));
13000             break;
13001          case OPCODE_MATRIX_POP:
13002             CALL_MatrixPopEXT(ctx->Exec, (n[1].e));
13003             break;
13004          case OPCODE_TEXTUREPARAMETER_F:
13005             {
13006                GLfloat params[4];
13007                params[0] = n[4].f;
13008                params[1] = n[5].f;
13009                params[2] = n[6].f;
13010                params[3] = n[7].f;
13011                CALL_TextureParameterfvEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13012             }
13013             break;
13014          case OPCODE_TEXTUREPARAMETER_I:
13015             {
13016                GLint params[4];
13017                params[0] = n[4].i;
13018                params[1] = n[5].i;
13019                params[2] = n[6].i;
13020                params[3] = n[7].i;
13021                CALL_TextureParameterivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13022             }
13023             break;
13024          case OPCODE_TEXTUREPARAMETER_II:
13025             {
13026                GLint params[4];
13027                params[0] = n[4].i;
13028                params[1] = n[5].i;
13029                params[2] = n[6].i;
13030                params[3] = n[7].i;
13031                CALL_TextureParameterIivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13032             }
13033             break;
13034          case OPCODE_TEXTUREPARAMETER_IUI:
13035             {
13036                GLuint params[4];
13037                params[0] = n[4].ui;
13038                params[1] = n[5].ui;
13039                params[2] = n[6].ui;
13040                params[3] = n[7].ui;
13041                CALL_TextureParameterIuivEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].e, params));
13042             }
13043             break;
13044          case OPCODE_TEXTURE_IMAGE1D:
13045             {
13046                const struct gl_pixelstore_attrib save = ctx->Unpack;
13047                ctx->Unpack = ctx->DefaultPacking;
13048                CALL_TextureImage1DEXT(ctx->Exec, (n[1].ui, /* texture */
13049                                                   n[2].e,  /* target */
13050                                                   n[3].i,  /* level */
13051                                                   n[4].i,  /* components */
13052                                                   n[5].i,  /* width */
13053                                                   n[6].e,  /* border */
13054                                                   n[7].e,  /* format */
13055                                                   n[8].e,  /* type */
13056                                                   get_pointer(&n[9])));
13057                ctx->Unpack = save;      /* restore */
13058             }
13059             break;
13060          case OPCODE_TEXTURE_IMAGE2D:
13061             {
13062                const struct gl_pixelstore_attrib save = ctx->Unpack;
13063                ctx->Unpack = ctx->DefaultPacking;
13064                CALL_TextureImage2DEXT(ctx->Exec, (n[1].ui, /* texture */
13065                                                   n[2].e,  /* target */
13066                                                   n[3].i,  /* level */
13067                                                   n[4].i,  /* components */
13068                                                   n[5].i,  /* width */
13069                                                   n[6].i,  /* height */
13070                                                   n[7].e,  /* border */
13071                                                   n[8].e,  /* format */
13072                                                   n[9].e,  /* type */
13073                                                   get_pointer(&n[10])));
13074                ctx->Unpack = save;      /* restore */
13075             }
13076             break;
13077          case OPCODE_TEXTURE_IMAGE3D:
13078             {
13079                const struct gl_pixelstore_attrib save = ctx->Unpack;
13080                ctx->Unpack = ctx->DefaultPacking;
13081                CALL_TextureImage3DEXT(ctx->Exec, (n[1].ui, /* texture */
13082                                                   n[2].e,  /* target */
13083                                                   n[3].i,  /* level */
13084                                                   n[4].i,  /* components */
13085                                                   n[5].i,  /* width */
13086                                                   n[6].i,  /* height */
13087                                                   n[7].i,  /* depth  */
13088                                                   n[8].e,  /* border */
13089                                                   n[9].e,  /* format */
13090                                                   n[10].e, /* type */
13091                                                   get_pointer(&n[11])));
13092                ctx->Unpack = save;      /* restore */
13093             }
13094             break;
13095          case OPCODE_TEXTURE_SUB_IMAGE1D:
13096             {
13097                const struct gl_pixelstore_attrib save = ctx->Unpack;
13098                ctx->Unpack = ctx->DefaultPacking;
13099                CALL_TextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13100                                                      n[4].i, n[5].i, n[6].e,
13101                                                      n[7].e, get_pointer(&n[8])));
13102                ctx->Unpack = save;      /* restore */
13103             }
13104             break;
13105          case OPCODE_TEXTURE_SUB_IMAGE2D:
13106             {
13107                const struct gl_pixelstore_attrib save = ctx->Unpack;
13108                ctx->Unpack = ctx->DefaultPacking;
13109                CALL_TextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13110                                                      n[4].i, n[5].i, n[6].e,
13111                                                      n[7].i, n[8].e, n[9].e,
13112                                                      get_pointer(&n[10])));
13113                ctx->Unpack = save;
13114             }
13115             break;
13116          case OPCODE_TEXTURE_SUB_IMAGE3D:
13117             {
13118                const struct gl_pixelstore_attrib save = ctx->Unpack;
13119                ctx->Unpack = ctx->DefaultPacking;
13120                CALL_TextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13121                                                      n[4].i, n[5].i, n[6].i,
13122                                                      n[7].i, n[8].i, n[9].i,
13123                                                      n[10].e, n[11].e,
13124                                                      get_pointer(&n[12])));
13125                ctx->Unpack = save;      /* restore */
13126             }
13127             break;
13128          case OPCODE_COPY_TEXTURE_IMAGE1D:
13129             CALL_CopyTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13130                                                    n[4].e, n[5].i, n[6].i,
13131                                                    n[7].i, n[8].i));
13132             break;
13133          case OPCODE_COPY_TEXTURE_IMAGE2D:
13134             CALL_CopyTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13135                                                    n[4].e, n[5].i, n[6].i,
13136                                                    n[7].i, n[8].i, n[9].i));
13137             break;
13138          case OPCODE_COPY_TEXTURE_SUB_IMAGE1D:
13139             CALL_CopyTextureSubImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13140                                                       n[4].i, n[5].i, n[6].i,
13141                                                       n[7].i));
13142             break;
13143          case OPCODE_COPY_TEXTURE_SUB_IMAGE2D:
13144             CALL_CopyTextureSubImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13145                                                       n[4].i, n[5].i, n[6].i,
13146                                                       n[7].i, n[8].i, n[9].i));
13147             break;
13148          case OPCODE_COPY_TEXTURE_SUB_IMAGE3D:
13149             CALL_CopyTextureSubImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13150                                                       n[4].i, n[5].i, n[6].i,
13151                                                       n[7].i, n[8].i, n[9].i,
13152                                                       n[10].i));
13153             break;
13154          case OPCODE_BIND_MULTITEXTURE:
13155             CALL_BindMultiTextureEXT(ctx->Exec, (n[1].e, n[2].e, n[3].ui));
13156             break;
13157          case OPCODE_MULTITEXPARAMETER_F:
13158             {
13159                GLfloat params[4];
13160                params[0] = n[4].f;
13161                params[1] = n[5].f;
13162                params[2] = n[6].f;
13163                params[3] = n[7].f;
13164                CALL_MultiTexParameterfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13165             }
13166             break;
13167          case OPCODE_MULTITEXPARAMETER_I:
13168             {
13169                GLint params[4];
13170                params[0] = n[4].i;
13171                params[1] = n[5].i;
13172                params[2] = n[6].i;
13173                params[3] = n[7].i;
13174                CALL_MultiTexParameterivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13175             }
13176             break;
13177          case OPCODE_MULTITEXPARAMETER_II:
13178             {
13179                GLint params[4];
13180                params[0] = n[4].i;
13181                params[1] = n[5].i;
13182                params[2] = n[6].i;
13183                params[3] = n[7].i;
13184                CALL_MultiTexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13185             }
13186             break;
13187          case OPCODE_MULTITEXPARAMETER_IUI:
13188             {
13189                GLuint params[4];
13190                params[0] = n[4].ui;
13191                params[1] = n[5].ui;
13192                params[2] = n[6].ui;
13193                params[3] = n[7].ui;
13194                CALL_MultiTexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13195             }
13196             break;
13197          case OPCODE_MULTITEX_IMAGE1D:
13198             {
13199                const struct gl_pixelstore_attrib save = ctx->Unpack;
13200                ctx->Unpack = ctx->DefaultPacking;
13201                CALL_MultiTexImage1DEXT(ctx->Exec, (n[1].e, /* texture */
13202                                                   n[2].e,  /* target */
13203                                                   n[3].i,  /* level */
13204                                                   n[4].i,  /* components */
13205                                                   n[5].i,  /* width */
13206                                                   n[6].e,  /* border */
13207                                                   n[7].e,  /* format */
13208                                                   n[8].e,  /* type */
13209                                                   get_pointer(&n[9])));
13210                ctx->Unpack = save;      /* restore */
13211             }
13212             break;
13213          case OPCODE_MULTITEX_IMAGE2D:
13214             {
13215                const struct gl_pixelstore_attrib save = ctx->Unpack;
13216                ctx->Unpack = ctx->DefaultPacking;
13217                CALL_MultiTexImage2DEXT(ctx->Exec, (n[1].e, /* texture */
13218                                                   n[2].e,  /* target */
13219                                                   n[3].i,  /* level */
13220                                                   n[4].i,  /* components */
13221                                                   n[5].i,  /* width */
13222                                                   n[6].i,  /* height */
13223                                                   n[7].e,  /* border */
13224                                                   n[8].e,  /* format */
13225                                                   n[9].e,  /* type */
13226                                                   get_pointer(&n[10])));
13227                ctx->Unpack = save;      /* restore */
13228             }
13229             break;
13230          case OPCODE_MULTITEX_IMAGE3D:
13231             {
13232                const struct gl_pixelstore_attrib save = ctx->Unpack;
13233                ctx->Unpack = ctx->DefaultPacking;
13234                CALL_MultiTexImage3DEXT(ctx->Exec, (n[1].e, /* texture */
13235                                                   n[2].e,  /* target */
13236                                                   n[3].i,  /* level */
13237                                                   n[4].i,  /* components */
13238                                                   n[5].i,  /* width */
13239                                                   n[6].i,  /* height */
13240                                                   n[7].i,  /* depth  */
13241                                                   n[8].e,  /* border */
13242                                                   n[9].e,  /* format */
13243                                                   n[10].e, /* type */
13244                                                   get_pointer(&n[11])));
13245                ctx->Unpack = save;      /* restore */
13246             }
13247             break;
13248          case OPCODE_MULTITEX_SUB_IMAGE1D:
13249             {
13250                const struct gl_pixelstore_attrib save = ctx->Unpack;
13251                ctx->Unpack = ctx->DefaultPacking;
13252                CALL_MultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13253                                                      n[4].i, n[5].i, n[6].e,
13254                                                      n[7].e, get_pointer(&n[8])));
13255                ctx->Unpack = save;      /* restore */
13256             }
13257             break;
13258          case OPCODE_MULTITEX_SUB_IMAGE2D:
13259             {
13260                const struct gl_pixelstore_attrib save = ctx->Unpack;
13261                ctx->Unpack = ctx->DefaultPacking;
13262                CALL_MultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13263                                                      n[4].i, n[5].i, n[6].e,
13264                                                      n[7].i, n[8].e, n[9].e,
13265                                                      get_pointer(&n[10])));
13266                ctx->Unpack = save;      /* restore */
13267             }
13268             break;
13269          case OPCODE_MULTITEX_SUB_IMAGE3D:
13270             {
13271                const struct gl_pixelstore_attrib save = ctx->Unpack;
13272                ctx->Unpack = ctx->DefaultPacking;
13273                CALL_MultiTexSubImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13274                                                      n[4].i, n[5].i, n[6].i,
13275                                                      n[7].i, n[8].i, n[9].i,
13276                                                      n[10].e, n[11].e,
13277                                                      get_pointer(&n[12])));
13278                ctx->Unpack = save;      /* restore */
13279             }
13280             break;
13281          case OPCODE_COPY_MULTITEX_IMAGE1D:
13282             CALL_CopyMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13283                                                    n[4].e, n[5].i, n[6].i,
13284                                                    n[7].i, n[8].i));
13285             break;
13286          case OPCODE_COPY_MULTITEX_IMAGE2D:
13287             CALL_CopyMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13288                                                    n[4].e, n[5].i, n[6].i,
13289                                                    n[7].i, n[8].i, n[9].i));
13290             break;
13291          case OPCODE_COPY_MULTITEX_SUB_IMAGE1D:
13292             CALL_CopyMultiTexSubImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13293                                                       n[4].i, n[5].i, n[6].i,
13294                                                       n[7].i));
13295             break;
13296          case OPCODE_COPY_MULTITEX_SUB_IMAGE2D:
13297             CALL_CopyMultiTexSubImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13298                                                       n[4].i, n[5].i, n[6].i,
13299                                                       n[7].i, n[8].i, n[9].i));
13300             break;
13301          case OPCODE_COPY_MULTITEX_SUB_IMAGE3D:
13302             CALL_CopyMultiTexSubImage3DEXT(ctx->Exec, (n[1].e, 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].i));
13306             break;
13307          case OPCODE_MULTITEXENV:
13308             {
13309                GLfloat params[4];
13310                params[0] = n[4].f;
13311                params[1] = n[5].f;
13312                params[2] = n[6].f;
13313                params[3] = n[7].f;
13314                CALL_MultiTexEnvfvEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, params));
13315             }
13316             break;
13317          case OPCODE_COMPRESSED_TEXTURE_IMAGE_1D:
13318             CALL_CompressedTextureImage1DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13319                                                          n[4].e, n[5].i, n[6].i,
13320                                                          n[7].i, get_pointer(&n[8])));
13321             break;
13322          case OPCODE_COMPRESSED_TEXTURE_IMAGE_2D:
13323             CALL_CompressedTextureImage2DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13324                                                          n[4].e, n[5].i, n[6].i,
13325                                                          n[7].i, n[8].i,
13326                                                          get_pointer(&n[9])));
13327             break;
13328          case OPCODE_COMPRESSED_TEXTURE_IMAGE_3D:
13329             CALL_CompressedTextureImage3DEXT(ctx->Exec, (n[1].ui, n[2].e, n[3].i,
13330                                                          n[4].e, n[5].i, n[6].i,
13331                                                          n[7].i, n[8].i, n[9].i,
13332                                                          get_pointer(&n[10])));
13333             break;
13334          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_1D:
13335             CALL_CompressedTextureSubImage1DEXT(ctx->Exec,
13336                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13337                                                  n[5].i, n[6].e, n[7].i,
13338                                                  get_pointer(&n[8])));
13339             break;
13340          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_2D:
13341             CALL_CompressedTextureSubImage2DEXT(ctx->Exec,
13342                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13343                                                  n[5].i, n[6].i, n[7].i, n[8].e,
13344                                                  n[9].i, get_pointer(&n[10])));
13345             break;
13346          case OPCODE_COMPRESSED_TEXTURE_SUB_IMAGE_3D:
13347             CALL_CompressedTextureSubImage3DEXT(ctx->Exec,
13348                                                 (n[1].ui, n[2].e, n[3].i, n[4].i,
13349                                                  n[5].i, n[6].i, n[7].i, n[8].i,
13350                                                  n[9].i, n[10].e, n[11].i,
13351                                                  get_pointer(&n[12])));
13352             break;
13353          case OPCODE_COMPRESSED_MULTITEX_IMAGE_1D:
13354             CALL_CompressedMultiTexImage1DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13355                                                          n[4].e, n[5].i, n[6].i,
13356                                                          n[7].i, get_pointer(&n[8])));
13357             break;
13358          case OPCODE_COMPRESSED_MULTITEX_IMAGE_2D:
13359             CALL_CompressedMultiTexImage2DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13360                                                          n[4].e, n[5].i, n[6].i,
13361                                                          n[7].i, n[8].i,
13362                                                          get_pointer(&n[9])));
13363             break;
13364          case OPCODE_COMPRESSED_MULTITEX_IMAGE_3D:
13365             CALL_CompressedMultiTexImage3DEXT(ctx->Exec, (n[1].e, n[2].e, n[3].i,
13366                                                          n[4].e, n[5].i, n[6].i,
13367                                                          n[7].i, n[8].i, n[9].i,
13368                                                          get_pointer(&n[10])));
13369             break;
13370          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_1D:
13371             CALL_CompressedMultiTexSubImage1DEXT(ctx->Exec,
13372                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13373                                                  n[5].i, n[6].e, n[7].i,
13374                                                  get_pointer(&n[8])));
13375             break;
13376          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_2D:
13377             CALL_CompressedMultiTexSubImage2DEXT(ctx->Exec,
13378                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13379                                                  n[5].i, n[6].i, n[7].i, n[8].e,
13380                                                  n[9].i, get_pointer(&n[10])));
13381             break;
13382          case OPCODE_COMPRESSED_MULTITEX_SUB_IMAGE_3D:
13383             CALL_CompressedMultiTexSubImage3DEXT(ctx->Exec,
13384                                                 (n[1].e, n[2].e, n[3].i, n[4].i,
13385                                                  n[5].i, n[6].i, n[7].i, n[8].i,
13386                                                  n[9].i, n[10].e, n[11].i,
13387                                                  get_pointer(&n[12])));
13388             break;
13389          case OPCODE_NAMED_PROGRAM_STRING:
13390             CALL_NamedProgramStringEXT(ctx->Exec,
13391                                   (n[1].ui, n[2].e, n[3].e, n[4].i,
13392                                    get_pointer(&n[5])));
13393             break;
13394          case OPCODE_NAMED_PROGRAM_LOCAL_PARAMETER:
13395             CALL_NamedProgramLocalParameter4fEXT(ctx->Exec,
13396                                             (n[1].ui, n[2].e, n[3].ui, n[4].f,
13397                                              n[5].f, n[6].f, n[7].f));
13398             break;
13399 
13400          case OPCODE_PRIMITIVE_BOUNDING_BOX:
13401             CALL_PrimitiveBoundingBox(ctx->Exec,
13402                                       (n[1].f, n[2].f, n[3].f, n[4].f,
13403                                        n[5].f, n[6].f, n[7].f, n[8].f));
13404             break;
13405          case OPCODE_VERTEX_LIST:
13406             vbo_save_playback_vertex_list(ctx, &n[1], false);
13407             break;
13408 
13409          case OPCODE_VERTEX_LIST_COPY_CURRENT:
13410             vbo_save_playback_vertex_list(ctx, &n[1], true);
13411             break;
13412 
13413          case OPCODE_VERTEX_LIST_LOOPBACK:
13414             vbo_save_playback_vertex_list_loopback(ctx, &n[1]);
13415             break;
13416 
13417          case OPCODE_CONTINUE:
13418             n = (Node *) get_pointer(&n[1]);
13419             continue;
13420          case OPCODE_NOP:
13421             /* no-op */
13422             break;
13423          default:
13424             {
13425                char msg[1000];
13426                snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d",
13427                              (int) opcode);
13428                _mesa_problem(ctx, "%s", msg);
13429             }
13430             FALLTHROUGH;
13431          case OPCODE_END_OF_LIST:
13432             return;
13433       }
13434 
13435       /* increment n to point to next compiled command */
13436       assert(n[0].InstSize > 0);
13437       n += n[0].InstSize;
13438    }
13439 }
13440 
13441 
13442 
13443 /**********************************************************************/
13444 /*                           GL functions                             */
13445 /**********************************************************************/
13446 
13447 /**
13448  * Test if a display list number is valid.
13449  */
13450 GLboolean GLAPIENTRY
_mesa_IsList(GLuint list)13451 _mesa_IsList(GLuint list)
13452 {
13453    GET_CURRENT_CONTEXT(ctx);
13454    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13455    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
13456    return _mesa_get_list(ctx, list, NULL, false);
13457 }
13458 
13459 
13460 /**
13461  * Delete a sequence of consecutive display lists.
13462  */
13463 void GLAPIENTRY
_mesa_DeleteLists(GLuint list,GLsizei range)13464 _mesa_DeleteLists(GLuint list, GLsizei range)
13465 {
13466    GET_CURRENT_CONTEXT(ctx);
13467    GLuint i;
13468    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13469    ASSERT_OUTSIDE_BEGIN_END(ctx);
13470 
13471    if (range < 0) {
13472       _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists");
13473       return;
13474    }
13475 
13476    if (range > 1) {
13477       /* We may be deleting a set of bitmap lists.  See if there's a
13478        * bitmap atlas to free.
13479        */
13480       struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, list);
13481       if (atlas) {
13482          _mesa_delete_bitmap_atlas(ctx, atlas);
13483          _mesa_HashRemove(ctx->Shared->BitmapAtlas, list);
13484       }
13485    }
13486 
13487    for (i = list; i < list + range; i++) {
13488       destroy_list(ctx, i);
13489    }
13490 }
13491 
13492 
13493 /**
13494  * Return a display list number, n, such that lists n through n+range-1
13495  * are free.
13496  */
13497 GLuint GLAPIENTRY
_mesa_GenLists(GLsizei range)13498 _mesa_GenLists(GLsizei range)
13499 {
13500    GET_CURRENT_CONTEXT(ctx);
13501    GLuint base;
13502    FLUSH_VERTICES(ctx, 0, 0);      /* must be called before assert */
13503    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
13504 
13505    if (range < 0) {
13506       _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists");
13507       return 0;
13508    }
13509    if (range == 0) {
13510       return 0;
13511    }
13512 
13513    /*
13514     * Make this an atomic operation
13515     */
13516    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13517 
13518    base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
13519    if (base) {
13520       /* reserve the list IDs by with empty/dummy lists */
13521       GLint i;
13522       for (i = 0; i < range; i++) {
13523          _mesa_HashInsertLocked(ctx->Shared->DisplayList, base + i,
13524                                 make_list(base + i, 1), true);
13525       }
13526    }
13527 
13528    if (USE_BITMAP_ATLAS &&
13529        range > 16 &&
13530        ctx->Driver.DrawAtlasBitmaps) {
13531       /* "range > 16" is a rough heuristic to guess when glGenLists might be
13532        * used to allocate display lists for glXUseXFont or wglUseFontBitmaps.
13533        * Create the empty atlas now.
13534        */
13535       struct gl_bitmap_atlas *atlas = lookup_bitmap_atlas(ctx, base);
13536       if (!atlas) {
13537          atlas = alloc_bitmap_atlas(ctx, base, true);
13538       }
13539       if (atlas) {
13540          /* Atlas _should_ be new/empty now, but clobbering is OK */
13541          assert(atlas->numBitmaps == 0);
13542          atlas->numBitmaps = range;
13543       }
13544    }
13545 
13546    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13547 
13548    return base;
13549 }
13550 
13551 
13552 /**
13553  * Begin a new display list.
13554  */
13555 void GLAPIENTRY
_mesa_NewList(GLuint name,GLenum mode)13556 _mesa_NewList(GLuint name, GLenum mode)
13557 {
13558    GET_CURRENT_CONTEXT(ctx);
13559 
13560    FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
13561    ASSERT_OUTSIDE_BEGIN_END(ctx);
13562 
13563    if (MESA_VERBOSE & VERBOSE_API)
13564       _mesa_debug(ctx, "glNewList %u %s\n", name,
13565                   _mesa_enum_to_string(mode));
13566 
13567    if (name == 0) {
13568       _mesa_error(ctx, GL_INVALID_VALUE, "glNewList");
13569       return;
13570    }
13571 
13572    if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
13573       _mesa_error(ctx, GL_INVALID_ENUM, "glNewList");
13574       return;
13575    }
13576 
13577    if (ctx->ListState.CurrentList) {
13578       /* already compiling a display list */
13579       _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList");
13580       return;
13581    }
13582 
13583    ctx->CompileFlag = GL_TRUE;
13584    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
13585 
13586    /* Reset accumulated list state */
13587    invalidate_saved_current_state( ctx );
13588 
13589    /* Allocate new display list */
13590    ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
13591    ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
13592    ctx->ListState.CurrentPos = 0;
13593    ctx->ListState.Current.UseLoopback = false;
13594 
13595    vbo_save_NewList(ctx, name, mode);
13596 
13597    ctx->CurrentServerDispatch = ctx->Save;
13598    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13599    if (ctx->MarshalExec == NULL) {
13600       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13601    }
13602 }
13603 
13604 
13605 /**
13606  * Walk all the opcode from a given list, recursively if OPCODE_CALL_LIST(S) is used,
13607  * and replace OPCODE_VERTEX_LIST[_COPY_CURRENT] occurences by OPCODE_VERTEX_LIST_LOOPBACK.
13608  */
13609 static void
replace_op_vertex_list_recursively(struct gl_context * ctx,struct gl_display_list * dlist)13610 replace_op_vertex_list_recursively(struct gl_context *ctx, struct gl_display_list *dlist)
13611 {
13612    Node *n = get_list_head(ctx, dlist);
13613    while (true) {
13614       const OpCode opcode = n[0].opcode;
13615       switch (opcode) {
13616          case OPCODE_VERTEX_LIST:
13617          case OPCODE_VERTEX_LIST_COPY_CURRENT:
13618             n[0].opcode = OPCODE_VERTEX_LIST_LOOPBACK;
13619             break;
13620          case OPCODE_CONTINUE:
13621             n = (Node *)get_pointer(&n[1]);
13622             continue;
13623          case OPCODE_CALL_LIST:
13624             replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)n[1].ui, true));
13625             break;
13626          case OPCODE_CALL_LISTS: {
13627             GLbyte *bptr;
13628             GLubyte *ubptr;
13629             GLshort *sptr;
13630             GLushort *usptr;
13631             GLint *iptr;
13632             GLuint *uiptr;
13633             GLfloat *fptr;
13634             switch(n[2].e) {
13635                case GL_BYTE:
13636                   bptr = (GLbyte *) get_pointer(&n[3]);
13637                   for (unsigned i = 0; i < n[1].i; i++)
13638                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)bptr[i], true));
13639                   break;
13640                case GL_UNSIGNED_BYTE:
13641                   ubptr = (GLubyte *) get_pointer(&n[3]);
13642                   for (unsigned i = 0; i < n[1].i; i++)
13643                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)ubptr[i], true));
13644                   break;
13645                case GL_SHORT:
13646                   sptr = (GLshort *) get_pointer(&n[3]);
13647                   for (unsigned i = 0; i < n[1].i; i++)
13648                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)sptr[i], true));
13649                   break;
13650                case GL_UNSIGNED_SHORT:
13651                   usptr = (GLushort *) get_pointer(&n[3]);
13652                   for (unsigned i = 0; i < n[1].i; i++)
13653                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)usptr[i], true));
13654                   break;
13655                case GL_INT:
13656                   iptr = (GLint *) get_pointer(&n[3]);
13657                   for (unsigned i = 0; i < n[1].i; i++)
13658                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)iptr[i], true));
13659                   break;
13660                case GL_UNSIGNED_INT:
13661                   uiptr = (GLuint *) get_pointer(&n[3]);
13662                   for (unsigned i = 0; i < n[1].i; i++)
13663                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)uiptr[i], true));
13664                   break;
13665                case GL_FLOAT:
13666                   fptr = (GLfloat *) get_pointer(&n[3]);
13667                   for (unsigned i = 0; i < n[1].i; i++)
13668                      replace_op_vertex_list_recursively(ctx, _mesa_lookup_list(ctx, (int)fptr[i], true));
13669                   break;
13670                case GL_2_BYTES:
13671                   ubptr = (GLubyte *) get_pointer(&n[3]);
13672                   for (unsigned i = 0; i < n[1].i; i++) {
13673                      replace_op_vertex_list_recursively(ctx,
13674                                                 _mesa_lookup_list(ctx, (int)ubptr[2 * i] * 256 +
13675                                                                        (int)ubptr[2 * i + 1], true));
13676                   }
13677                   break;
13678                case GL_3_BYTES:
13679                   ubptr = (GLubyte *) get_pointer(&n[3]);
13680                   for (unsigned i = 0; i < n[1].i; i++) {
13681                      replace_op_vertex_list_recursively(ctx,
13682                                                 _mesa_lookup_list(ctx, (int)ubptr[3 * i] * 65536 +
13683                                                                   (int)ubptr[3 * i + 1] * 256 +
13684                                                                   (int)ubptr[3 * i + 2], true));
13685                   }
13686                   break;
13687                case GL_4_BYTES:
13688                   ubptr = (GLubyte *) get_pointer(&n[3]);
13689                   for (unsigned i = 0; i < n[1].i; i++) {
13690                      replace_op_vertex_list_recursively(ctx,
13691                                                 _mesa_lookup_list(ctx, (int)ubptr[4 * i] * 16777216 +
13692                                                                   (int)ubptr[4 * i + 1] * 65536 +
13693                                                                   (int)ubptr[4 * i + 2] * 256 +
13694                                                                   (int)ubptr[4 * i + 3], true));
13695                   }
13696                   break;
13697                }
13698             break;
13699          }
13700          case OPCODE_END_OF_LIST:
13701             return;
13702          default:
13703             break;
13704       }
13705       n += n[0].InstSize;
13706    }
13707 }
13708 
13709 
13710 /**
13711  * End definition of current display list.
13712  */
13713 void GLAPIENTRY
_mesa_EndList(void)13714 _mesa_EndList(void)
13715 {
13716    GET_CURRENT_CONTEXT(ctx);
13717    SAVE_FLUSH_VERTICES(ctx);
13718    FLUSH_VERTICES(ctx, 0, 0);
13719 
13720    if (MESA_VERBOSE & VERBOSE_API)
13721       _mesa_debug(ctx, "glEndList\n");
13722 
13723    if (ctx->ExecuteFlag && _mesa_inside_dlist_begin_end(ctx)) {
13724       _mesa_error(ctx, GL_INVALID_OPERATION,
13725                   "glEndList() called inside glBegin/End");
13726    }
13727 
13728    /* Check that a list is under construction */
13729    if (!ctx->ListState.CurrentList) {
13730       _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
13731       return;
13732    }
13733 
13734    /* Call before emitting END_OF_LIST, in case the driver wants to
13735     * emit opcodes itself.
13736     */
13737    vbo_save_EndList(ctx);
13738 
13739    (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0);
13740 
13741    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13742 
13743    if (ctx->ListState.Current.UseLoopback)
13744       replace_op_vertex_list_recursively(ctx, ctx->ListState.CurrentList);
13745 
13746    struct gl_dlist_state *list = &ctx->ListState;
13747 
13748    if ((list->CurrentList->Head == list->CurrentBlock) &&
13749        (list->CurrentPos < BLOCK_SIZE)) {
13750       /* This list has a low number of commands. Instead of storing them in a malloc-ed block
13751        * of memory (list->CurrentBlock), we store them in ctx->Shared->small_dlist_store.ptr.
13752        * This reduces cache misses in execute_list on successive lists since their commands
13753        * are now stored in the same array instead of being scattered in memory.
13754        */
13755       list->CurrentList->small_list = true;
13756       unsigned start;
13757 
13758       if (ctx->Shared->small_dlist_store.size == 0) {
13759          util_idalloc_init(&ctx->Shared->small_dlist_store.free_idx, MAX2(1, list->CurrentPos));
13760       }
13761 
13762       start = util_idalloc_alloc_range(&ctx->Shared->small_dlist_store.free_idx, list->CurrentPos);
13763 
13764       if ((start + list->CurrentPos) > ctx->Shared->small_dlist_store.size) {
13765          ctx->Shared->small_dlist_store.size =
13766             ctx->Shared->small_dlist_store.free_idx.num_elements * 32;
13767          ctx->Shared->small_dlist_store.ptr = realloc(
13768             ctx->Shared->small_dlist_store.ptr,
13769             ctx->Shared->small_dlist_store.size * sizeof(Node));
13770       }
13771       list->CurrentList->start = start;
13772       list->CurrentList->count = list->CurrentPos;
13773 
13774       memcpy(&ctx->Shared->small_dlist_store.ptr[start],
13775              list->CurrentBlock,
13776              list->CurrentList->count * sizeof(Node));
13777 
13778       assert (ctx->Shared->small_dlist_store.ptr[start + list->CurrentList->count - 1].opcode == OPCODE_END_OF_LIST);
13779 
13780       /* If the first opcode is a NOP, adjust start */
13781       if (ctx->Shared->small_dlist_store.ptr[start].opcode == OPCODE_NOP) {
13782          list->CurrentList->start++;
13783          list->CurrentList->begins_with_a_nop = true;
13784       } else {
13785          list->CurrentList->begins_with_a_nop = false;
13786       }
13787 
13788       free(list->CurrentBlock);
13789    } else {
13790       /* Keep the mallocated storage */
13791       list->CurrentList->small_list = false;
13792       list->CurrentList->begins_with_a_nop = false;
13793    }
13794 
13795    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13796 
13797    /* Destroy old list, if any */
13798    destroy_list(ctx, ctx->ListState.CurrentList->Name);
13799 
13800    /* Install the new list */
13801    _mesa_HashInsertLocked(ctx->Shared->DisplayList,
13802                           ctx->ListState.CurrentList->Name,
13803                           ctx->ListState.CurrentList, true);
13804 
13805 
13806    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
13807       mesa_print_display_list(ctx->ListState.CurrentList->Name);
13808 
13809    ctx->ListState.CurrentList = NULL;
13810    ctx->ListState.CurrentBlock = NULL;
13811    ctx->ListState.CurrentPos = 0;
13812    ctx->ExecuteFlag = GL_TRUE;
13813    ctx->CompileFlag = GL_FALSE;
13814 
13815    ctx->CurrentServerDispatch = ctx->Exec;
13816    _glapi_set_dispatch(ctx->CurrentServerDispatch);
13817    if (ctx->MarshalExec == NULL) {
13818       ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13819    }
13820 }
13821 
13822 
13823 void GLAPIENTRY
_mesa_CallList(GLuint list)13824 _mesa_CallList(GLuint list)
13825 {
13826    GLboolean save_compile_flag;
13827    GET_CURRENT_CONTEXT(ctx);
13828    FLUSH_CURRENT(ctx, 0);
13829 
13830    if (MESA_VERBOSE & VERBOSE_API)
13831       _mesa_debug(ctx, "glCallList %d\n", list);
13832 
13833    if (list == 0) {
13834       _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
13835       return;
13836    }
13837 
13838    if (0)
13839       mesa_print_display_list( list );
13840 
13841    /* Save the CompileFlag status, turn it off, execute the display list,
13842     * and restore the CompileFlag. This is needed for GL_COMPILE_AND_EXECUTE
13843     * because the call is already recorded and we just need to execute it.
13844     */
13845    save_compile_flag = ctx->CompileFlag;
13846    if (save_compile_flag) {
13847       ctx->CompileFlag = GL_FALSE;
13848    }
13849 
13850    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13851    execute_list(ctx, list);
13852    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
13853    ctx->CompileFlag = save_compile_flag;
13854 
13855    /* also restore API function pointers to point to "save" versions */
13856    if (save_compile_flag) {
13857       ctx->CurrentServerDispatch = ctx->Save;
13858        _glapi_set_dispatch(ctx->CurrentServerDispatch);
13859       if (ctx->MarshalExec == NULL) {
13860          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
13861       }
13862    }
13863 }
13864 
13865 
13866 /**
13867  * Try to execute a glCallLists() command where the display lists contain
13868  * glBitmap commands with a texture atlas.
13869  * \return true for success, false otherwise
13870  */
13871 static bool
render_bitmap_atlas(struct gl_context * ctx,GLsizei n,GLenum type,const void * lists)13872 render_bitmap_atlas(struct gl_context *ctx, GLsizei n, GLenum type,
13873                     const void *lists)
13874 {
13875    struct gl_bitmap_atlas *atlas;
13876    int i;
13877 
13878    if (!USE_BITMAP_ATLAS ||
13879        !ctx->Current.RasterPosValid ||
13880        ctx->List.ListBase == 0 ||
13881        type != GL_UNSIGNED_BYTE ||
13882        !ctx->Driver.DrawAtlasBitmaps) {
13883       /* unsupported */
13884       return false;
13885    }
13886 
13887    atlas = lookup_bitmap_atlas(ctx, ctx->List.ListBase);
13888 
13889    if (!atlas) {
13890       /* Even if glGenLists wasn't called, we can still try to create
13891        * the atlas now.
13892        */
13893       atlas = alloc_bitmap_atlas(ctx, ctx->List.ListBase, false);
13894    }
13895 
13896    if (atlas && !atlas->complete && !atlas->incomplete) {
13897       /* Try to build the bitmap atlas now.
13898        * If the atlas was created in glGenLists, we'll have recorded the
13899        * number of lists (bitmaps).  Otherwise, take a guess at 256.
13900        */
13901       if (atlas->numBitmaps == 0)
13902          atlas->numBitmaps = 256;
13903       build_bitmap_atlas(ctx, atlas, ctx->List.ListBase);
13904    }
13905 
13906    if (!atlas || !atlas->complete) {
13907       return false;
13908    }
13909 
13910    /* check that all display list IDs are in the atlas */
13911    for (i = 0; i < n; i++) {
13912       const GLubyte *ids = (const GLubyte *) lists;
13913 
13914       if (ids[i] >= atlas->numBitmaps) {
13915          return false;
13916       }
13917    }
13918 
13919    ctx->Driver.DrawAtlasBitmaps(ctx, atlas, n, (const GLubyte *) lists);
13920 
13921    return true;
13922 }
13923 
13924 
13925 /**
13926  * Execute glCallLists:  call multiple display lists.
13927  */
13928 void GLAPIENTRY
_mesa_CallLists(GLsizei n,GLenum type,const GLvoid * lists)13929 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
13930 {
13931    GET_CURRENT_CONTEXT(ctx);
13932    GLboolean save_compile_flag;
13933 
13934    if (MESA_VERBOSE & VERBOSE_API)
13935       _mesa_debug(ctx, "glCallLists %d\n", n);
13936 
13937    if (type < GL_BYTE || type > GL_4_BYTES) {
13938       _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
13939       return;
13940    }
13941 
13942    if (n < 0) {
13943       _mesa_error(ctx, GL_INVALID_VALUE, "glCallLists(n < 0)");
13944       return;
13945    } else if (n == 0 || lists == NULL) {
13946       /* nothing to do */
13947       return;
13948    }
13949 
13950    if (render_bitmap_atlas(ctx, n, type, lists)) {
13951       return;
13952    }
13953 
13954    /* Save the CompileFlag status, turn it off, execute the display lists,
13955     * and restore the CompileFlag. This is needed for GL_COMPILE_AND_EXECUTE
13956     * because the call is already recorded and we just need to execute it.
13957     */
13958    save_compile_flag = ctx->CompileFlag;
13959    ctx->CompileFlag = GL_FALSE;
13960 
13961    GLbyte *bptr;
13962    GLubyte *ubptr;
13963    GLshort *sptr;
13964    GLushort *usptr;
13965    GLint *iptr;
13966    GLuint *uiptr;
13967    GLfloat *fptr;
13968 
13969    GLuint base = ctx->List.ListBase;
13970 
13971    _mesa_HashLockMutex(ctx->Shared->DisplayList);
13972 
13973    /* A loop inside a switch is faster than a switch inside a loop. */
13974    switch (type) {
13975    case GL_BYTE:
13976       bptr = (GLbyte *) lists;
13977       for (unsigned i = 0; i < n; i++)
13978          execute_list(ctx, base + (int)bptr[i]);
13979       break;
13980    case GL_UNSIGNED_BYTE:
13981       ubptr = (GLubyte *) lists;
13982       for (unsigned i = 0; i < n; i++)
13983          execute_list(ctx, base + (int)ubptr[i]);
13984       break;
13985    case GL_SHORT:
13986       sptr = (GLshort *) lists;
13987       for (unsigned i = 0; i < n; i++)
13988          execute_list(ctx, base + (int)sptr[i]);
13989       break;
13990    case GL_UNSIGNED_SHORT:
13991       usptr = (GLushort *) lists;
13992       for (unsigned i = 0; i < n; i++)
13993          execute_list(ctx, base + (int)usptr[i]);
13994       break;
13995    case GL_INT:
13996       iptr = (GLint *) lists;
13997       for (unsigned i = 0; i < n; i++)
13998          execute_list(ctx, base + (int)iptr[i]);
13999       break;
14000    case GL_UNSIGNED_INT:
14001       uiptr = (GLuint *) lists;
14002       for (unsigned i = 0; i < n; i++)
14003          execute_list(ctx, base + (int)uiptr[i]);
14004       break;
14005    case GL_FLOAT:
14006       fptr = (GLfloat *) lists;
14007       for (unsigned i = 0; i < n; i++)
14008          execute_list(ctx, base + (int)fptr[i]);
14009       break;
14010    case GL_2_BYTES:
14011       ubptr = (GLubyte *) lists;
14012       for (unsigned i = 0; i < n; i++) {
14013          execute_list(ctx, base +
14014                       (int)ubptr[2 * i] * 256 +
14015                       (int)ubptr[2 * i + 1]);
14016       }
14017       break;
14018    case GL_3_BYTES:
14019       ubptr = (GLubyte *) lists;
14020       for (unsigned i = 0; i < n; i++) {
14021          execute_list(ctx, base +
14022                       (int)ubptr[3 * i] * 65536 +
14023                       (int)ubptr[3 * i + 1] * 256 +
14024                       (int)ubptr[3 * i + 2]);
14025       }
14026       break;
14027    case GL_4_BYTES:
14028       ubptr = (GLubyte *) lists;
14029       for (unsigned i = 0; i < n; i++) {
14030          execute_list(ctx, base +
14031                       (int)ubptr[4 * i] * 16777216 +
14032                       (int)ubptr[4 * i + 1] * 65536 +
14033                       (int)ubptr[4 * i + 2] * 256 +
14034                       (int)ubptr[4 * i + 3]);
14035       }
14036       break;
14037    }
14038 
14039    _mesa_HashUnlockMutex(ctx->Shared->DisplayList);
14040    ctx->CompileFlag = save_compile_flag;
14041 
14042    /* also restore API function pointers to point to "save" versions */
14043    if (save_compile_flag) {
14044       ctx->CurrentServerDispatch = ctx->Save;
14045       _glapi_set_dispatch(ctx->CurrentServerDispatch);
14046       if (ctx->MarshalExec == NULL) {
14047          ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
14048       }
14049    }
14050 }
14051 
14052 
14053 /**
14054  * Set the offset added to list numbers in glCallLists.
14055  */
14056 void GLAPIENTRY
_mesa_ListBase(GLuint base)14057 _mesa_ListBase(GLuint base)
14058 {
14059    GET_CURRENT_CONTEXT(ctx);
14060    FLUSH_VERTICES(ctx, 0, GL_LIST_BIT);   /* must be called before assert */
14061    ASSERT_OUTSIDE_BEGIN_END(ctx);
14062    ctx->List.ListBase = base;
14063 }
14064 
14065 /**
14066  * Setup the given dispatch table to point to Mesa's display list
14067  * building functions.
14068  *
14069  * This does not include any of the tnl functions - they are
14070  * initialized from _mesa_init_api_defaults and from the active vtxfmt
14071  * struct.
14072  */
14073 void
_mesa_initialize_save_table(const struct gl_context * ctx)14074 _mesa_initialize_save_table(const struct gl_context *ctx)
14075 {
14076    struct _glapi_table *table = ctx->Save;
14077    int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size());
14078 
14079    /* Initially populate the dispatch table with the contents of the
14080     * normal-execution dispatch table.  This lets us skip populating functions
14081     * that should be called directly instead of compiled into display lists.
14082     */
14083    memcpy(table, ctx->Exec, numEntries * sizeof(_glapi_proc));
14084 
14085    /* VBO functions */
14086    vbo_initialize_save_dispatch(ctx, table);
14087 
14088    /* GL 1.0 */
14089    SET_Accum(table, save_Accum);
14090    SET_AlphaFunc(table, save_AlphaFunc);
14091    SET_Bitmap(table, save_Bitmap);
14092    SET_BlendFunc(table, save_BlendFunc);
14093    SET_CallList(table, save_CallList);
14094    SET_CallLists(table, save_CallLists);
14095    SET_Clear(table, save_Clear);
14096    SET_ClearAccum(table, save_ClearAccum);
14097    SET_ClearColor(table, save_ClearColor);
14098    SET_ClearDepth(table, save_ClearDepth);
14099    SET_ClearIndex(table, save_ClearIndex);
14100    SET_ClearStencil(table, save_ClearStencil);
14101    SET_ClipPlane(table, save_ClipPlane);
14102    SET_ColorMask(table, save_ColorMask);
14103    SET_ColorMaski(table, save_ColorMaskIndexed);
14104    SET_ColorMaterial(table, save_ColorMaterial);
14105    SET_CopyPixels(table, save_CopyPixels);
14106    SET_CullFace(table, save_CullFace);
14107    SET_DepthFunc(table, save_DepthFunc);
14108    SET_DepthMask(table, save_DepthMask);
14109    SET_DepthRange(table, save_DepthRange);
14110    SET_Disable(table, save_Disable);
14111    SET_Disablei(table, save_DisableIndexed);
14112    SET_DrawBuffer(table, save_DrawBuffer);
14113    SET_DrawPixels(table, save_DrawPixels);
14114    SET_Enable(table, save_Enable);
14115    SET_Enablei(table, save_EnableIndexed);
14116    SET_EvalMesh1(table, save_EvalMesh1);
14117    SET_EvalMesh2(table, save_EvalMesh2);
14118    SET_Fogf(table, save_Fogf);
14119    SET_Fogfv(table, save_Fogfv);
14120    SET_Fogi(table, save_Fogi);
14121    SET_Fogiv(table, save_Fogiv);
14122    SET_FrontFace(table, save_FrontFace);
14123    SET_Frustum(table, save_Frustum);
14124    SET_Hint(table, save_Hint);
14125    SET_IndexMask(table, save_IndexMask);
14126    SET_InitNames(table, save_InitNames);
14127    SET_LightModelf(table, save_LightModelf);
14128    SET_LightModelfv(table, save_LightModelfv);
14129    SET_LightModeli(table, save_LightModeli);
14130    SET_LightModeliv(table, save_LightModeliv);
14131    SET_Lightf(table, save_Lightf);
14132    SET_Lightfv(table, save_Lightfv);
14133    SET_Lighti(table, save_Lighti);
14134    SET_Lightiv(table, save_Lightiv);
14135    SET_LineStipple(table, save_LineStipple);
14136    SET_LineWidth(table, save_LineWidth);
14137    SET_ListBase(table, save_ListBase);
14138    SET_LoadIdentity(table, save_LoadIdentity);
14139    SET_LoadMatrixd(table, save_LoadMatrixd);
14140    SET_LoadMatrixf(table, save_LoadMatrixf);
14141    SET_LoadName(table, save_LoadName);
14142    SET_LogicOp(table, save_LogicOp);
14143    SET_Map1d(table, save_Map1d);
14144    SET_Map1f(table, save_Map1f);
14145    SET_Map2d(table, save_Map2d);
14146    SET_Map2f(table, save_Map2f);
14147    SET_MapGrid1d(table, save_MapGrid1d);
14148    SET_MapGrid1f(table, save_MapGrid1f);
14149    SET_MapGrid2d(table, save_MapGrid2d);
14150    SET_MapGrid2f(table, save_MapGrid2f);
14151    SET_MatrixMode(table, save_MatrixMode);
14152    SET_MultMatrixd(table, save_MultMatrixd);
14153    SET_MultMatrixf(table, save_MultMatrixf);
14154    SET_NewList(table, save_NewList);
14155    SET_Ortho(table, save_Ortho);
14156    SET_PassThrough(table, save_PassThrough);
14157    SET_PixelMapfv(table, save_PixelMapfv);
14158    SET_PixelMapuiv(table, save_PixelMapuiv);
14159    SET_PixelMapusv(table, save_PixelMapusv);
14160    SET_PixelTransferf(table, save_PixelTransferf);
14161    SET_PixelTransferi(table, save_PixelTransferi);
14162    SET_PixelZoom(table, save_PixelZoom);
14163    SET_PointSize(table, save_PointSize);
14164    SET_PolygonMode(table, save_PolygonMode);
14165    SET_PolygonOffset(table, save_PolygonOffset);
14166    SET_PolygonStipple(table, save_PolygonStipple);
14167    SET_PopAttrib(table, save_PopAttrib);
14168    SET_PopMatrix(table, save_PopMatrix);
14169    SET_PopName(table, save_PopName);
14170    SET_PushAttrib(table, save_PushAttrib);
14171    SET_PushMatrix(table, save_PushMatrix);
14172    SET_PushName(table, save_PushName);
14173    SET_RasterPos2d(table, save_RasterPos2d);
14174    SET_RasterPos2dv(table, save_RasterPos2dv);
14175    SET_RasterPos2f(table, save_RasterPos2f);
14176    SET_RasterPos2fv(table, save_RasterPos2fv);
14177    SET_RasterPos2i(table, save_RasterPos2i);
14178    SET_RasterPos2iv(table, save_RasterPos2iv);
14179    SET_RasterPos2s(table, save_RasterPos2s);
14180    SET_RasterPos2sv(table, save_RasterPos2sv);
14181    SET_RasterPos3d(table, save_RasterPos3d);
14182    SET_RasterPos3dv(table, save_RasterPos3dv);
14183    SET_RasterPos3f(table, save_RasterPos3f);
14184    SET_RasterPos3fv(table, save_RasterPos3fv);
14185    SET_RasterPos3i(table, save_RasterPos3i);
14186    SET_RasterPos3iv(table, save_RasterPos3iv);
14187    SET_RasterPos3s(table, save_RasterPos3s);
14188    SET_RasterPos3sv(table, save_RasterPos3sv);
14189    SET_RasterPos4d(table, save_RasterPos4d);
14190    SET_RasterPos4dv(table, save_RasterPos4dv);
14191    SET_RasterPos4f(table, save_RasterPos4f);
14192    SET_RasterPos4fv(table, save_RasterPos4fv);
14193    SET_RasterPos4i(table, save_RasterPos4i);
14194    SET_RasterPos4iv(table, save_RasterPos4iv);
14195    SET_RasterPos4s(table, save_RasterPos4s);
14196    SET_RasterPos4sv(table, save_RasterPos4sv);
14197    SET_ReadBuffer(table, save_ReadBuffer);
14198    SET_Rotated(table, save_Rotated);
14199    SET_Rotatef(table, save_Rotatef);
14200    SET_Scaled(table, save_Scaled);
14201    SET_Scalef(table, save_Scalef);
14202    SET_Scissor(table, save_Scissor);
14203    SET_ShadeModel(table, save_ShadeModel);
14204    SET_StencilFunc(table, save_StencilFunc);
14205    SET_StencilMask(table, save_StencilMask);
14206    SET_StencilOp(table, save_StencilOp);
14207    SET_TexEnvf(table, save_TexEnvf);
14208    SET_TexEnvfv(table, save_TexEnvfv);
14209    SET_TexEnvi(table, save_TexEnvi);
14210    SET_TexEnviv(table, save_TexEnviv);
14211    SET_TexGend(table, save_TexGend);
14212    SET_TexGendv(table, save_TexGendv);
14213    SET_TexGenf(table, save_TexGenf);
14214    SET_TexGenfv(table, save_TexGenfv);
14215    SET_TexGeni(table, save_TexGeni);
14216    SET_TexGeniv(table, save_TexGeniv);
14217    SET_TexImage1D(table, save_TexImage1D);
14218    SET_TexImage2D(table, save_TexImage2D);
14219    SET_TexParameterf(table, save_TexParameterf);
14220    SET_TexParameterfv(table, save_TexParameterfv);
14221    SET_TexParameteri(table, save_TexParameteri);
14222    SET_TexParameteriv(table, save_TexParameteriv);
14223    SET_Translated(table, save_Translated);
14224    SET_Translatef(table, save_Translatef);
14225    SET_Viewport(table, save_Viewport);
14226 
14227    /* GL 1.1 */
14228    SET_BindTexture(table, save_BindTexture);
14229    SET_CopyTexImage1D(table, save_CopyTexImage1D);
14230    SET_CopyTexImage2D(table, save_CopyTexImage2D);
14231    SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
14232    SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
14233    SET_PrioritizeTextures(table, save_PrioritizeTextures);
14234    SET_TexSubImage1D(table, save_TexSubImage1D);
14235    SET_TexSubImage2D(table, save_TexSubImage2D);
14236 
14237    /* GL 1.2 */
14238    SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
14239    SET_TexImage3D(table, save_TexImage3D);
14240    SET_TexSubImage3D(table, save_TexSubImage3D);
14241 
14242    /* GL 2.0 */
14243    SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
14244    SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
14245    SET_StencilOpSeparate(table, save_StencilOpSeparate);
14246 
14247    /* ATI_separate_stencil */
14248    SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
14249 
14250    /* GL_ARB_imaging */
14251    /* Not all are supported */
14252    SET_BlendColor(table, save_BlendColor);
14253    SET_BlendEquation(table, save_BlendEquation);
14254 
14255    /* 2. GL_EXT_blend_color */
14256 #if 0
14257    SET_BlendColorEXT(table, save_BlendColorEXT);
14258 #endif
14259 
14260    /* 6. GL_EXT_texture3d */
14261 #if 0
14262    SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
14263    SET_TexImage3DEXT(table, save_TexImage3DEXT);
14264    SET_TexSubImage3DEXT(table, save_TexSubImage3D);
14265 #endif
14266 
14267    /* 37. GL_EXT_blend_minmax */
14268 #if 0
14269    SET_BlendEquationEXT(table, save_BlendEquationEXT);
14270 #endif
14271 
14272    /* 54. GL_EXT_point_parameters */
14273    SET_PointParameterf(table, save_PointParameterfEXT);
14274    SET_PointParameterfv(table, save_PointParameterfvEXT);
14275 
14276    /* 91. GL_ARB_tessellation_shader */
14277    SET_PatchParameteri(table, save_PatchParameteri);
14278    SET_PatchParameterfv(table, save_PatchParameterfv);
14279 
14280    /* 100. ARB_viewport_array */
14281    SET_ViewportArrayv(table, save_ViewportArrayv);
14282    SET_ViewportIndexedf(table, save_ViewportIndexedf);
14283    SET_ViewportIndexedfv(table, save_ViewportIndexedfv);
14284    SET_ScissorArrayv(table, save_ScissorArrayv);
14285    SET_ScissorIndexed(table, save_ScissorIndexed);
14286    SET_ScissorIndexedv(table, save_ScissorIndexedv);
14287    SET_DepthRangeArrayv(table, save_DepthRangeArrayv);
14288    SET_DepthRangeIndexed(table, save_DepthRangeIndexed);
14289 
14290    /* 122. ARB_compute_shader */
14291    SET_DispatchCompute(table, save_DispatchCompute);
14292    SET_DispatchComputeIndirect(table, save_DispatchComputeIndirect);
14293 
14294    /* 173. GL_EXT_blend_func_separate */
14295    SET_BlendFuncSeparate(table, save_BlendFuncSeparateEXT);
14296 
14297    /* 197. GL_MESA_window_pos */
14298    SET_WindowPos2d(table, save_WindowPos2dMESA);
14299    SET_WindowPos2dv(table, save_WindowPos2dvMESA);
14300    SET_WindowPos2f(table, save_WindowPos2fMESA);
14301    SET_WindowPos2fv(table, save_WindowPos2fvMESA);
14302    SET_WindowPos2i(table, save_WindowPos2iMESA);
14303    SET_WindowPos2iv(table, save_WindowPos2ivMESA);
14304    SET_WindowPos2s(table, save_WindowPos2sMESA);
14305    SET_WindowPos2sv(table, save_WindowPos2svMESA);
14306    SET_WindowPos3d(table, save_WindowPos3dMESA);
14307    SET_WindowPos3dv(table, save_WindowPos3dvMESA);
14308    SET_WindowPos3f(table, save_WindowPos3fMESA);
14309    SET_WindowPos3fv(table, save_WindowPos3fvMESA);
14310    SET_WindowPos3i(table, save_WindowPos3iMESA);
14311    SET_WindowPos3iv(table, save_WindowPos3ivMESA);
14312    SET_WindowPos3s(table, save_WindowPos3sMESA);
14313    SET_WindowPos3sv(table, save_WindowPos3svMESA);
14314    SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
14315    SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
14316    SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
14317    SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
14318    SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
14319    SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
14320    SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
14321    SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
14322 
14323    /* 245. GL_ATI_fragment_shader */
14324    SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
14325    SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
14326 
14327    /* 262. GL_ARB_point_sprite */
14328    SET_PointParameteri(table, save_PointParameteri);
14329    SET_PointParameteriv(table, save_PointParameteriv);
14330 
14331    /* 268. GL_EXT_stencil_two_side */
14332    SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
14333 
14334    /* ???. GL_EXT_depth_bounds_test */
14335    SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
14336 
14337    /* ARB 1. GL_ARB_multitexture */
14338    SET_ActiveTexture(table, save_ActiveTextureARB);
14339 
14340    /* ARB 3. GL_ARB_transpose_matrix */
14341    SET_LoadTransposeMatrixd(table, save_LoadTransposeMatrixdARB);
14342    SET_LoadTransposeMatrixf(table, save_LoadTransposeMatrixfARB);
14343    SET_MultTransposeMatrixd(table, save_MultTransposeMatrixdARB);
14344    SET_MultTransposeMatrixf(table, save_MultTransposeMatrixfARB);
14345 
14346    /* ARB 5. GL_ARB_multisample */
14347    SET_SampleCoverage(table, save_SampleCoverageARB);
14348 
14349    /* ARB 12. GL_ARB_texture_compression */
14350    SET_CompressedTexImage3D(table, save_CompressedTexImage3DARB);
14351    SET_CompressedTexImage2D(table, save_CompressedTexImage2DARB);
14352    SET_CompressedTexImage1D(table, save_CompressedTexImage1DARB);
14353    SET_CompressedTexSubImage3D(table, save_CompressedTexSubImage3DARB);
14354    SET_CompressedTexSubImage2D(table, save_CompressedTexSubImage2DARB);
14355    SET_CompressedTexSubImage1D(table, save_CompressedTexSubImage1DARB);
14356 
14357    /* ARB 14. GL_ARB_point_parameters */
14358    /* aliased with EXT_point_parameters functions */
14359 
14360    /* ARB 25. GL_ARB_window_pos */
14361    /* aliased with MESA_window_pos functions */
14362 
14363    /* ARB 26. GL_ARB_vertex_program */
14364    /* ARB 27. GL_ARB_fragment_program */
14365    /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
14366    SET_ProgramStringARB(table, save_ProgramStringARB);
14367    SET_BindProgramARB(table, save_BindProgramARB);
14368    SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
14369    SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
14370    SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
14371    SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
14372    SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
14373    SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
14374    SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
14375    SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
14376 
14377    SET_BeginQuery(table, save_BeginQueryARB);
14378    SET_EndQuery(table, save_EndQueryARB);
14379    SET_QueryCounter(table, save_QueryCounter);
14380 
14381    SET_DrawBuffers(table, save_DrawBuffersARB);
14382 
14383    SET_BlitFramebuffer(table, save_BlitFramebufferEXT);
14384 
14385    SET_UseProgram(table, save_UseProgram);
14386    SET_Uniform1f(table, save_Uniform1fARB);
14387    SET_Uniform2f(table, save_Uniform2fARB);
14388    SET_Uniform3f(table, save_Uniform3fARB);
14389    SET_Uniform4f(table, save_Uniform4fARB);
14390    SET_Uniform1fv(table, save_Uniform1fvARB);
14391    SET_Uniform2fv(table, save_Uniform2fvARB);
14392    SET_Uniform3fv(table, save_Uniform3fvARB);
14393    SET_Uniform4fv(table, save_Uniform4fvARB);
14394    SET_Uniform1i(table, save_Uniform1iARB);
14395    SET_Uniform2i(table, save_Uniform2iARB);
14396    SET_Uniform3i(table, save_Uniform3iARB);
14397    SET_Uniform4i(table, save_Uniform4iARB);
14398    SET_Uniform1iv(table, save_Uniform1ivARB);
14399    SET_Uniform2iv(table, save_Uniform2ivARB);
14400    SET_Uniform3iv(table, save_Uniform3ivARB);
14401    SET_Uniform4iv(table, save_Uniform4ivARB);
14402    SET_UniformMatrix2fv(table, save_UniformMatrix2fvARB);
14403    SET_UniformMatrix3fv(table, save_UniformMatrix3fvARB);
14404    SET_UniformMatrix4fv(table, save_UniformMatrix4fvARB);
14405    SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv);
14406    SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv);
14407    SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv);
14408    SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv);
14409    SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv);
14410    SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv);
14411 
14412    /* 299. GL_EXT_blend_equation_separate */
14413    SET_BlendEquationSeparate(table, save_BlendEquationSeparateEXT);
14414 
14415    /* GL_EXT_gpu_program_parameters */
14416    SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT);
14417    SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT);
14418 
14419    /* 364. GL_EXT_provoking_vertex */
14420    SET_ProvokingVertex(table, save_ProvokingVertexEXT);
14421 
14422    /* GL_EXT_texture_integer */
14423    SET_ClearColorIiEXT(table, save_ClearColorIi);
14424    SET_ClearColorIuiEXT(table, save_ClearColorIui);
14425    SET_TexParameterIiv(table, save_TexParameterIiv);
14426    SET_TexParameterIuiv(table, save_TexParameterIuiv);
14427 
14428    /* GL_ARB_clip_control */
14429    SET_ClipControl(table, save_ClipControl);
14430 
14431    /* GL_ARB_color_buffer_float */
14432    SET_ClampColor(table, save_ClampColorARB);
14433 
14434    /* GL 3.0 */
14435    SET_ClearBufferiv(table, save_ClearBufferiv);
14436    SET_ClearBufferuiv(table, save_ClearBufferuiv);
14437    SET_ClearBufferfv(table, save_ClearBufferfv);
14438    SET_ClearBufferfi(table, save_ClearBufferfi);
14439    SET_Uniform1ui(table, save_Uniform1ui);
14440    SET_Uniform2ui(table, save_Uniform2ui);
14441    SET_Uniform3ui(table, save_Uniform3ui);
14442    SET_Uniform4ui(table, save_Uniform4ui);
14443    SET_Uniform1uiv(table, save_Uniform1uiv);
14444    SET_Uniform2uiv(table, save_Uniform2uiv);
14445    SET_Uniform3uiv(table, save_Uniform3uiv);
14446    SET_Uniform4uiv(table, save_Uniform4uiv);
14447 
14448    /* GL_ARB_gpu_shader_fp64 */
14449    SET_Uniform1d(table, save_Uniform1d);
14450    SET_Uniform2d(table, save_Uniform2d);
14451    SET_Uniform3d(table, save_Uniform3d);
14452    SET_Uniform4d(table, save_Uniform4d);
14453    SET_Uniform1dv(table, save_Uniform1dv);
14454    SET_Uniform2dv(table, save_Uniform2dv);
14455    SET_Uniform3dv(table, save_Uniform3dv);
14456    SET_Uniform4dv(table, save_Uniform4dv);
14457    SET_UniformMatrix2dv(table, save_UniformMatrix2dv);
14458    SET_UniformMatrix3dv(table, save_UniformMatrix3dv);
14459    SET_UniformMatrix4dv(table, save_UniformMatrix4dv);
14460    SET_UniformMatrix2x3dv(table, save_UniformMatrix2x3dv);
14461    SET_UniformMatrix3x2dv(table, save_UniformMatrix3x2dv);
14462    SET_UniformMatrix2x4dv(table, save_UniformMatrix2x4dv);
14463    SET_UniformMatrix4x2dv(table, save_UniformMatrix4x2dv);
14464    SET_UniformMatrix3x4dv(table, save_UniformMatrix3x4dv);
14465    SET_UniformMatrix4x3dv(table, save_UniformMatrix4x3dv);
14466 
14467    /* GL_ARB_gpu_shader_int64 */
14468    SET_Uniform1i64ARB(table, save_Uniform1i64ARB);
14469    SET_Uniform2i64ARB(table, save_Uniform2i64ARB);
14470    SET_Uniform3i64ARB(table, save_Uniform3i64ARB);
14471    SET_Uniform4i64ARB(table, save_Uniform4i64ARB);
14472    SET_Uniform1i64vARB(table, save_Uniform1i64vARB);
14473    SET_Uniform2i64vARB(table, save_Uniform2i64vARB);
14474    SET_Uniform3i64vARB(table, save_Uniform3i64vARB);
14475    SET_Uniform4i64vARB(table, save_Uniform4i64vARB);
14476    SET_Uniform1ui64ARB(table, save_Uniform1ui64ARB);
14477    SET_Uniform2ui64ARB(table, save_Uniform2ui64ARB);
14478    SET_Uniform3ui64ARB(table, save_Uniform3ui64ARB);
14479    SET_Uniform4ui64ARB(table, save_Uniform4ui64ARB);
14480    SET_Uniform1ui64vARB(table, save_Uniform1ui64vARB);
14481    SET_Uniform2ui64vARB(table, save_Uniform2ui64vARB);
14482    SET_Uniform3ui64vARB(table, save_Uniform3ui64vARB);
14483    SET_Uniform4ui64vARB(table, save_Uniform4ui64vARB);
14484 
14485    SET_ProgramUniform1i64ARB(table, save_ProgramUniform1i64ARB);
14486    SET_ProgramUniform2i64ARB(table, save_ProgramUniform2i64ARB);
14487    SET_ProgramUniform3i64ARB(table, save_ProgramUniform3i64ARB);
14488    SET_ProgramUniform4i64ARB(table, save_ProgramUniform4i64ARB);
14489    SET_ProgramUniform1i64vARB(table, save_ProgramUniform1i64vARB);
14490    SET_ProgramUniform2i64vARB(table, save_ProgramUniform2i64vARB);
14491    SET_ProgramUniform3i64vARB(table, save_ProgramUniform3i64vARB);
14492    SET_ProgramUniform4i64vARB(table, save_ProgramUniform4i64vARB);
14493    SET_ProgramUniform1ui64ARB(table, save_ProgramUniform1ui64ARB);
14494    SET_ProgramUniform2ui64ARB(table, save_ProgramUniform2ui64ARB);
14495    SET_ProgramUniform3ui64ARB(table, save_ProgramUniform3ui64ARB);
14496    SET_ProgramUniform4ui64ARB(table, save_ProgramUniform4ui64ARB);
14497    SET_ProgramUniform1ui64vARB(table, save_ProgramUniform1ui64vARB);
14498    SET_ProgramUniform2ui64vARB(table, save_ProgramUniform2ui64vARB);
14499    SET_ProgramUniform3ui64vARB(table, save_ProgramUniform3ui64vARB);
14500    SET_ProgramUniform4ui64vARB(table, save_ProgramUniform4ui64vARB);
14501 
14502    /* These are: */
14503    SET_BeginTransformFeedback(table, save_BeginTransformFeedback);
14504    SET_EndTransformFeedback(table, save_EndTransformFeedback);
14505    SET_BindTransformFeedback(table, save_BindTransformFeedback);
14506    SET_PauseTransformFeedback(table, save_PauseTransformFeedback);
14507    SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback);
14508    SET_DrawTransformFeedback(table, save_DrawTransformFeedback);
14509    SET_DrawTransformFeedbackStream(table, save_DrawTransformFeedbackStream);
14510    SET_DrawTransformFeedbackInstanced(table,
14511                                       save_DrawTransformFeedbackInstanced);
14512    SET_DrawTransformFeedbackStreamInstanced(table,
14513                                 save_DrawTransformFeedbackStreamInstanced);
14514    SET_BeginQueryIndexed(table, save_BeginQueryIndexed);
14515    SET_EndQueryIndexed(table, save_EndQueryIndexed);
14516 
14517    /* GL_ARB_instanced_arrays */
14518    SET_VertexAttribDivisor(table, save_VertexAttribDivisor);
14519 
14520    /* GL_NV_texture_barrier */
14521    SET_TextureBarrierNV(table, save_TextureBarrierNV);
14522 
14523    SET_BindSampler(table, save_BindSampler);
14524    SET_SamplerParameteri(table, save_SamplerParameteri);
14525    SET_SamplerParameterf(table, save_SamplerParameterf);
14526    SET_SamplerParameteriv(table, save_SamplerParameteriv);
14527    SET_SamplerParameterfv(table, save_SamplerParameterfv);
14528    SET_SamplerParameterIiv(table, save_SamplerParameterIiv);
14529    SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv);
14530 
14531    /* GL_ARB_draw_buffer_blend */
14532    SET_BlendFunciARB(table, save_BlendFunci);
14533    SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei);
14534    SET_BlendEquationiARB(table, save_BlendEquationi);
14535    SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
14536 
14537    /* GL_NV_conditional_render */
14538    SET_BeginConditionalRender(table, save_BeginConditionalRender);
14539    SET_EndConditionalRender(table, save_EndConditionalRender);
14540 
14541    /* GL_ARB_sync */
14542    SET_WaitSync(table, save_WaitSync);
14543 
14544    /* GL_ARB_uniform_buffer_object */
14545    SET_UniformBlockBinding(table, save_UniformBlockBinding);
14546 
14547    /* GL_ARB_shader_subroutines */
14548    SET_UniformSubroutinesuiv(table, save_UniformSubroutinesuiv);
14549 
14550    /* GL_ARB_draw_instanced */
14551    SET_DrawArraysInstancedARB(table, save_DrawArraysInstancedARB);
14552    SET_DrawElementsInstancedARB(table, save_DrawElementsInstancedARB);
14553 
14554    /* GL_ARB_draw_elements_base_vertex */
14555    SET_DrawElementsInstancedBaseVertex(table, save_DrawElementsInstancedBaseVertexARB);
14556 
14557    /* GL_ARB_base_instance */
14558    SET_DrawArraysInstancedBaseInstance(table, save_DrawArraysInstancedBaseInstance);
14559    SET_DrawElementsInstancedBaseInstance(table, save_DrawElementsInstancedBaseInstance);
14560    SET_DrawElementsInstancedBaseVertexBaseInstance(table, save_DrawElementsInstancedBaseVertexBaseInstance);
14561 
14562    /* GL_ARB_draw_indirect / GL_ARB_multi_draw_indirect */
14563    SET_DrawArraysIndirect(table, save_DrawArraysIndirect);
14564    SET_DrawElementsIndirect(table, save_DrawElementsIndirect);
14565    SET_MultiDrawArraysIndirect(table, save_MultiDrawArraysIndirect);
14566    SET_MultiDrawElementsIndirect(table, save_MultiDrawElementsIndirect);
14567 
14568    /* OpenGL 4.2 / GL_ARB_separate_shader_objects */
14569    SET_UseProgramStages(table, save_UseProgramStages);
14570    SET_ProgramUniform1f(table, save_ProgramUniform1f);
14571    SET_ProgramUniform2f(table, save_ProgramUniform2f);
14572    SET_ProgramUniform3f(table, save_ProgramUniform3f);
14573    SET_ProgramUniform4f(table, save_ProgramUniform4f);
14574    SET_ProgramUniform1fv(table, save_ProgramUniform1fv);
14575    SET_ProgramUniform2fv(table, save_ProgramUniform2fv);
14576    SET_ProgramUniform3fv(table, save_ProgramUniform3fv);
14577    SET_ProgramUniform4fv(table, save_ProgramUniform4fv);
14578    SET_ProgramUniform1d(table, save_ProgramUniform1d);
14579    SET_ProgramUniform2d(table, save_ProgramUniform2d);
14580    SET_ProgramUniform3d(table, save_ProgramUniform3d);
14581    SET_ProgramUniform4d(table, save_ProgramUniform4d);
14582    SET_ProgramUniform1dv(table, save_ProgramUniform1dv);
14583    SET_ProgramUniform2dv(table, save_ProgramUniform2dv);
14584    SET_ProgramUniform3dv(table, save_ProgramUniform3dv);
14585    SET_ProgramUniform4dv(table, save_ProgramUniform4dv);
14586    SET_ProgramUniform1i(table, save_ProgramUniform1i);
14587    SET_ProgramUniform2i(table, save_ProgramUniform2i);
14588    SET_ProgramUniform3i(table, save_ProgramUniform3i);
14589    SET_ProgramUniform4i(table, save_ProgramUniform4i);
14590    SET_ProgramUniform1iv(table, save_ProgramUniform1iv);
14591    SET_ProgramUniform2iv(table, save_ProgramUniform2iv);
14592    SET_ProgramUniform3iv(table, save_ProgramUniform3iv);
14593    SET_ProgramUniform4iv(table, save_ProgramUniform4iv);
14594    SET_ProgramUniform1ui(table, save_ProgramUniform1ui);
14595    SET_ProgramUniform2ui(table, save_ProgramUniform2ui);
14596    SET_ProgramUniform3ui(table, save_ProgramUniform3ui);
14597    SET_ProgramUniform4ui(table, save_ProgramUniform4ui);
14598    SET_ProgramUniform1uiv(table, save_ProgramUniform1uiv);
14599    SET_ProgramUniform2uiv(table, save_ProgramUniform2uiv);
14600    SET_ProgramUniform3uiv(table, save_ProgramUniform3uiv);
14601    SET_ProgramUniform4uiv(table, save_ProgramUniform4uiv);
14602    SET_ProgramUniformMatrix2fv(table, save_ProgramUniformMatrix2fv);
14603    SET_ProgramUniformMatrix3fv(table, save_ProgramUniformMatrix3fv);
14604    SET_ProgramUniformMatrix4fv(table, save_ProgramUniformMatrix4fv);
14605    SET_ProgramUniformMatrix2x3fv(table, save_ProgramUniformMatrix2x3fv);
14606    SET_ProgramUniformMatrix3x2fv(table, save_ProgramUniformMatrix3x2fv);
14607    SET_ProgramUniformMatrix2x4fv(table, save_ProgramUniformMatrix2x4fv);
14608    SET_ProgramUniformMatrix4x2fv(table, save_ProgramUniformMatrix4x2fv);
14609    SET_ProgramUniformMatrix3x4fv(table, save_ProgramUniformMatrix3x4fv);
14610    SET_ProgramUniformMatrix4x3fv(table, save_ProgramUniformMatrix4x3fv);
14611    SET_ProgramUniformMatrix2dv(table, save_ProgramUniformMatrix2dv);
14612    SET_ProgramUniformMatrix3dv(table, save_ProgramUniformMatrix3dv);
14613    SET_ProgramUniformMatrix4dv(table, save_ProgramUniformMatrix4dv);
14614    SET_ProgramUniformMatrix2x3dv(table, save_ProgramUniformMatrix2x3dv);
14615    SET_ProgramUniformMatrix3x2dv(table, save_ProgramUniformMatrix3x2dv);
14616    SET_ProgramUniformMatrix2x4dv(table, save_ProgramUniformMatrix2x4dv);
14617    SET_ProgramUniformMatrix4x2dv(table, save_ProgramUniformMatrix4x2dv);
14618    SET_ProgramUniformMatrix3x4dv(table, save_ProgramUniformMatrix3x4dv);
14619    SET_ProgramUniformMatrix4x3dv(table, save_ProgramUniformMatrix4x3dv);
14620 
14621    /* GL_{ARB,EXT}_polygon_offset_clamp */
14622    SET_PolygonOffsetClampEXT(table, save_PolygonOffsetClampEXT);
14623 
14624    /* GL_EXT_window_rectangles */
14625    SET_WindowRectanglesEXT(table, save_WindowRectanglesEXT);
14626 
14627    /* GL_NV_conservative_raster */
14628    SET_SubpixelPrecisionBiasNV(table, save_SubpixelPrecisionBiasNV);
14629 
14630    /* GL_NV_conservative_raster_dilate */
14631    SET_ConservativeRasterParameterfNV(table, save_ConservativeRasterParameterfNV);
14632 
14633    /* GL_NV_conservative_raster_pre_snap_triangles */
14634    SET_ConservativeRasterParameteriNV(table, save_ConservativeRasterParameteriNV);
14635 
14636    /* GL_EXT_direct_state_access */
14637    SET_MatrixLoadfEXT(table, save_MatrixLoadfEXT);
14638    SET_MatrixLoaddEXT(table, save_MatrixLoaddEXT);
14639    SET_MatrixMultfEXT(table, save_MatrixMultfEXT);
14640    SET_MatrixMultdEXT(table, save_MatrixMultdEXT);
14641    SET_MatrixRotatefEXT(table, save_MatrixRotatefEXT);
14642    SET_MatrixRotatedEXT(table, save_MatrixRotatedEXT);
14643    SET_MatrixScalefEXT(table, save_MatrixScalefEXT);
14644    SET_MatrixScaledEXT(table, save_MatrixScaledEXT);
14645    SET_MatrixTranslatefEXT(table, save_MatrixTranslatefEXT);
14646    SET_MatrixTranslatedEXT(table, save_MatrixTranslatedEXT);
14647    SET_MatrixLoadIdentityEXT(table, save_MatrixLoadIdentityEXT);
14648    SET_MatrixOrthoEXT(table, save_MatrixOrthoEXT);
14649    SET_MatrixFrustumEXT(table, save_MatrixFrustumEXT);
14650    SET_MatrixPushEXT(table, save_MatrixPushEXT);
14651    SET_MatrixPopEXT(table, save_MatrixPopEXT);
14652    SET_MatrixLoadTransposefEXT(table, save_MatrixLoadTransposefEXT);
14653    SET_MatrixLoadTransposedEXT(table, save_MatrixLoadTransposedEXT);
14654    SET_MatrixMultTransposefEXT(table, save_MatrixMultTransposefEXT);
14655    SET_MatrixMultTransposedEXT(table, save_MatrixMultTransposedEXT);
14656    SET_TextureParameteriEXT(table, save_TextureParameteriEXT);
14657    SET_TextureParameterivEXT(table, save_TextureParameterivEXT);
14658    SET_TextureParameterfEXT(table, save_TextureParameterfEXT);
14659    SET_TextureParameterfvEXT(table, save_TextureParameterfvEXT);
14660    SET_TextureParameterIivEXT(table, save_TextureParameterIivEXT);
14661    SET_TextureParameterIuivEXT(table, save_TextureParameterIuivEXT);
14662    SET_TextureImage1DEXT(table, save_TextureImage1DEXT);
14663    SET_TextureImage2DEXT(table, save_TextureImage2DEXT);
14664    SET_TextureImage3DEXT(table, save_TextureImage3DEXT);
14665    SET_TextureSubImage1DEXT(table, save_TextureSubImage1DEXT);
14666    SET_TextureSubImage2DEXT(table, save_TextureSubImage2DEXT);
14667    SET_TextureSubImage3DEXT(table, save_TextureSubImage3DEXT);
14668    SET_CopyTextureImage1DEXT(table, save_CopyTextureImage1DEXT);
14669    SET_CopyTextureImage2DEXT(table, save_CopyTextureImage2DEXT);
14670    SET_CopyTextureSubImage1DEXT(table, save_CopyTextureSubImage1DEXT);
14671    SET_CopyTextureSubImage2DEXT(table, save_CopyTextureSubImage2DEXT);
14672    SET_CopyTextureSubImage3DEXT(table, save_CopyTextureSubImage3DEXT);
14673    SET_BindMultiTextureEXT(table, save_BindMultiTextureEXT);
14674    SET_MultiTexParameteriEXT(table, save_MultiTexParameteriEXT);
14675    SET_MultiTexParameterivEXT(table, save_MultiTexParameterivEXT);
14676    SET_MultiTexParameterIivEXT(table, save_MultiTexParameterIivEXT);
14677    SET_MultiTexParameterIuivEXT(table, save_MultiTexParameterIuivEXT);
14678    SET_MultiTexParameterfEXT(table, save_MultiTexParameterfEXT);
14679    SET_MultiTexParameterfvEXT(table, save_MultiTexParameterfvEXT);
14680    SET_MultiTexImage1DEXT(table, save_MultiTexImage1DEXT);
14681    SET_MultiTexImage2DEXT(table, save_MultiTexImage2DEXT);
14682    SET_MultiTexImage3DEXT(table, save_MultiTexImage3DEXT);
14683    SET_MultiTexSubImage1DEXT(table, save_MultiTexSubImage1DEXT);
14684    SET_MultiTexSubImage2DEXT(table, save_MultiTexSubImage2DEXT);
14685    SET_MultiTexSubImage3DEXT(table, save_MultiTexSubImage3DEXT);
14686    SET_CopyMultiTexImage1DEXT(table, save_CopyMultiTexImage1DEXT);
14687    SET_CopyMultiTexImage2DEXT(table, save_CopyMultiTexImage2DEXT);
14688    SET_CopyMultiTexSubImage1DEXT(table, save_CopyMultiTexSubImage1DEXT);
14689    SET_CopyMultiTexSubImage2DEXT(table, save_CopyMultiTexSubImage2DEXT);
14690    SET_CopyMultiTexSubImage3DEXT(table, save_CopyMultiTexSubImage3DEXT);
14691    SET_MultiTexEnvfEXT(table, save_MultiTexEnvfEXT);
14692    SET_MultiTexEnvfvEXT(table, save_MultiTexEnvfvEXT);
14693    SET_MultiTexEnviEXT(table, save_MultiTexEnviEXT);
14694    SET_MultiTexEnvivEXT(table, save_MultiTexEnvivEXT);
14695    SET_CompressedTextureImage1DEXT(table, save_CompressedTextureImage1DEXT);
14696    SET_CompressedTextureImage2DEXT(table, save_CompressedTextureImage2DEXT);
14697    SET_CompressedTextureImage3DEXT(table, save_CompressedTextureImage3DEXT);
14698    SET_CompressedTextureSubImage1DEXT(table, save_CompressedTextureSubImage1DEXT);
14699    SET_CompressedTextureSubImage2DEXT(table, save_CompressedTextureSubImage2DEXT);
14700    SET_CompressedTextureSubImage3DEXT(table, save_CompressedTextureSubImage3DEXT);
14701    SET_CompressedMultiTexImage1DEXT(table, save_CompressedMultiTexImage1DEXT);
14702    SET_CompressedMultiTexImage2DEXT(table, save_CompressedMultiTexImage2DEXT);
14703    SET_CompressedMultiTexImage3DEXT(table, save_CompressedMultiTexImage3DEXT);
14704    SET_CompressedMultiTexSubImage1DEXT(table, save_CompressedMultiTexSubImage1DEXT);
14705    SET_CompressedMultiTexSubImage2DEXT(table, save_CompressedMultiTexSubImage2DEXT);
14706    SET_CompressedMultiTexSubImage3DEXT(table, save_CompressedMultiTexSubImage3DEXT);
14707    SET_NamedProgramStringEXT(table, save_NamedProgramStringEXT);
14708    SET_NamedProgramLocalParameter4dEXT(table, save_NamedProgramLocalParameter4dEXT);
14709    SET_NamedProgramLocalParameter4dvEXT(table, save_NamedProgramLocalParameter4dvEXT);
14710    SET_NamedProgramLocalParameter4fEXT(table, save_NamedProgramLocalParameter4fEXT);
14711    SET_NamedProgramLocalParameter4fvEXT(table, save_NamedProgramLocalParameter4fvEXT);
14712 
14713    /* GL_ARB_ES3_2_compatibility */
14714    SET_PrimitiveBoundingBox(table, save_PrimitiveBoundingBox);
14715 }
14716 
14717 
14718 
14719 static const char *
enum_string(GLenum k)14720 enum_string(GLenum k)
14721 {
14722    return _mesa_enum_to_string(k);
14723 }
14724 
14725 
14726 /**
14727  * Print the commands in a display list.  For debugging only.
14728  * TODO: many commands aren't handled yet.
14729  * \param fname  filename to write display list to.  If null, use stdout.
14730  */
14731 static void GLAPIENTRY
print_list(struct gl_context * ctx,GLuint list,const char * fname)14732 print_list(struct gl_context *ctx, GLuint list, const char *fname)
14733 {
14734    struct gl_display_list *dlist;
14735    Node *n;
14736    FILE *f = stdout;
14737 
14738    if (fname) {
14739       f = fopen(fname, "w");
14740       if (!f)
14741          return;
14742    }
14743 
14744    if (!_mesa_get_list(ctx, list, &dlist, true)) {
14745       fprintf(f, "%u is not a display list ID\n", list);
14746       fflush(f);
14747       if (fname)
14748          fclose(f);
14749       return;
14750    }
14751 
14752    n = get_list_head(ctx, dlist);
14753 
14754    fprintf(f, "START-LIST %u, address %p\n", list, (void *) n);
14755 
14756    while (1) {
14757       const OpCode opcode = n[0].opcode;
14758 
14759       switch (opcode) {
14760          case OPCODE_ACCUM:
14761             fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f);
14762             break;
14763          case OPCODE_ACTIVE_TEXTURE:
14764             fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e));
14765             break;
14766          case OPCODE_BITMAP:
14767             fprintf(f, "Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
14768                    n[3].f, n[4].f, n[5].f, n[6].f,
14769                    get_pointer(&n[7]));
14770             break;
14771          case OPCODE_BLEND_COLOR:
14772             fprintf(f, "BlendColor %f, %f, %f, %f\n",
14773                     n[1].f, n[2].f, n[3].f, n[4].f);
14774             break;
14775          case OPCODE_BLEND_EQUATION:
14776             fprintf(f, "BlendEquation %s\n",
14777                     enum_string(n[1].e));
14778             break;
14779          case OPCODE_BLEND_EQUATION_SEPARATE:
14780             fprintf(f, "BlendEquationSeparate %s, %s\n",
14781                     enum_string(n[1].e),
14782                     enum_string(n[2].e));
14783             break;
14784          case OPCODE_BLEND_FUNC_SEPARATE:
14785             fprintf(f, "BlendFuncSeparate %s, %s, %s, %s\n",
14786                     enum_string(n[1].e),
14787                     enum_string(n[2].e),
14788                     enum_string(n[3].e),
14789                     enum_string(n[4].e));
14790             break;
14791          case OPCODE_BLEND_EQUATION_I:
14792             fprintf(f, "BlendEquationi %u, %s\n",
14793                     n[1].ui, enum_string(n[2].e));
14794             break;
14795          case OPCODE_BLEND_EQUATION_SEPARATE_I:
14796             fprintf(f, "BlendEquationSeparatei %u, %s, %s\n",
14797                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
14798             break;
14799          case OPCODE_BLEND_FUNC_I:
14800             fprintf(f, "BlendFunci %u, %s, %s\n",
14801                     n[1].ui, enum_string(n[2].e), enum_string(n[3].e));
14802             break;
14803          case OPCODE_BLEND_FUNC_SEPARATE_I:
14804             fprintf(f, "BlendFuncSeparatei %u, %s, %s, %s, %s\n",
14805                     n[1].ui,
14806                     enum_string(n[2].e),
14807                     enum_string(n[3].e),
14808                     enum_string(n[4].e),
14809                     enum_string(n[5].e));
14810             break;
14811          case OPCODE_CALL_LIST:
14812             fprintf(f, "CallList %d\n", (int) n[1].ui);
14813             break;
14814          case OPCODE_CALL_LISTS:
14815             fprintf(f, "CallLists %d, %s\n", n[1].i, enum_string(n[1].e));
14816             break;
14817          case OPCODE_DISABLE:
14818             fprintf(f, "Disable %s\n", enum_string(n[1].e));
14819             break;
14820          case OPCODE_ENABLE:
14821             fprintf(f, "Enable %s\n", enum_string(n[1].e));
14822             break;
14823          case OPCODE_FRUSTUM:
14824             fprintf(f, "Frustum %g %g %g %g %g %g\n",
14825                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
14826             break;
14827          case OPCODE_LINE_STIPPLE:
14828             fprintf(f, "LineStipple %d %x\n", n[1].i, (int) n[2].us);
14829             break;
14830          case OPCODE_LINE_WIDTH:
14831             fprintf(f, "LineWidth %f\n", n[1].f);
14832             break;
14833          case OPCODE_LOAD_IDENTITY:
14834             fprintf(f, "LoadIdentity\n");
14835             break;
14836          case OPCODE_LOAD_MATRIX:
14837             fprintf(f, "LoadMatrix\n");
14838             fprintf(f, "  %8f %8f %8f %8f\n",
14839                          n[1].f, n[5].f, n[9].f, n[13].f);
14840             fprintf(f, "  %8f %8f %8f %8f\n",
14841                          n[2].f, n[6].f, n[10].f, n[14].f);
14842             fprintf(f, "  %8f %8f %8f %8f\n",
14843                          n[3].f, n[7].f, n[11].f, n[15].f);
14844             fprintf(f, "  %8f %8f %8f %8f\n",
14845                          n[4].f, n[8].f, n[12].f, n[16].f);
14846             break;
14847          case OPCODE_MULT_MATRIX:
14848             fprintf(f, "MultMatrix (or Rotate)\n");
14849             fprintf(f, "  %8f %8f %8f %8f\n",
14850                          n[1].f, n[5].f, n[9].f, n[13].f);
14851             fprintf(f, "  %8f %8f %8f %8f\n",
14852                          n[2].f, n[6].f, n[10].f, n[14].f);
14853             fprintf(f, "  %8f %8f %8f %8f\n",
14854                          n[3].f, n[7].f, n[11].f, n[15].f);
14855             fprintf(f, "  %8f %8f %8f %8f\n",
14856                          n[4].f, n[8].f, n[12].f, n[16].f);
14857             break;
14858          case OPCODE_ORTHO:
14859             fprintf(f, "Ortho %g %g %g %g %g %g\n",
14860                          n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f);
14861             break;
14862          case OPCODE_POINT_SIZE:
14863             fprintf(f, "PointSize %f\n", n[1].f);
14864             break;
14865          case OPCODE_POP_ATTRIB:
14866             fprintf(f, "PopAttrib\n");
14867             break;
14868          case OPCODE_POP_MATRIX:
14869             fprintf(f, "PopMatrix\n");
14870             break;
14871          case OPCODE_POP_NAME:
14872             fprintf(f, "PopName\n");
14873             break;
14874          case OPCODE_PUSH_ATTRIB:
14875             fprintf(f, "PushAttrib %x\n", n[1].bf);
14876             break;
14877          case OPCODE_PUSH_MATRIX:
14878             fprintf(f, "PushMatrix\n");
14879             break;
14880          case OPCODE_PUSH_NAME:
14881             fprintf(f, "PushName %d\n", (int) n[1].ui);
14882             break;
14883          case OPCODE_RASTER_POS:
14884             fprintf(f, "RasterPos %g %g %g %g\n",
14885                          n[1].f, n[2].f, n[3].f, n[4].f);
14886             break;
14887          case OPCODE_ROTATE:
14888             fprintf(f, "Rotate %g %g %g %g\n",
14889                          n[1].f, n[2].f, n[3].f, n[4].f);
14890             break;
14891          case OPCODE_SCALE:
14892             fprintf(f, "Scale %g %g %g\n", n[1].f, n[2].f, n[3].f);
14893             break;
14894          case OPCODE_TRANSLATE:
14895             fprintf(f, "Translate %g %g %g\n", n[1].f, n[2].f, n[3].f);
14896             break;
14897          case OPCODE_BIND_TEXTURE:
14898             fprintf(f, "BindTexture %s %d\n",
14899                          _mesa_enum_to_string(n[1].ui), n[2].ui);
14900             break;
14901          case OPCODE_SHADE_MODEL:
14902             fprintf(f, "ShadeModel %s\n", _mesa_enum_to_string(n[1].ui));
14903             break;
14904          case OPCODE_MAP1:
14905             fprintf(f, "Map1 %s %.3f %.3f %d %d\n",
14906                          _mesa_enum_to_string(n[1].ui),
14907                          n[2].f, n[3].f, n[4].i, n[5].i);
14908             break;
14909          case OPCODE_MAP2:
14910             fprintf(f, "Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
14911                          _mesa_enum_to_string(n[1].ui),
14912                          n[2].f, n[3].f, n[4].f, n[5].f,
14913                          n[6].i, n[7].i, n[8].i, n[9].i);
14914             break;
14915          case OPCODE_MAPGRID1:
14916             fprintf(f, "MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
14917             break;
14918          case OPCODE_MAPGRID2:
14919             fprintf(f, "MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
14920                          n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
14921             break;
14922          case OPCODE_EVALMESH1:
14923             fprintf(f, "EvalMesh1 %d %d\n", n[1].i, n[2].i);
14924             break;
14925          case OPCODE_EVALMESH2:
14926             fprintf(f, "EvalMesh2 %d %d %d %d\n",
14927                          n[1].i, n[2].i, n[3].i, n[4].i);
14928             break;
14929 
14930          case OPCODE_ATTR_1F_NV:
14931             fprintf(f, "ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f);
14932             break;
14933          case OPCODE_ATTR_2F_NV:
14934             fprintf(f, "ATTR_2F_NV attr %d: %f %f\n",
14935                          n[1].i, n[2].f, n[3].f);
14936             break;
14937          case OPCODE_ATTR_3F_NV:
14938             fprintf(f, "ATTR_3F_NV attr %d: %f %f %f\n",
14939                          n[1].i, n[2].f, n[3].f, n[4].f);
14940             break;
14941          case OPCODE_ATTR_4F_NV:
14942             fprintf(f, "ATTR_4F_NV attr %d: %f %f %f %f\n",
14943                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
14944             break;
14945          case OPCODE_ATTR_1F_ARB:
14946             fprintf(f, "ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f);
14947             break;
14948          case OPCODE_ATTR_2F_ARB:
14949             fprintf(f, "ATTR_2F_ARB attr %d: %f %f\n",
14950                          n[1].i, n[2].f, n[3].f);
14951             break;
14952          case OPCODE_ATTR_3F_ARB:
14953             fprintf(f, "ATTR_3F_ARB attr %d: %f %f %f\n",
14954                          n[1].i, n[2].f, n[3].f, n[4].f);
14955             break;
14956          case OPCODE_ATTR_4F_ARB:
14957             fprintf(f, "ATTR_4F_ARB attr %d: %f %f %f %f\n",
14958                          n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
14959             break;
14960 
14961          case OPCODE_MATERIAL:
14962             fprintf(f, "MATERIAL %x %x: %f %f %f %f\n",
14963                          n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
14964             break;
14965          case OPCODE_BEGIN:
14966             fprintf(f, "BEGIN %x\n", n[1].i);
14967             break;
14968          case OPCODE_END:
14969             fprintf(f, "END\n");
14970             break;
14971          case OPCODE_EVAL_C1:
14972             fprintf(f, "EVAL_C1 %f\n", n[1].f);
14973             break;
14974          case OPCODE_EVAL_C2:
14975             fprintf(f, "EVAL_C2 %f %f\n", n[1].f, n[2].f);
14976             break;
14977          case OPCODE_EVAL_P1:
14978             fprintf(f, "EVAL_P1 %d\n", n[1].i);
14979             break;
14980          case OPCODE_EVAL_P2:
14981             fprintf(f, "EVAL_P2 %d %d\n", n[1].i, n[2].i);
14982             break;
14983 
14984          case OPCODE_PROVOKING_VERTEX:
14985             fprintf(f, "ProvokingVertex %s\n",
14986                          _mesa_enum_to_string(n[1].ui));
14987             break;
14988 
14989             /*
14990              * meta opcodes/commands
14991              */
14992          case OPCODE_ERROR:
14993             fprintf(f, "Error: %s %s\n", enum_string(n[1].e),
14994                    (const char *) get_pointer(&n[2]));
14995             break;
14996          case OPCODE_CONTINUE:
14997             fprintf(f, "DISPLAY-LIST-CONTINUE\n");
14998             n = (Node *) get_pointer(&n[1]);
14999             continue;
15000          case OPCODE_NOP:
15001             fprintf(f, "NOP\n");
15002             break;
15003          case OPCODE_VERTEX_LIST:
15004          case OPCODE_VERTEX_LIST_LOOPBACK:
15005          case OPCODE_VERTEX_LIST_COPY_CURRENT:
15006             vbo_print_vertex_list(ctx, (struct vbo_save_vertex_list *) &n[1], opcode, f);
15007             break;
15008          default:
15009             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
15010                printf
15011                   ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
15012                    opcode, (void *) n);
15013             } else {
15014                fprintf(f, "command %d, %u operands\n", opcode,
15015                             n[0].InstSize);
15016                break;
15017             }
15018             FALLTHROUGH;
15019          case OPCODE_END_OF_LIST:
15020             fprintf(f, "END-LIST %u\n", list);
15021             fflush(f);
15022             if (fname)
15023                fclose(f);
15024             return;
15025       }
15026 
15027       /* increment n to point to next compiled command */
15028       assert(n[0].InstSize > 0);
15029       n += n[0].InstSize;
15030    }
15031 }
15032 
15033 
15034 void
_mesa_glthread_execute_list(struct gl_context * ctx,GLuint list)15035 _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
15036 {
15037    struct gl_display_list *dlist;
15038 
15039    if (list == 0 ||
15040        !_mesa_get_list(ctx, list, &dlist, true))
15041       return;
15042 
15043    Node *n = get_list_head(ctx, dlist);
15044 
15045    while (1) {
15046       const OpCode opcode = n[0].opcode;
15047 
15048       switch (opcode) {
15049          case OPCODE_CALL_LIST:
15050             /* Generated by glCallList(), don't add ListBase */
15051             if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
15052                ctx->GLThread.ListCallDepth++;
15053                _mesa_glthread_execute_list(ctx, n[1].ui);
15054                ctx->GLThread.ListCallDepth--;
15055             }
15056             break;
15057          case OPCODE_CALL_LISTS:
15058             if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
15059                ctx->GLThread.ListCallDepth++;
15060                _mesa_glthread_CallLists(ctx, n[1].i, n[2].e, get_pointer(&n[3]));
15061                ctx->GLThread.ListCallDepth--;
15062             }
15063             break;
15064          case OPCODE_DISABLE:
15065             _mesa_glthread_Disable(ctx, n[1].e);
15066             break;
15067          case OPCODE_ENABLE:
15068             _mesa_glthread_Enable(ctx, n[1].e);
15069             break;
15070          case OPCODE_LIST_BASE:
15071             _mesa_glthread_ListBase(ctx, n[1].ui);
15072             break;
15073          case OPCODE_MATRIX_MODE:
15074             _mesa_glthread_MatrixMode(ctx, n[1].e);
15075             break;
15076          case OPCODE_POP_ATTRIB:
15077             _mesa_glthread_PopAttrib(ctx);
15078             break;
15079          case OPCODE_POP_MATRIX:
15080             _mesa_glthread_PopMatrix(ctx);
15081             break;
15082          case OPCODE_PUSH_ATTRIB:
15083             _mesa_glthread_PushAttrib(ctx, n[1].bf);
15084             break;
15085          case OPCODE_PUSH_MATRIX:
15086             _mesa_glthread_PushMatrix(ctx);
15087             break;
15088          case OPCODE_ACTIVE_TEXTURE:   /* GL_ARB_multitexture */
15089             _mesa_glthread_ActiveTexture(ctx, n[1].e);
15090             break;
15091          case OPCODE_MATRIX_PUSH:
15092             _mesa_glthread_MatrixPushEXT(ctx, n[1].e);
15093             break;
15094          case OPCODE_MATRIX_POP:
15095             _mesa_glthread_MatrixPopEXT(ctx, n[1].e);
15096             break;
15097          case OPCODE_CONTINUE:
15098             n = (Node *)get_pointer(&n[1]);
15099             continue;
15100          case OPCODE_END_OF_LIST:
15101             ctx->GLThread.ListCallDepth--;
15102             return;
15103          default:
15104             /* ignore */
15105             break;
15106       }
15107 
15108       /* increment n to point to next compiled command */
15109       assert(n[0].InstSize > 0);
15110       n += n[0].InstSize;
15111    }
15112 }
15113 
15114 
15115 /**
15116  * Clients may call this function to help debug display list problems.
15117  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
15118  * changed, or break in the future without notice.
15119  */
15120 void
mesa_print_display_list(GLuint list)15121 mesa_print_display_list(GLuint list)
15122 {
15123    GET_CURRENT_CONTEXT(ctx);
15124    print_list(ctx, list, NULL);
15125 }
15126 
15127 
15128 /**********************************************************************/
15129 /*****                      Initialization                        *****/
15130 /**********************************************************************/
15131 
15132 void
_mesa_install_dlist_vtxfmt(struct _glapi_table * disp,const GLvertexformat * vfmt)15133 _mesa_install_dlist_vtxfmt(struct _glapi_table *disp,
15134                            const GLvertexformat *vfmt)
15135 {
15136    SET_CallList(disp, vfmt->CallList);
15137    SET_CallLists(disp, vfmt->CallLists);
15138 }
15139 
15140 
15141 /**
15142  * Initialize display list state for given context.
15143  */
15144 void
_mesa_init_display_list(struct gl_context * ctx)15145 _mesa_init_display_list(struct gl_context *ctx)
15146 {
15147    GLvertexformat *vfmt = &ctx->ListState.ListVtxfmt;
15148 
15149    /* Display list */
15150    ctx->ListState.CallDepth = 1;
15151    ctx->ExecuteFlag = GL_TRUE;
15152    ctx->CompileFlag = GL_FALSE;
15153    ctx->ListState.CurrentBlock = NULL;
15154    ctx->ListState.CurrentPos = 0;
15155 
15156    /* Display List group */
15157    ctx->List.ListBase = 0;
15158 
15159 #define NAME_AE(x) _ae_##x
15160 #define NAME_CALLLIST(x) save_##x
15161 #define NAME(x) save_##x
15162 #define NAME_ES(x) save_##x##ARB
15163 
15164 #include "vbo/vbo_init_tmp.h"
15165 }
15166