Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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