Subversion Repositories Kolibri OS

Rev

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