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