home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / dlist.cpp < prev    next >
C/C++ Source or Header  |  2002-11-06  |  187KB  |  6,486 lines

  1. /* $Id: dlist.c,v 1.100 2002/11/06 15:16:23 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  5.0
  6.  *
  7.  * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
  8.  *
  9.  * Permission is hereby granted, free of charge, to any person obtaining a
  10.  * copy of this software and associated documentation files (the "Software"),
  11.  * to deal in the Software without restriction, including without limitation
  12.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13.  * and/or sell copies of the Software, and to permit persons to whom the
  14.  * Software is furnished to do so, subject to the following conditions:
  15.  *
  16.  * The above copyright notice and this permission notice shall be included
  17.  * in all copies or substantial portions of the Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  22.  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  23.  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24.  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  */
  26.  
  27. #include "glheader.h"
  28. #include "imports.h"
  29. #include "api_loopback.h"
  30. #include "attrib.h"
  31. #include "blend.h"
  32. #include "buffers.h"
  33. #include "clip.h"
  34. #include "colormac.h"
  35. #include "colortab.h"
  36. #include "context.h"
  37. #include "convolve.h"
  38. #include "depth.h"
  39. #include "dlist.h"
  40. #include "enable.h"
  41. #include "enums.h"
  42. #include "eval.h"
  43. #include "extensions.h"
  44. #include "feedback.h"
  45. #include "get.h"
  46. #include "glapi.h"
  47. #include "hash.h"
  48. #include "histogram.h"
  49. #include "image.h"
  50. #include "light.h"
  51. #include "lines.h"
  52. #include "dlist.h"
  53. #include "macros.h"
  54. #include "matrix.h"
  55. #include "pixel.h"
  56. #include "points.h"
  57. #include "polygon.h"
  58. #include "state.h"
  59. #include "texobj.h"
  60. #include "teximage.h"
  61. #include "texstate.h"
  62. #include "mtypes.h"
  63. #include "varray.h"
  64. #if FEATURE_NV_vertex_program
  65. #include "vpstate.h"
  66. #endif
  67.  
  68. #include "math/m_matrix.h"
  69. #include "math/m_xform.h"
  70.  
  71.  
  72.  
  73. /*
  74. Functions which aren't compiled but executed immediately:
  75.     glIsList
  76.     glGenLists
  77.     glDeleteLists
  78.     glEndList  --- BUT:  call ctx->Driver.EndList at end of list execution?
  79.     glFeedbackBuffer
  80.     glSelectBuffer
  81.     glRenderMode
  82.     glReadPixels
  83.     glPixelStore
  84.     glFlush
  85.     glFinish
  86.     glIsEnabled
  87.     glGet*
  88.  
  89. Functions which cause errors if called while compiling a display list:
  90.     glNewList
  91. */
  92.  
  93.  
  94.  
  95. /*
  96.  * Display list instructions are stored as sequences of "nodes".  Nodes
  97.  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
  98.  * are linked together with a pointer.
  99.  */
  100.  
  101.  
  102. /* How many nodes to allocate at a time:
  103.  * - reduced now that we hold vertices etc. elsewhere.
  104.  */
  105. #define BLOCK_SIZE 256
  106.  
  107.  
  108. /*
  109.  * Display list opcodes.
  110.  *
  111.  * The fact that these identifiers are assigned consecutive
  112.  * integer values starting at 0 is very important, see InstSize array usage)
  113.  *
  114.  */
  115. typedef enum {
  116.     OPCODE_ACCUM,
  117.     OPCODE_ALPHA_FUNC,
  118.         OPCODE_BIND_TEXTURE,
  119.     OPCODE_BITMAP,
  120.     OPCODE_BLEND_COLOR,
  121.     OPCODE_BLEND_EQUATION,
  122.     OPCODE_BLEND_FUNC,
  123.     OPCODE_BLEND_FUNC_SEPARATE,
  124.         OPCODE_CALL_LIST,
  125.         OPCODE_CALL_LIST_OFFSET,
  126.     OPCODE_CLEAR,
  127.     OPCODE_CLEAR_ACCUM,
  128.     OPCODE_CLEAR_COLOR,
  129.     OPCODE_CLEAR_DEPTH,
  130.     OPCODE_CLEAR_INDEX,
  131.     OPCODE_CLEAR_STENCIL,
  132.         OPCODE_CLIP_PLANE,
  133.     OPCODE_COLOR_MASK,
  134.     OPCODE_COLOR_MATERIAL,
  135.     OPCODE_COLOR_TABLE,
  136.     OPCODE_COLOR_TABLE_PARAMETER_FV,
  137.     OPCODE_COLOR_TABLE_PARAMETER_IV,
  138.     OPCODE_COLOR_SUB_TABLE,
  139.         OPCODE_CONVOLUTION_FILTER_1D,
  140.         OPCODE_CONVOLUTION_FILTER_2D,
  141.         OPCODE_CONVOLUTION_PARAMETER_I,
  142.         OPCODE_CONVOLUTION_PARAMETER_IV,
  143.         OPCODE_CONVOLUTION_PARAMETER_F,
  144.         OPCODE_CONVOLUTION_PARAMETER_FV,
  145.         OPCODE_COPY_COLOR_SUB_TABLE,
  146.         OPCODE_COPY_COLOR_TABLE,
  147.     OPCODE_COPY_PIXELS,
  148.         OPCODE_COPY_TEX_IMAGE1D,
  149.         OPCODE_COPY_TEX_IMAGE2D,
  150.         OPCODE_COPY_TEX_SUB_IMAGE1D,
  151.         OPCODE_COPY_TEX_SUB_IMAGE2D,
  152.         OPCODE_COPY_TEX_SUB_IMAGE3D,
  153.     OPCODE_CULL_FACE,
  154.     OPCODE_DEPTH_FUNC,
  155.     OPCODE_DEPTH_MASK,
  156.     OPCODE_DEPTH_RANGE,
  157.     OPCODE_DISABLE,
  158.     OPCODE_DRAW_BUFFER,
  159.     OPCODE_DRAW_PIXELS,
  160.     OPCODE_ENABLE,
  161.     OPCODE_EVALMESH1,
  162.     OPCODE_EVALMESH2,
  163.     OPCODE_FOG,
  164.     OPCODE_FRONT_FACE,
  165.     OPCODE_FRUSTUM,
  166.     OPCODE_HINT,
  167.     OPCODE_HISTOGRAM,
  168.     OPCODE_INDEX_MASK,
  169.     OPCODE_INIT_NAMES,
  170.     OPCODE_LIGHT,
  171.     OPCODE_LIGHT_MODEL,
  172.     OPCODE_LINE_STIPPLE,
  173.     OPCODE_LINE_WIDTH,
  174.     OPCODE_LIST_BASE,
  175.     OPCODE_LOAD_IDENTITY,
  176.     OPCODE_LOAD_MATRIX,
  177.     OPCODE_LOAD_NAME,
  178.     OPCODE_LOGIC_OP,
  179.     OPCODE_MAP1,
  180.     OPCODE_MAP2,
  181.     OPCODE_MAPGRID1,
  182.     OPCODE_MAPGRID2,
  183.     OPCODE_MATRIX_MODE,
  184.         OPCODE_MIN_MAX,
  185.     OPCODE_MULT_MATRIX,
  186.     OPCODE_ORTHO,
  187.     OPCODE_PASSTHROUGH,
  188.     OPCODE_PIXEL_MAP,
  189.     OPCODE_PIXEL_TRANSFER,
  190.     OPCODE_PIXEL_ZOOM,
  191.     OPCODE_POINT_SIZE,
  192.         OPCODE_POINT_PARAMETERS,
  193.     OPCODE_POLYGON_MODE,
  194.         OPCODE_POLYGON_STIPPLE,
  195.     OPCODE_POLYGON_OFFSET,
  196.     OPCODE_POP_ATTRIB,
  197.     OPCODE_POP_MATRIX,
  198.     OPCODE_POP_NAME,
  199.     OPCODE_PRIORITIZE_TEXTURE,
  200.     OPCODE_PUSH_ATTRIB,
  201.     OPCODE_PUSH_MATRIX,
  202.     OPCODE_PUSH_NAME,
  203.     OPCODE_RASTER_POS,
  204.     OPCODE_READ_BUFFER,
  205.         OPCODE_RESET_HISTOGRAM,
  206.         OPCODE_RESET_MIN_MAX,
  207.         OPCODE_ROTATE,
  208.         OPCODE_SCALE,
  209.     OPCODE_SCISSOR,
  210.     OPCODE_SELECT_TEXTURE_SGIS,
  211.     OPCODE_SELECT_TEXTURE_COORD_SET,
  212.     OPCODE_SHADE_MODEL,
  213.     OPCODE_STENCIL_FUNC,
  214.     OPCODE_STENCIL_MASK,
  215.     OPCODE_STENCIL_OP,
  216.         OPCODE_TEXENV,
  217.         OPCODE_TEXGEN,
  218.         OPCODE_TEXPARAMETER,
  219.     OPCODE_TEX_IMAGE1D,
  220.     OPCODE_TEX_IMAGE2D,
  221.     OPCODE_TEX_IMAGE3D,
  222.     OPCODE_TEX_SUB_IMAGE1D,
  223.     OPCODE_TEX_SUB_IMAGE2D,
  224.     OPCODE_TEX_SUB_IMAGE3D,
  225.         OPCODE_TRANSLATE,
  226.     OPCODE_VIEWPORT,
  227.     OPCODE_WINDOW_POS,
  228.         /* GL_ARB_multitexture */
  229.         OPCODE_ACTIVE_TEXTURE,
  230.         /* GL_SGIX/SGIS_pixel_texture */
  231.         OPCODE_PIXEL_TEXGEN_SGIX,
  232.         OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS,
  233.         /* GL_ARB_texture_compression */
  234.         OPCODE_COMPRESSED_TEX_IMAGE_1D,
  235.         OPCODE_COMPRESSED_TEX_IMAGE_2D,
  236.         OPCODE_COMPRESSED_TEX_IMAGE_3D,
  237.         OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
  238.         OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
  239.         OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
  240.         /* GL_ARB_multisample */
  241.         OPCODE_SAMPLE_COVERAGE,
  242.         /* GL_ARB_window_pos */
  243.     OPCODE_WINDOW_POS_ARB,
  244.         /* GL_NV_vertex_program */
  245.         OPCODE_BIND_PROGRAM_NV,
  246.         OPCODE_EXECUTE_PROGRAM_NV,
  247.         OPCODE_REQUEST_PROGRAMS_RESIDENT_NV,
  248.         OPCODE_LOAD_PROGRAM_NV,
  249.         OPCODE_PROGRAM_PARAMETER4F_NV,
  250.         OPCODE_TRACK_MATRIX_NV,
  251.         /* GL_EXT_stencil_two_side */
  252.         OPCODE_ACTIVE_STENCIL_FACE_EXT,
  253.     /* The following three are meta instructions */
  254.     OPCODE_ERROR,            /* raise compiled-in error */
  255.     OPCODE_CONTINUE,
  256.     OPCODE_END_OF_LIST,
  257.     OPCODE_DRV_0
  258. } OpCode;
  259.  
  260.  
  261. /*
  262.  * Each instruction in the display list is stored as a sequence of
  263.  * contiguous nodes in memory.
  264.  * Each node is the union of a variety of datatypes.
  265.  */
  266. union node {
  267.     OpCode        opcode;
  268.     GLboolean    b;
  269.     GLbitfield    bf;
  270.     GLubyte        ub;
  271.     GLshort        s;
  272.     GLushort    us;
  273.     GLint        i;
  274.     GLuint        ui;
  275.     GLenum        e;
  276.     GLfloat        f;
  277.     GLvoid        *data;
  278.     void        *next;    /* If prev node's opcode==OPCODE_CONTINUE */
  279. };
  280.  
  281.  
  282.  
  283. /* Number of nodes of storage needed for each instruction.  Sizes for
  284.  * dynamically allocated opcodes are stored in the context struct.
  285.  */
  286. static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
  287.  
  288. void mesa_print_display_list( GLuint list );
  289.  
  290.  
  291. /**********************************************************************/
  292. /*****                           Private                          *****/
  293. /**********************************************************************/
  294.  
  295.  
  296.  
  297.  
  298.  
  299. /*
  300.  * Make an empty display list.  This is used by glGenLists() to
  301.  * reserver display list IDs.
  302.  */
  303. static Node *make_empty_list( void )
  304. {
  305.    Node *n = (Node *) MALLOC( sizeof(Node) );
  306.    n[0].opcode = OPCODE_END_OF_LIST;
  307.    return n;
  308. }
  309.  
  310.  
  311.  
  312. /*
  313.  * Destroy all nodes in a display list.
  314.  * Input:  list - display list number
  315.  */
  316. void _mesa_destroy_list( GLcontext *ctx, GLuint list )
  317. {
  318.    Node *n, *block;
  319.    GLboolean done;
  320.  
  321.    if (list==0)
  322.       return;
  323.  
  324.    block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
  325.    n = block;
  326.  
  327.    done = block ? GL_FALSE : GL_TRUE;
  328.    while (!done) {
  329.  
  330.       /* check for extension opcodes first */
  331.  
  332.       GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
  333.       if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
  334.      ctx->listext.opcode[i].destroy(ctx, &n[1]);
  335.      n += ctx->listext.opcode[i].size;
  336.       }
  337.       else {
  338.      switch (n[0].opcode) {
  339.      case OPCODE_MAP1:
  340.             FREE(n[6].data);
  341.         n += InstSize[n[0].opcode];
  342.         break;
  343.      case OPCODE_MAP2:
  344.             FREE(n[10].data);
  345.         n += InstSize[n[0].opcode];
  346.         break;
  347.      case OPCODE_DRAW_PIXELS:
  348.         FREE( n[5].data );
  349.         n += InstSize[n[0].opcode];
  350.         break;
  351.      case OPCODE_BITMAP:
  352.         FREE( n[7].data );
  353.         n += InstSize[n[0].opcode];
  354.         break;
  355.          case OPCODE_COLOR_TABLE:
  356.             FREE( n[6].data );
  357.             n += InstSize[n[0].opcode];
  358.             break;
  359.          case OPCODE_COLOR_SUB_TABLE:
  360.             FREE( n[6].data );
  361.             n += InstSize[n[0].opcode];
  362.             break;
  363.          case OPCODE_CONVOLUTION_FILTER_1D:
  364.             FREE( n[6].data );
  365.             n += InstSize[n[0].opcode];
  366.             break;
  367.          case OPCODE_CONVOLUTION_FILTER_2D:
  368.             FREE( n[7].data );
  369.             n += InstSize[n[0].opcode];
  370.             break;
  371.          case OPCODE_POLYGON_STIPPLE:
  372.             FREE( n[1].data );
  373.         n += InstSize[n[0].opcode];
  374.             break;
  375.      case OPCODE_TEX_IMAGE1D:
  376.             FREE(n[8].data);
  377.             n += InstSize[n[0].opcode];
  378.         break;
  379.      case OPCODE_TEX_IMAGE2D:
  380.             FREE( n[9]. data );
  381.             n += InstSize[n[0].opcode];
  382.         break;
  383.      case OPCODE_TEX_IMAGE3D:
  384.             FREE( n[10]. data );
  385.             n += InstSize[n[0].opcode];
  386.         break;
  387.          case OPCODE_TEX_SUB_IMAGE1D:
  388.             FREE(n[7].data);
  389.             n += InstSize[n[0].opcode];
  390.             break;
  391.          case OPCODE_TEX_SUB_IMAGE2D:
  392.             FREE(n[9].data);
  393.             n += InstSize[n[0].opcode];
  394.             break;
  395.          case OPCODE_TEX_SUB_IMAGE3D:
  396.             FREE(n[11].data);
  397.             n += InstSize[n[0].opcode];
  398.             break;
  399.          case OPCODE_COMPRESSED_TEX_IMAGE_1D:
  400.             FREE(n[7].data);
  401.             n += InstSize[n[0].opcode];
  402.             break;
  403.          case OPCODE_COMPRESSED_TEX_IMAGE_2D:
  404.             FREE(n[8].data);
  405.             n += InstSize[n[0].opcode];
  406.             break;
  407.          case OPCODE_COMPRESSED_TEX_IMAGE_3D:
  408.             FREE(n[9].data);
  409.             n += InstSize[n[0].opcode];
  410.             break;
  411.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D:
  412.             FREE(n[7].data);
  413.             n += InstSize[n[0].opcode];
  414.             break;
  415.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D:
  416.             FREE(n[9].data);
  417.             n += InstSize[n[0].opcode];
  418.             break;
  419.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D:
  420.             FREE(n[11].data);
  421.             n += InstSize[n[0].opcode];
  422.             break;
  423.      case OPCODE_CONTINUE:
  424.         n = (Node *) n[1].next;
  425.         FREE( block );
  426.         block = n;
  427.         break;
  428.      case OPCODE_END_OF_LIST:
  429.         FREE( block );
  430.         done = GL_TRUE;
  431.         break;
  432.      default:
  433.         /* Most frequent case */
  434.         n += InstSize[n[0].opcode];
  435.         break;
  436.      }
  437.       }
  438.    }
  439.  
  440.    _mesa_HashRemove(ctx->Shared->DisplayList, list);
  441. }
  442.  
  443.  
  444.  
  445. /*
  446.  * Translate the nth element of list from type to GLuint.
  447.  */
  448. static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
  449. {
  450.    GLbyte *bptr;
  451.    GLubyte *ubptr;
  452.    GLshort *sptr;
  453.    GLushort *usptr;
  454.    GLint *iptr;
  455.    GLuint *uiptr;
  456.    GLfloat *fptr;
  457.  
  458.    switch (type) {
  459.       case GL_BYTE:
  460.          bptr = (GLbyte *) list;
  461.          return (GLuint) *(bptr+n);
  462.       case GL_UNSIGNED_BYTE:
  463.          ubptr = (GLubyte *) list;
  464.          return (GLuint) *(ubptr+n);
  465.       case GL_SHORT:
  466.          sptr = (GLshort *) list;
  467.          return (GLuint) *(sptr+n);
  468.       case GL_UNSIGNED_SHORT:
  469.          usptr = (GLushort *) list;
  470.          return (GLuint) *(usptr+n);
  471.       case GL_INT:
  472.          iptr = (GLint *) list;
  473.          return (GLuint) *(iptr+n);
  474.       case GL_UNSIGNED_INT:
  475.          uiptr = (GLuint *) list;
  476.          return (GLuint) *(uiptr+n);
  477.       case GL_FLOAT:
  478.          fptr = (GLfloat *) list;
  479.          return (GLuint) *(fptr+n);
  480.       case GL_2_BYTES:
  481.          ubptr = ((GLubyte *) list) + 2*n;
  482.          return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
  483.       case GL_3_BYTES:
  484.          ubptr = ((GLubyte *) list) + 3*n;
  485.          return (GLuint) *ubptr * 65536
  486.               + (GLuint) *(ubptr+1) * 256
  487.               + (GLuint) *(ubptr+2);
  488.       case GL_4_BYTES:
  489.          ubptr = ((GLubyte *) list) + 4*n;
  490.          return (GLuint) *ubptr * 16777216
  491.               + (GLuint) *(ubptr+1) * 65536
  492.               + (GLuint) *(ubptr+2) * 256
  493.               + (GLuint) *(ubptr+3);
  494.       default:
  495.          return 0;
  496.    }
  497. }
  498.  
  499.  
  500.  
  501.  
  502. /**********************************************************************/
  503. /*****                        Public                              *****/
  504. /**********************************************************************/
  505.  
  506. void _mesa_init_lists( void )
  507. {
  508.    static int init_flag = 0;
  509.  
  510.    if (init_flag==0) {
  511.       InstSize[OPCODE_ACCUM] = 3;
  512.       InstSize[OPCODE_ALPHA_FUNC] = 3;
  513.       InstSize[OPCODE_BIND_TEXTURE] = 3;
  514.       InstSize[OPCODE_BITMAP] = 8;
  515.       InstSize[OPCODE_BLEND_COLOR] = 5;
  516.       InstSize[OPCODE_BLEND_EQUATION] = 2;
  517.       InstSize[OPCODE_BLEND_FUNC] = 3;
  518.       InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
  519.       InstSize[OPCODE_CALL_LIST] = 2;
  520.       InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
  521.       InstSize[OPCODE_CLEAR] = 2;
  522.       InstSize[OPCODE_CLEAR_ACCUM] = 5;
  523.       InstSize[OPCODE_CLEAR_COLOR] = 5;
  524.       InstSize[OPCODE_CLEAR_DEPTH] = 2;
  525.       InstSize[OPCODE_CLEAR_INDEX] = 2;
  526.       InstSize[OPCODE_CLEAR_STENCIL] = 2;
  527.       InstSize[OPCODE_CLIP_PLANE] = 6;
  528.       InstSize[OPCODE_COLOR_MASK] = 5;
  529.       InstSize[OPCODE_COLOR_MATERIAL] = 3;
  530.       InstSize[OPCODE_COLOR_TABLE] = 7;
  531.       InstSize[OPCODE_COLOR_TABLE_PARAMETER_FV] = 7;
  532.       InstSize[OPCODE_COLOR_TABLE_PARAMETER_IV] = 7;
  533.       InstSize[OPCODE_COLOR_SUB_TABLE] = 7;
  534.       InstSize[OPCODE_CONVOLUTION_FILTER_1D] = 7;
  535.       InstSize[OPCODE_CONVOLUTION_FILTER_2D] = 8;
  536.       InstSize[OPCODE_CONVOLUTION_PARAMETER_I] = 4;
  537.       InstSize[OPCODE_CONVOLUTION_PARAMETER_IV] = 7;
  538.       InstSize[OPCODE_CONVOLUTION_PARAMETER_F] = 4;
  539.       InstSize[OPCODE_CONVOLUTION_PARAMETER_FV] = 7;
  540.       InstSize[OPCODE_COPY_PIXELS] = 6;
  541.       InstSize[OPCODE_COPY_COLOR_SUB_TABLE] = 6;
  542.       InstSize[OPCODE_COPY_COLOR_TABLE] = 6;
  543.       InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
  544.       InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
  545.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
  546.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
  547.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
  548.       InstSize[OPCODE_CULL_FACE] = 2;
  549.       InstSize[OPCODE_DEPTH_FUNC] = 2;
  550.       InstSize[OPCODE_DEPTH_MASK] = 2;
  551.       InstSize[OPCODE_DEPTH_RANGE] = 3;
  552.       InstSize[OPCODE_DISABLE] = 2;
  553.       InstSize[OPCODE_DRAW_BUFFER] = 2;
  554.       InstSize[OPCODE_DRAW_PIXELS] = 6;
  555.       InstSize[OPCODE_ENABLE] = 2;
  556.       InstSize[OPCODE_EVALMESH1] = 4;
  557.       InstSize[OPCODE_EVALMESH2] = 6;
  558.       InstSize[OPCODE_FOG] = 6;
  559.       InstSize[OPCODE_FRONT_FACE] = 2;
  560.       InstSize[OPCODE_FRUSTUM] = 7;
  561.       InstSize[OPCODE_HINT] = 3;
  562.       InstSize[OPCODE_HISTOGRAM] = 5;
  563.       InstSize[OPCODE_INDEX_MASK] = 2;
  564.       InstSize[OPCODE_INIT_NAMES] = 1;
  565.       InstSize[OPCODE_LIGHT] = 7;
  566.       InstSize[OPCODE_LIGHT_MODEL] = 6;
  567.       InstSize[OPCODE_LINE_STIPPLE] = 3;
  568.       InstSize[OPCODE_LINE_WIDTH] = 2;
  569.       InstSize[OPCODE_LIST_BASE] = 2;
  570.       InstSize[OPCODE_LOAD_IDENTITY] = 1;
  571.       InstSize[OPCODE_LOAD_MATRIX] = 17;
  572.       InstSize[OPCODE_LOAD_NAME] = 2;
  573.       InstSize[OPCODE_LOGIC_OP] = 2;
  574.       InstSize[OPCODE_MAP1] = 7;
  575.       InstSize[OPCODE_MAP2] = 11;
  576.       InstSize[OPCODE_MAPGRID1] = 4;
  577.       InstSize[OPCODE_MAPGRID2] = 7;
  578.       InstSize[OPCODE_MATRIX_MODE] = 2;
  579.       InstSize[OPCODE_MIN_MAX] = 4;
  580.       InstSize[OPCODE_MULT_MATRIX] = 17;
  581.       InstSize[OPCODE_ORTHO] = 7;
  582.       InstSize[OPCODE_PASSTHROUGH] = 2;
  583.       InstSize[OPCODE_PIXEL_MAP] = 4;
  584.       InstSize[OPCODE_PIXEL_TRANSFER] = 3;
  585.       InstSize[OPCODE_PIXEL_ZOOM] = 3;
  586.       InstSize[OPCODE_POINT_SIZE] = 2;
  587.       InstSize[OPCODE_POINT_PARAMETERS] = 5;
  588.       InstSize[OPCODE_POLYGON_MODE] = 3;
  589.       InstSize[OPCODE_POLYGON_STIPPLE] = 2;
  590.       InstSize[OPCODE_POLYGON_OFFSET] = 3;
  591.       InstSize[OPCODE_POP_ATTRIB] = 1;
  592.       InstSize[OPCODE_POP_MATRIX] = 1;
  593.       InstSize[OPCODE_POP_NAME] = 1;
  594.       InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
  595.       InstSize[OPCODE_PUSH_ATTRIB] = 2;
  596.       InstSize[OPCODE_PUSH_MATRIX] = 1;
  597.       InstSize[OPCODE_PUSH_NAME] = 2;
  598.       InstSize[OPCODE_RASTER_POS] = 5;
  599.       InstSize[OPCODE_READ_BUFFER] = 2;
  600.       InstSize[OPCODE_RESET_HISTOGRAM] = 2;
  601.       InstSize[OPCODE_RESET_MIN_MAX] = 2;
  602.       InstSize[OPCODE_ROTATE] = 5;
  603.       InstSize[OPCODE_SCALE] = 4;
  604.       InstSize[OPCODE_SCISSOR] = 5;
  605.       InstSize[OPCODE_STENCIL_FUNC] = 4;
  606.       InstSize[OPCODE_STENCIL_MASK] = 2;
  607.       InstSize[OPCODE_STENCIL_OP] = 4;
  608.       InstSize[OPCODE_SHADE_MODEL] = 2;
  609.       InstSize[OPCODE_TEXENV] = 7;
  610.       InstSize[OPCODE_TEXGEN] = 7;
  611.       InstSize[OPCODE_TEXPARAMETER] = 7;
  612.       InstSize[OPCODE_TEX_IMAGE1D] = 9;
  613.       InstSize[OPCODE_TEX_IMAGE2D] = 10;
  614.       InstSize[OPCODE_TEX_IMAGE3D] = 11;
  615.       InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
  616.       InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
  617.       InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
  618.       InstSize[OPCODE_TRANSLATE] = 4;
  619.       InstSize[OPCODE_VIEWPORT] = 5;
  620.       InstSize[OPCODE_WINDOW_POS] = 5;
  621.       InstSize[OPCODE_CONTINUE] = 2;
  622.       InstSize[OPCODE_ERROR] = 3;
  623.       InstSize[OPCODE_END_OF_LIST] = 1;
  624.       /* GL_SGIX/SGIS_pixel_texture */
  625.       InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
  626.       InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3;
  627.       /* GL_ARB_texture_compression */
  628.       InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8;
  629.       InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9;
  630.       InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10;
  631.       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
  632.       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
  633.       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
  634.       /* GL_ARB_multisample */
  635.       InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
  636.       /* GL_ARB_multitexture */
  637.       InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
  638.       /* GL_ARB_window_pos */
  639.       InstSize[OPCODE_WINDOW_POS_ARB] = 4;
  640.       /* GL_NV_vertex_program */
  641.       InstSize[OPCODE_BIND_PROGRAM_NV] = 3;
  642.       InstSize[OPCODE_EXECUTE_PROGRAM_NV] = 7;
  643.       InstSize[OPCODE_REQUEST_PROGRAMS_RESIDENT_NV] = 2;
  644.       InstSize[OPCODE_LOAD_PROGRAM_NV] = 4;
  645.       InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
  646.       InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
  647.       /* GL_EXT_stencil_two_side */
  648.       InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2;
  649.    }
  650.    init_flag = 1;
  651. }
  652.  
  653.  
  654. /*
  655.  * Allocate space for a display list instruction.
  656.  * Input:  opcode - type of instruction
  657.  *         argcount - size in bytes of data required.
  658.  * Return: pointer to the usable data area (not including the internal
  659.  *         opcode).
  660.  */
  661. void *
  662. _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
  663. {
  664.    Node *n, *newblock;
  665.    GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
  666.  
  667. #ifdef DEBUG
  668.    if (opcode < (int) OPCODE_DRV_0) {
  669.       assert( count == InstSize[opcode] );
  670.    }
  671. #endif
  672.  
  673.    if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
  674.       /* This block is full.  Allocate a new block and chain to it */
  675.       n = ctx->CurrentBlock + ctx->CurrentPos;
  676.       n[0].opcode = OPCODE_CONTINUE;
  677.       newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
  678.       if (!newblock) {
  679.          _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
  680.          return NULL;
  681.       }
  682.       n[1].next = (Node *) newblock;
  683.       ctx->CurrentBlock = newblock;
  684.       ctx->CurrentPos = 0;
  685.    }
  686.  
  687.    n = ctx->CurrentBlock + ctx->CurrentPos;
  688.    ctx->CurrentPos += count;
  689.  
  690.    n[0].opcode = (OpCode) opcode;
  691.  
  692.    return (void *)&n[1];
  693. }
  694.  
  695.  
  696. /* Allow modules and drivers to get their own opcodes.
  697.  */
  698. int
  699. _mesa_alloc_opcode( GLcontext *ctx,
  700.             GLuint sz,
  701.             void (*execute)( GLcontext *, void * ),
  702.             void (*destroy)( GLcontext *, void * ),
  703.             void (*print)( GLcontext *, void * ) )
  704. {
  705.    if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
  706.       GLuint i = ctx->listext.nr_opcodes++;
  707.       ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
  708.       ctx->listext.opcode[i].execute = execute;
  709.       ctx->listext.opcode[i].destroy = destroy;
  710.       ctx->listext.opcode[i].print = print;
  711.       return i + OPCODE_DRV_0;
  712.    }
  713.    return -1;
  714. }
  715.  
  716.  
  717.  
  718. /* Mimic the old behaviour of alloc_instruction:
  719.  *   - sz is in units of sizeof(Node)
  720.  *   - return value a pointer to sizeof(Node) before the actual
  721.  *     usable data area.
  722.  */
  723. #define ALLOC_INSTRUCTION(ctx, opcode, sz) \
  724.         ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
  725.  
  726.  
  727.  
  728. /*
  729.  * Display List compilation functions
  730.  */
  731. static void save_Accum( GLenum op, GLfloat value )
  732. {
  733.    GET_CURRENT_CONTEXT(ctx);
  734.    Node *n;
  735.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  736.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
  737.    if (n) {
  738.       n[1].e = op;
  739.       n[2].f = value;
  740.    }
  741.    if (ctx->ExecuteFlag) {
  742.       (*ctx->Exec->Accum)( op, value );
  743.    }
  744. }
  745.  
  746.  
  747. static void save_AlphaFunc( GLenum func, GLclampf ref )
  748. {
  749.    GET_CURRENT_CONTEXT(ctx);
  750.    Node *n;
  751.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  752.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
  753.    if (n) {
  754.       n[1].e = func;
  755.       n[2].f = (GLfloat) ref;
  756.    }
  757.    if (ctx->ExecuteFlag) {
  758.       (*ctx->Exec->AlphaFunc)( func, ref );
  759.    }
  760. }
  761.  
  762.  
  763. static void save_BindTexture( GLenum target, GLuint texture )
  764. {
  765.    GET_CURRENT_CONTEXT(ctx);
  766.    Node *n;
  767.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  768.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
  769.    if (n) {
  770.       n[1].e = target;
  771.       n[2].ui = texture;
  772.    }
  773.    if (ctx->ExecuteFlag) {
  774.       (*ctx->Exec->BindTexture)( target, texture );
  775.    }
  776. }
  777.  
  778.  
  779. static void save_Bitmap( GLsizei width, GLsizei height,
  780.                          GLfloat xorig, GLfloat yorig,
  781.                          GLfloat xmove, GLfloat ymove,
  782.                          const GLubyte *pixels )
  783. {
  784.    GET_CURRENT_CONTEXT(ctx);
  785.    GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
  786.    Node *n;
  787.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  788.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
  789.    if (n) {
  790.       n[1].i = (GLint) width;
  791.       n[2].i = (GLint) height;
  792.       n[3].f = xorig;
  793.       n[4].f = yorig;
  794.       n[5].f = xmove;
  795.       n[6].f = ymove;
  796.       n[7].data = image;
  797.    }
  798.    else if (image) {
  799.       FREE(image);
  800.    }
  801.    if (ctx->ExecuteFlag) {
  802.       (*ctx->Exec->Bitmap)( width, height,
  803.                            xorig, yorig, xmove, ymove, pixels );
  804.    }
  805. }
  806.  
  807.  
  808. static void save_BlendEquation( GLenum mode )
  809. {
  810.    GET_CURRENT_CONTEXT(ctx);
  811.    Node *n;
  812.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  813.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
  814.    if (n) {
  815.       n[1].e = mode;
  816.    }
  817.    if (ctx->ExecuteFlag) {
  818.       (*ctx->Exec->BlendEquation)( mode );
  819.    }
  820. }
  821.  
  822.  
  823. static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
  824. {
  825.    GET_CURRENT_CONTEXT(ctx);
  826.    Node *n;
  827.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  828.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC, 2 );
  829.    if (n) {
  830.       n[1].e = sfactor;
  831.       n[2].e = dfactor;
  832.    }
  833.    if (ctx->ExecuteFlag) {
  834.       (*ctx->Exec->BlendFunc)( sfactor, dfactor );
  835.    }
  836. }
  837.  
  838.  
  839. static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
  840.                                       GLenum sfactorA, GLenum dfactorA)
  841. {
  842.    GET_CURRENT_CONTEXT(ctx);
  843.    Node *n;
  844.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  845.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
  846.    if (n) {
  847.       n[1].e = sfactorRGB;
  848.       n[2].e = dfactorRGB;
  849.       n[3].e = sfactorA;
  850.       n[4].e = dfactorA;
  851.    }
  852.    if (ctx->ExecuteFlag) {
  853.       (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
  854.                                           sfactorA, dfactorA);
  855.    }
  856. }
  857.  
  858.  
  859. static void save_BlendColor( GLfloat red, GLfloat green,
  860.                              GLfloat blue, GLfloat alpha )
  861. {
  862.    GET_CURRENT_CONTEXT(ctx);
  863.    Node *n;
  864.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  865.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
  866.    if (n) {
  867.       n[1].f = red;
  868.       n[2].f = green;
  869.       n[3].f = blue;
  870.       n[4].f = alpha;
  871.    }
  872.    if (ctx->ExecuteFlag) {
  873.       (*ctx->Exec->BlendColor)( red, green, blue, alpha );
  874.    }
  875. }
  876.  
  877.  
  878. void _mesa_save_CallList( GLuint list )
  879. {
  880.    GET_CURRENT_CONTEXT(ctx);
  881.    Node *n;
  882.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  883.    FLUSH_CURRENT(ctx, 0);
  884.  
  885.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
  886.    if (n) {
  887.       n[1].ui = list;
  888.    }
  889.    if (ctx->ExecuteFlag) {
  890.       (*ctx->Exec->CallList)( list );
  891.    }
  892. }
  893.  
  894.  
  895. void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
  896. {
  897.    GET_CURRENT_CONTEXT(ctx);
  898.    GLint i;
  899.    GLboolean typeErrorFlag;
  900.  
  901.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  902.    FLUSH_CURRENT(ctx, 0);
  903.  
  904.    switch (type) {
  905.       case GL_BYTE:
  906.       case GL_UNSIGNED_BYTE:
  907.       case GL_SHORT:
  908.       case GL_UNSIGNED_SHORT:
  909.       case GL_INT:
  910.       case GL_UNSIGNED_INT:
  911.       case GL_FLOAT:
  912.       case GL_2_BYTES:
  913.       case GL_3_BYTES:
  914.       case GL_4_BYTES:
  915.          typeErrorFlag = GL_FALSE;
  916.          break;
  917.       default:
  918.          typeErrorFlag = GL_TRUE;
  919.    }
  920.  
  921.    for (i=0;i<n;i++) {
  922.       GLuint list = translate_id( i, type, lists );
  923.       Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
  924.       if (n) {
  925.          n[1].ui = list;
  926.          n[2].b = typeErrorFlag;
  927.       }
  928.    }
  929.    if (ctx->ExecuteFlag) {
  930.       (*ctx->Exec->CallLists)( n, type, lists );
  931.    }
  932. }
  933.  
  934.  
  935. static void save_Clear( GLbitfield mask )
  936. {
  937.    GET_CURRENT_CONTEXT(ctx);
  938.    Node *n;
  939.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  940.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
  941.    if (n) {
  942.       n[1].bf = mask;
  943.    }
  944.    if (ctx->ExecuteFlag) {
  945.       (*ctx->Exec->Clear)( mask );
  946.    }
  947. }
  948.  
  949.  
  950. static void save_ClearAccum( GLfloat red, GLfloat green,
  951.                              GLfloat blue, GLfloat alpha )
  952. {
  953.    GET_CURRENT_CONTEXT(ctx);
  954.    Node *n;
  955.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  956.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
  957.    if (n) {
  958.       n[1].f = red;
  959.       n[2].f = green;
  960.       n[3].f = blue;
  961.       n[4].f = alpha;
  962.    }
  963.    if (ctx->ExecuteFlag) {
  964.       (*ctx->Exec->ClearAccum)( red, green, blue, alpha );
  965.    }
  966. }
  967.  
  968.  
  969. static void save_ClearColor( GLclampf red, GLclampf green,
  970.                              GLclampf blue, GLclampf alpha )
  971. {
  972.    GET_CURRENT_CONTEXT(ctx);
  973.    Node *n;
  974.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  975.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
  976.    if (n) {
  977.       n[1].f = red;
  978.       n[2].f = green;
  979.       n[3].f = blue;
  980.       n[4].f = alpha;
  981.    }
  982.    if (ctx->ExecuteFlag) {
  983.       (*ctx->Exec->ClearColor)( red, green, blue, alpha );
  984.    }
  985. }
  986.  
  987.  
  988. static void save_ClearDepth( GLclampd depth )
  989. {
  990.    GET_CURRENT_CONTEXT(ctx);
  991.    Node *n;
  992.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  993.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
  994.    if (n) {
  995.       n[1].f = (GLfloat) depth;
  996.    }
  997.    if (ctx->ExecuteFlag) {
  998.       (*ctx->Exec->ClearDepth)( depth );
  999.    }
  1000. }
  1001.  
  1002.  
  1003. static void save_ClearIndex( GLfloat c )
  1004. {
  1005.    GET_CURRENT_CONTEXT(ctx);
  1006.    Node *n;
  1007.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1008.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
  1009.    if (n) {
  1010.       n[1].f = c;
  1011.    }
  1012.    if (ctx->ExecuteFlag) {
  1013.       (*ctx->Exec->ClearIndex)( c );
  1014.    }
  1015. }
  1016.  
  1017.  
  1018. static void save_ClearStencil( GLint s )
  1019. {
  1020.    GET_CURRENT_CONTEXT(ctx);
  1021.    Node *n;
  1022.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1023.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
  1024.    if (n) {
  1025.       n[1].i = s;
  1026.    }
  1027.    if (ctx->ExecuteFlag) {
  1028.       (*ctx->Exec->ClearStencil)( s );
  1029.    }
  1030. }
  1031.  
  1032.  
  1033. static void save_ClipPlane( GLenum plane, const GLdouble *equ )
  1034. {
  1035.    GET_CURRENT_CONTEXT(ctx);
  1036.    Node *n;
  1037.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1038.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
  1039.    if (n) {
  1040.       n[1].e = plane;
  1041.       n[2].f = (GLfloat) equ[0];
  1042.       n[3].f = (GLfloat) equ[1];
  1043.       n[4].f = (GLfloat) equ[2];
  1044.       n[5].f = (GLfloat) equ[3];
  1045.    }
  1046.    if (ctx->ExecuteFlag) {
  1047.       (*ctx->Exec->ClipPlane)( plane, equ );
  1048.    }
  1049. }
  1050.  
  1051.  
  1052.  
  1053. static void save_ColorMask( GLboolean red, GLboolean green,
  1054.                             GLboolean blue, GLboolean alpha )
  1055. {
  1056.    GET_CURRENT_CONTEXT(ctx);
  1057.    Node *n;
  1058.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1059.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
  1060.    if (n) {
  1061.       n[1].b = red;
  1062.       n[2].b = green;
  1063.       n[3].b = blue;
  1064.       n[4].b = alpha;
  1065.    }
  1066.    if (ctx->ExecuteFlag) {
  1067.       (*ctx->Exec->ColorMask)( red, green, blue, alpha );
  1068.    }
  1069. }
  1070.  
  1071.  
  1072. static void save_ColorMaterial( GLenum face, GLenum mode )
  1073. {
  1074.    GET_CURRENT_CONTEXT(ctx);
  1075.    Node *n;
  1076.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1077.    FLUSH_CURRENT(ctx, 0);
  1078.  
  1079.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
  1080.    if (n) {
  1081.       n[1].e = face;
  1082.       n[2].e = mode;
  1083.    }
  1084.    if (ctx->ExecuteFlag) {
  1085.       (*ctx->Exec->ColorMaterial)( face, mode );
  1086.    }
  1087. }
  1088.  
  1089.  
  1090. static void save_ColorTable( GLenum target, GLenum internalFormat,
  1091.                              GLsizei width, GLenum format, GLenum type,
  1092.                              const GLvoid *table )
  1093. {
  1094.    GET_CURRENT_CONTEXT(ctx);
  1095.    if (target == GL_PROXY_TEXTURE_1D ||
  1096.        target == GL_PROXY_TEXTURE_2D ||
  1097.        target == GL_PROXY_TEXTURE_3D ||
  1098.        target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
  1099.       /* execute immediately */
  1100.       (*ctx->Exec->ColorTable)( target, internalFormat, width,
  1101.                                 format, type, table );
  1102.    }
  1103.    else {
  1104.       GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
  1105.                                          &ctx->Unpack);
  1106.       Node *n;
  1107.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1108.       n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
  1109.       if (n) {
  1110.          n[1].e = target;
  1111.          n[2].e = internalFormat;
  1112.          n[3].i = width;
  1113.          n[4].e = format;
  1114.          n[5].e = type;
  1115.          n[6].data = image;
  1116.       }
  1117.       else if (image) {
  1118.          FREE(image);
  1119.       }
  1120.       if (ctx->ExecuteFlag) {
  1121.          (*ctx->Exec->ColorTable)( target, internalFormat, width,
  1122.                                    format, type, table );
  1123.       }
  1124.    }
  1125. }
  1126.  
  1127.  
  1128.  
  1129. static void
  1130. save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
  1131. {
  1132.    GET_CURRENT_CONTEXT(ctx);
  1133.    Node *n;
  1134.  
  1135.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1136.  
  1137.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
  1138.    if (n) {
  1139.       n[1].e = target;
  1140.       n[2].e = pname;
  1141.       n[3].f = params[0];
  1142.       if (pname == GL_COLOR_TABLE_SGI ||
  1143.           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
  1144.           pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
  1145.          n[4].f = params[1];
  1146.          n[5].f = params[2];
  1147.          n[6].f = params[3];
  1148.       }
  1149.    }
  1150.  
  1151.    if (ctx->ExecuteFlag) {
  1152.       (*ctx->Exec->ColorTableParameterfv)( target, pname, params );
  1153.    }
  1154. }
  1155.  
  1156.  
  1157. static void
  1158. save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
  1159. {
  1160.    GET_CURRENT_CONTEXT(ctx);
  1161.    Node *n;
  1162.  
  1163.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1164.  
  1165.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
  1166.    if (n) {
  1167.       n[1].e = target;
  1168.       n[2].e = pname;
  1169.       n[3].i = params[0];
  1170.       if (pname == GL_COLOR_TABLE_SGI ||
  1171.           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
  1172.           pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
  1173.          n[4].i = params[1];
  1174.          n[5].i = params[2];
  1175.          n[6].i = params[3];
  1176.       }
  1177.    }
  1178.  
  1179.    if (ctx->ExecuteFlag) {
  1180.       (*ctx->Exec->ColorTableParameteriv)( target, pname, params );
  1181.    }
  1182. }
  1183.  
  1184.  
  1185.  
  1186. static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
  1187.                                 GLenum format, GLenum type,
  1188.                                 const GLvoid *table)
  1189. {
  1190.    GET_CURRENT_CONTEXT(ctx);
  1191.    GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
  1192.                                       &ctx->Unpack);
  1193.    Node *n;
  1194.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1195.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
  1196.    if (n) {
  1197.       n[1].e = target;
  1198.       n[2].i = start;
  1199.       n[3].i = count;
  1200.       n[4].e = format;
  1201.       n[5].e = type;
  1202.       n[6].data = image;
  1203.    }
  1204.    else if (image) {
  1205.       FREE(image);
  1206.    }
  1207.    if (ctx->ExecuteFlag) {
  1208.       (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
  1209.    }
  1210. }
  1211.  
  1212.  
  1213. static void
  1214. save_CopyColorSubTable(GLenum target, GLsizei start,
  1215.                        GLint x, GLint y, GLsizei width)
  1216. {
  1217.    GET_CURRENT_CONTEXT(ctx);
  1218.    Node *n;
  1219.  
  1220.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1221.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
  1222.    if (n) {
  1223.       n[1].e = target;
  1224.       n[2].i = start;
  1225.       n[3].i = x;
  1226.       n[4].i = y;
  1227.       n[5].i = width;
  1228.    }
  1229.    if (ctx->ExecuteFlag) {
  1230.       (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width);
  1231.    }
  1232. }
  1233.  
  1234.  
  1235. static void
  1236. save_CopyColorTable(GLenum target, GLenum internalformat,
  1237.                     GLint x, GLint y, GLsizei width)
  1238. {
  1239.    GET_CURRENT_CONTEXT(ctx);
  1240.    Node *n;
  1241.  
  1242.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1243.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
  1244.    if (n) {
  1245.       n[1].e = target;
  1246.       n[2].e = internalformat;
  1247.       n[3].i = x;
  1248.       n[4].i = y;
  1249.       n[5].i = width;
  1250.    }
  1251.    if (ctx->ExecuteFlag) {
  1252.       (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width);
  1253.    }
  1254. }
  1255.  
  1256.  
  1257. static void
  1258. save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
  1259.                          GLenum format, GLenum type, const GLvoid *filter)
  1260. {
  1261.    GET_CURRENT_CONTEXT(ctx);
  1262.    GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
  1263.                                       &ctx->Unpack);
  1264.    Node *n;
  1265.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1266.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
  1267.    if (n) {
  1268.       n[1].e = target;
  1269.       n[2].e = internalFormat;
  1270.       n[3].i = width;
  1271.       n[4].e = format;
  1272.       n[5].e = type;
  1273.       n[6].data = image;
  1274.    }
  1275.    else if (image) {
  1276.       FREE(image);
  1277.    }
  1278.    if (ctx->ExecuteFlag) {
  1279.       (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width,
  1280.                                          format, type, filter );
  1281.    }
  1282. }
  1283.  
  1284.  
  1285. static void
  1286. save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
  1287.                          GLsizei width, GLsizei height, GLenum format,
  1288.                          GLenum type, const GLvoid *filter)
  1289. {
  1290.    GET_CURRENT_CONTEXT(ctx);
  1291.    GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
  1292.                                       &ctx->Unpack);
  1293.    Node *n;
  1294.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1295.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
  1296.    if (n) {
  1297.       n[1].e = target;
  1298.       n[2].e = internalFormat;
  1299.       n[3].i = width;
  1300.       n[4].i = height;
  1301.       n[5].e = format;
  1302.       n[6].e = type;
  1303.       n[7].data = image;
  1304.    }
  1305.    else if (image) {
  1306.       FREE(image);
  1307.    }
  1308.    if (ctx->ExecuteFlag) {
  1309.       (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height,
  1310.                                          format, type, filter );
  1311.    }
  1312. }
  1313.  
  1314.  
  1315. static void
  1316. save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
  1317. {
  1318.    GET_CURRENT_CONTEXT(ctx);
  1319.    Node *n;
  1320.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1321.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
  1322.    if (n) {
  1323.       n[1].e = target;
  1324.       n[2].e = pname;
  1325.       n[3].i = param;
  1326.    }
  1327.    if (ctx->ExecuteFlag) {
  1328.       (*ctx->Exec->ConvolutionParameteri)( target, pname, param );
  1329.    }
  1330. }
  1331.  
  1332.  
  1333. static void
  1334. save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
  1335. {
  1336.    GET_CURRENT_CONTEXT(ctx);
  1337.    Node *n;
  1338.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1339.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
  1340.    if (n) {
  1341.       n[1].e = target;
  1342.       n[2].e = pname;
  1343.       n[3].i = params[0];
  1344.       if (pname == GL_CONVOLUTION_BORDER_COLOR ||
  1345.           pname == GL_CONVOLUTION_FILTER_SCALE ||
  1346.           pname == GL_CONVOLUTION_FILTER_BIAS) {
  1347.          n[4].i = params[1];
  1348.          n[5].i = params[2];
  1349.          n[6].i = params[3];
  1350.       }
  1351.       else {
  1352.          n[4].i = n[5].i = n[6].i = 0;
  1353.       }
  1354.    }
  1355.    if (ctx->ExecuteFlag) {
  1356.       (*ctx->Exec->ConvolutionParameteriv)( target, pname, params );
  1357.    }
  1358. }
  1359.  
  1360.  
  1361. static void
  1362. save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
  1363. {
  1364.    GET_CURRENT_CONTEXT(ctx);
  1365.    Node *n;
  1366.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1367.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
  1368.    if (n) {
  1369.       n[1].e = target;
  1370.       n[2].e = pname;
  1371.       n[3].f = param;
  1372.    }
  1373.    if (ctx->ExecuteFlag) {
  1374.       (*ctx->Exec->ConvolutionParameterf)( target, pname, param );
  1375.    }
  1376. }
  1377.  
  1378.  
  1379. static void
  1380. save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
  1381. {
  1382.    GET_CURRENT_CONTEXT(ctx);
  1383.    Node *n;
  1384.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1385.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6 );
  1386.    if (n) {
  1387.       n[1].e = target;
  1388.       n[2].e = pname;
  1389.       n[3].f = params[0];
  1390.       if (pname == GL_CONVOLUTION_BORDER_COLOR ||
  1391.           pname == GL_CONVOLUTION_FILTER_SCALE ||
  1392.           pname == GL_CONVOLUTION_FILTER_BIAS) {
  1393.          n[4].f = params[1];
  1394.          n[5].f = params[2];
  1395.          n[6].f = params[3];
  1396.       }
  1397.       else {
  1398.          n[4].f = n[5].f = n[6].f = 0.0F;
  1399.       }
  1400.    }
  1401.    if (ctx->ExecuteFlag) {
  1402.       (*ctx->Exec->ConvolutionParameterfv)( target, pname, params );
  1403.    }
  1404. }
  1405.  
  1406.  
  1407. static void 
  1408. save_CopyPixels( GLint x, GLint y,
  1409.          GLsizei width, GLsizei height, GLenum type )
  1410. {
  1411.    GET_CURRENT_CONTEXT(ctx);
  1412.    Node *n;
  1413.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1414.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
  1415.    if (n) {
  1416.       n[1].i = x;
  1417.       n[2].i = y;
  1418.       n[3].i = (GLint) width;
  1419.       n[4].i = (GLint) height;
  1420.       n[5].e = type;
  1421.    }
  1422.    if (ctx->ExecuteFlag) {
  1423.       (*ctx->Exec->CopyPixels)( x, y, width, height, type );
  1424.    }
  1425. }
  1426.  
  1427.  
  1428.  
  1429. static void
  1430. save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
  1431.                      GLint x, GLint y, GLsizei width, GLint border )
  1432. {
  1433.    GET_CURRENT_CONTEXT(ctx);
  1434.    Node *n;
  1435.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1436.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
  1437.    if (n) {
  1438.       n[1].e = target;
  1439.       n[2].i = level;
  1440.       n[3].e = internalformat;
  1441.       n[4].i = x;
  1442.       n[5].i = y;
  1443.       n[6].i = width;
  1444.       n[7].i = border;
  1445.    }
  1446.    if (ctx->ExecuteFlag) {
  1447.       (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
  1448.                                    x, y, width, border );
  1449.    }
  1450. }
  1451.  
  1452.  
  1453. static void
  1454. save_CopyTexImage2D( GLenum target, GLint level,
  1455.                      GLenum internalformat,
  1456.                      GLint x, GLint y, GLsizei width,
  1457.                      GLsizei height, GLint border )
  1458. {
  1459.    GET_CURRENT_CONTEXT(ctx);
  1460.    Node *n;
  1461.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1462.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
  1463.    if (n) {
  1464.       n[1].e = target;
  1465.       n[2].i = level;
  1466.       n[3].e = internalformat;
  1467.       n[4].i = x;
  1468.       n[5].i = y;
  1469.       n[6].i = width;
  1470.       n[7].i = height;
  1471.       n[8].i = border;
  1472.    }
  1473.    if (ctx->ExecuteFlag) {
  1474.       (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
  1475.                                    x, y, width, height, border );
  1476.    }
  1477. }
  1478.  
  1479.  
  1480.  
  1481. static void
  1482. save_CopyTexSubImage1D( GLenum target, GLint level,
  1483.                         GLint xoffset, GLint x, GLint y,
  1484.                         GLsizei width )
  1485. {
  1486.    GET_CURRENT_CONTEXT(ctx);
  1487.    Node *n;
  1488.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1489.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
  1490.    if (n) {
  1491.       n[1].e = target;
  1492.       n[2].i = level;
  1493.       n[3].i = xoffset;
  1494.       n[4].i = x;
  1495.       n[5].i = y;
  1496.       n[6].i = width;
  1497.    }
  1498.    if (ctx->ExecuteFlag) {
  1499.       (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
  1500.    }
  1501. }
  1502.  
  1503.  
  1504. static void
  1505. save_CopyTexSubImage2D( GLenum target, GLint level,
  1506.                         GLint xoffset, GLint yoffset,
  1507.                         GLint x, GLint y,
  1508.                         GLsizei width, GLint height )
  1509. {
  1510.    GET_CURRENT_CONTEXT(ctx);
  1511.    Node *n;
  1512.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1513.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
  1514.    if (n) {
  1515.       n[1].e = target;
  1516.       n[2].i = level;
  1517.       n[3].i = xoffset;
  1518.       n[4].i = yoffset;
  1519.       n[5].i = x;
  1520.       n[6].i = y;
  1521.       n[7].i = width;
  1522.       n[8].i = height;
  1523.    }
  1524.    if (ctx->ExecuteFlag) {
  1525.       (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
  1526.                                x, y, width, height );
  1527.    }
  1528. }
  1529.  
  1530.  
  1531. static void
  1532. save_CopyTexSubImage3D( GLenum target, GLint level,
  1533.                         GLint xoffset, GLint yoffset, GLint zoffset,
  1534.                         GLint x, GLint y,
  1535.                         GLsizei width, GLint height )
  1536. {
  1537.    GET_CURRENT_CONTEXT(ctx);
  1538.    Node *n;
  1539.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1540.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
  1541.    if (n) {
  1542.       n[1].e = target;
  1543.       n[2].i = level;
  1544.       n[3].i = xoffset;
  1545.       n[4].i = yoffset;
  1546.       n[5].i = zoffset;
  1547.       n[6].i = x;
  1548.       n[7].i = y;
  1549.       n[8].i = width;
  1550.       n[9].i = height;
  1551.    }
  1552.    if (ctx->ExecuteFlag) {
  1553.       (*ctx->Exec->CopyTexSubImage3D)( target, level,
  1554.                                       xoffset, yoffset, zoffset,
  1555.                                       x, y, width, height );
  1556.    }
  1557. }
  1558.  
  1559.  
  1560. static void save_CullFace( GLenum mode )
  1561. {
  1562.    GET_CURRENT_CONTEXT(ctx);
  1563.    Node *n;
  1564.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1565.    n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
  1566.    if (n) {
  1567.       n[1].e = mode;
  1568.    }
  1569.    if (ctx->ExecuteFlag) {
  1570.       (*ctx->Exec->CullFace)( mode );
  1571.    }
  1572. }
  1573.  
  1574.  
  1575. static void save_DepthFunc( GLenum func )
  1576. {
  1577.    GET_CURRENT_CONTEXT(ctx);
  1578.    Node *n;
  1579.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1580.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
  1581.    if (n) {
  1582.       n[1].e = func;
  1583.    }
  1584.    if (ctx->ExecuteFlag) {
  1585.       (*ctx->Exec->DepthFunc)( func );
  1586.    }
  1587. }
  1588.  
  1589.  
  1590. static void save_DepthMask( GLboolean mask )
  1591. {
  1592.    GET_CURRENT_CONTEXT(ctx);
  1593.    Node *n;
  1594.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1595.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
  1596.    if (n) {
  1597.       n[1].b = mask;
  1598.    }
  1599.    if (ctx->ExecuteFlag) {
  1600.       (*ctx->Exec->DepthMask)( mask );
  1601.    }
  1602. }
  1603.  
  1604.  
  1605. static void save_DepthRange( GLclampd nearval, GLclampd farval )
  1606. {
  1607.    GET_CURRENT_CONTEXT(ctx);
  1608.    Node *n;
  1609.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1610.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
  1611.    if (n) {
  1612.       n[1].f = (GLfloat) nearval;
  1613.       n[2].f = (GLfloat) farval;
  1614.    }
  1615.    if (ctx->ExecuteFlag) {
  1616.       (*ctx->Exec->DepthRange)( nearval, farval );
  1617.    }
  1618. }
  1619.  
  1620.  
  1621. static void save_Disable( GLenum cap )
  1622. {
  1623.    GET_CURRENT_CONTEXT(ctx);
  1624.    Node *n;
  1625.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1626.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
  1627.    if (n) {
  1628.       n[1].e = cap;
  1629.    }
  1630.    if (ctx->ExecuteFlag) {
  1631.       (*ctx->Exec->Disable)( cap );
  1632.    }
  1633. }
  1634.  
  1635.  
  1636. static void save_DrawBuffer( GLenum mode )
  1637. {
  1638.    GET_CURRENT_CONTEXT(ctx);
  1639.    Node *n;
  1640.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1641.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
  1642.    if (n) {
  1643.       n[1].e = mode;
  1644.    }
  1645.    if (ctx->ExecuteFlag) {
  1646.       (*ctx->Exec->DrawBuffer)( mode );
  1647.    }
  1648. }
  1649.  
  1650.  
  1651. static void save_DrawPixels( GLsizei width, GLsizei height,
  1652.                              GLenum format, GLenum type,
  1653.                              const GLvoid *pixels )
  1654. {
  1655.    GET_CURRENT_CONTEXT(ctx);
  1656.    GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
  1657.                                       pixels, &ctx->Unpack);
  1658.    Node *n;
  1659.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1660.    n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
  1661.    if (n) {
  1662.       n[1].i = width;
  1663.       n[2].i = height;
  1664.       n[3].e = format;
  1665.       n[4].e = type;
  1666.       n[5].data = image;
  1667.    }
  1668.    else if (image) {
  1669.       FREE(image);
  1670.    }
  1671.    if (ctx->ExecuteFlag) {
  1672.       (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
  1673.    }
  1674. }
  1675.  
  1676.  
  1677.  
  1678. static void save_Enable( GLenum cap )
  1679. {
  1680.    GET_CURRENT_CONTEXT(ctx);
  1681.    Node *n;
  1682.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1683.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
  1684.    if (n) {
  1685.       n[1].e = cap;
  1686.    }
  1687.    if (ctx->ExecuteFlag) {
  1688.       (*ctx->Exec->Enable)( cap );
  1689.    }
  1690. }
  1691.  
  1692.  
  1693.  
  1694. void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
  1695. {
  1696.    GET_CURRENT_CONTEXT(ctx);
  1697.    Node *n;
  1698.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1699.    n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
  1700.    if (n) {
  1701.       n[1].e = mode;
  1702.       n[2].i = i1;
  1703.       n[3].i = i2;
  1704.    }
  1705.    if (ctx->ExecuteFlag) {
  1706.       (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
  1707.    }
  1708. }
  1709.  
  1710.  
  1711. void _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
  1712. {
  1713.    GET_CURRENT_CONTEXT(ctx);
  1714.    Node *n;
  1715.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1716.    n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
  1717.    if (n) {
  1718.       n[1].e = mode;
  1719.       n[2].i = i1;
  1720.       n[3].i = i2;
  1721.       n[4].i = j1;
  1722.       n[5].i = j2;
  1723.    }
  1724.    if (ctx->ExecuteFlag) {
  1725.       (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
  1726.    }
  1727. }
  1728.  
  1729.  
  1730.  
  1731.  
  1732. static void save_Fogfv( GLenum pname, const GLfloat *params )
  1733. {
  1734.    GET_CURRENT_CONTEXT(ctx);
  1735.    Node *n;
  1736.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1737.    n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
  1738.    if (n) {
  1739.       n[1].e = pname;
  1740.       n[2].f = params[0];
  1741.       n[3].f = params[1];
  1742.       n[4].f = params[2];
  1743.       n[5].f = params[3];
  1744.    }
  1745.    if (ctx->ExecuteFlag) {
  1746.       (*ctx->Exec->Fogfv)( pname, params );
  1747.    }
  1748. }
  1749.  
  1750.  
  1751. static void save_Fogf( GLenum pname, GLfloat param )
  1752. {
  1753.    save_Fogfv(pname, ¶m);
  1754. }
  1755.  
  1756.  
  1757. static void save_Fogiv(GLenum pname, const GLint *params )
  1758. {
  1759.    GLfloat p[4];
  1760.    switch (pname) {
  1761.       case GL_FOG_MODE:
  1762.       case GL_FOG_DENSITY:
  1763.       case GL_FOG_START:
  1764.       case GL_FOG_END:
  1765.       case GL_FOG_INDEX:
  1766.      p[0] = (GLfloat) *params;
  1767.      break;
  1768.       case GL_FOG_COLOR:
  1769.      p[0] = INT_TO_FLOAT( params[0] );
  1770.      p[1] = INT_TO_FLOAT( params[1] );
  1771.      p[2] = INT_TO_FLOAT( params[2] );
  1772.      p[3] = INT_TO_FLOAT( params[3] );
  1773.      break;
  1774.       default:
  1775.          /* Error will be caught later in gl_Fogfv */
  1776.          ;
  1777.    }
  1778.    save_Fogfv(pname, p);
  1779. }
  1780.  
  1781.  
  1782. static void save_Fogi(GLenum pname, GLint param )
  1783. {
  1784.    save_Fogiv(pname, ¶m);
  1785. }
  1786.  
  1787.  
  1788. static void save_FrontFace( GLenum mode )
  1789. {
  1790.    GET_CURRENT_CONTEXT(ctx);
  1791.    Node *n;
  1792.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1793.    n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
  1794.    if (n) {
  1795.       n[1].e = mode;
  1796.    }
  1797.    if (ctx->ExecuteFlag) {
  1798.       (*ctx->Exec->FrontFace)( mode );
  1799.    }
  1800. }
  1801.  
  1802.  
  1803. static void save_Frustum( GLdouble left, GLdouble right,
  1804.                       GLdouble bottom, GLdouble top,
  1805.                       GLdouble nearval, GLdouble farval )
  1806. {
  1807.    GET_CURRENT_CONTEXT(ctx);
  1808.    Node *n;
  1809.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1810.    n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
  1811.    if (n) {
  1812.       n[1].f = (GLfloat) left;
  1813.       n[2].f = (GLfloat) right;
  1814.       n[3].f = (GLfloat) bottom;
  1815.       n[4].f = (GLfloat) top;
  1816.       n[5].f = (GLfloat) nearval;
  1817.       n[6].f = (GLfloat) farval;
  1818.    }
  1819.    if (ctx->ExecuteFlag) {
  1820.       (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
  1821.    }
  1822. }
  1823.  
  1824.  
  1825. static void save_Hint( GLenum target, GLenum mode )
  1826. {
  1827.    GET_CURRENT_CONTEXT(ctx);
  1828.    Node *n;
  1829.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1830.    n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
  1831.    if (n) {
  1832.       n[1].e = target;
  1833.       n[2].e = mode;
  1834.    }
  1835.    if (ctx->ExecuteFlag) {
  1836.       (*ctx->Exec->Hint)( target, mode );
  1837.    }
  1838. }
  1839.  
  1840.  
  1841. static void
  1842. save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
  1843. {
  1844.    GET_CURRENT_CONTEXT(ctx);
  1845.    Node *n;
  1846.  
  1847.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1848.    n = ALLOC_INSTRUCTION( ctx, OPCODE_HISTOGRAM, 4 );
  1849.    if (n) {
  1850.       n[1].e = target;
  1851.       n[2].i = width;
  1852.       n[3].e = internalFormat;
  1853.       n[4].b = sink;
  1854.    }
  1855.    if (ctx->ExecuteFlag) {
  1856.       (*ctx->Exec->Histogram)( target, width, internalFormat, sink );
  1857.    }
  1858. }
  1859.  
  1860.  
  1861. static void save_IndexMask( GLuint mask )
  1862. {
  1863.    GET_CURRENT_CONTEXT(ctx);
  1864.    Node *n;
  1865.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1866.    n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
  1867.    if (n) {
  1868.       n[1].ui = mask;
  1869.    }
  1870.    if (ctx->ExecuteFlag) {
  1871.       (*ctx->Exec->IndexMask)( mask );
  1872.    }
  1873. }
  1874.  
  1875.  
  1876. static void save_InitNames( void )
  1877. {
  1878.    GET_CURRENT_CONTEXT(ctx);
  1879.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1880.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
  1881.    if (ctx->ExecuteFlag) {
  1882.       (*ctx->Exec->InitNames)();
  1883.    }
  1884. }
  1885.  
  1886.  
  1887. static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
  1888. {
  1889.    GET_CURRENT_CONTEXT(ctx);
  1890.    Node *n;
  1891.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1892.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
  1893.    if (OPCODE_LIGHT) {
  1894.       GLint i, nParams;
  1895.       n[1].e = light;
  1896.       n[2].e = pname;
  1897.       switch (pname) {
  1898.          case GL_AMBIENT:
  1899.             nParams = 4;
  1900.             break;
  1901.          case GL_DIFFUSE:
  1902.             nParams = 4;
  1903.             break;
  1904.          case GL_SPECULAR:
  1905.             nParams = 4;
  1906.             break;
  1907.          case GL_POSITION:
  1908.             nParams = 4;
  1909.             break;
  1910.          case GL_SPOT_DIRECTION:
  1911.             nParams = 3;
  1912.             break;
  1913.          case GL_SPOT_EXPONENT:
  1914.             nParams = 1;
  1915.             break;
  1916.          case GL_SPOT_CUTOFF:
  1917.             nParams = 1;
  1918.             break;
  1919.          case GL_CONSTANT_ATTENUATION:
  1920.             nParams = 1;
  1921.             break;
  1922.          case GL_LINEAR_ATTENUATION:
  1923.             nParams = 1;
  1924.             break;
  1925.          case GL_QUADRATIC_ATTENUATION:
  1926.             nParams = 1;
  1927.             break;
  1928.          default:
  1929.             nParams = 0;
  1930.       }
  1931.       for (i = 0; i < nParams; i++) {
  1932.      n[3+i].f = params[i];
  1933.       }
  1934.    }
  1935.    if (ctx->ExecuteFlag) {
  1936.       (*ctx->Exec->Lightfv)( light, pname, params );
  1937.    }
  1938. }
  1939.  
  1940.  
  1941. static void save_Lightf( GLenum light, GLenum pname, GLfloat params )
  1942. {
  1943.    save_Lightfv(light, pname, ¶ms);
  1944. }
  1945.  
  1946.  
  1947. static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
  1948. {
  1949.    GLfloat fparam[4];
  1950.    switch (pname) {
  1951.       case GL_AMBIENT:
  1952.       case GL_DIFFUSE:
  1953.       case GL_SPECULAR:
  1954.          fparam[0] = INT_TO_FLOAT( params[0] );
  1955.          fparam[1] = INT_TO_FLOAT( params[1] );
  1956.          fparam[2] = INT_TO_FLOAT( params[2] );
  1957.          fparam[3] = INT_TO_FLOAT( params[3] );
  1958.          break;
  1959.       case GL_POSITION:
  1960.          fparam[0] = (GLfloat) params[0];
  1961.          fparam[1] = (GLfloat) params[1];
  1962.          fparam[2] = (GLfloat) params[2];
  1963.          fparam[3] = (GLfloat) params[3];
  1964.          break;
  1965.       case GL_SPOT_DIRECTION:
  1966.          fparam[0] = (GLfloat) params[0];
  1967.          fparam[1] = (GLfloat) params[1];
  1968.          fparam[2] = (GLfloat) params[2];
  1969.          break;
  1970.       case GL_SPOT_EXPONENT:
  1971.       case GL_SPOT_CUTOFF:
  1972.       case GL_CONSTANT_ATTENUATION:
  1973.       case GL_LINEAR_ATTENUATION:
  1974.       case GL_QUADRATIC_ATTENUATION:
  1975.          fparam[0] = (GLfloat) params[0];
  1976.          break;
  1977.       default:
  1978.          /* error will be caught later in gl_Lightfv */
  1979.          ;
  1980.    }
  1981.    save_Lightfv( light, pname, fparam );
  1982. }
  1983.  
  1984.  
  1985. static void save_Lighti( GLenum light, GLenum pname, GLint param )
  1986. {
  1987.    save_Lightiv( light, pname, ¶m );
  1988. }
  1989.  
  1990.  
  1991. static void save_LightModelfv( GLenum pname, const GLfloat *params )
  1992. {
  1993.    GET_CURRENT_CONTEXT(ctx);
  1994.    Node *n;
  1995.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  1996.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
  1997.    if (n) {
  1998.       n[1].e = pname;
  1999.       n[2].f = params[0];
  2000.       n[3].f = params[1];
  2001.       n[4].f = params[2];
  2002.       n[5].f = params[3];
  2003.    }
  2004.    if (ctx->ExecuteFlag) {
  2005.       (*ctx->Exec->LightModelfv)( pname, params );
  2006.    }
  2007. }
  2008.  
  2009.  
  2010. static void save_LightModelf( GLenum pname, GLfloat param )
  2011. {
  2012.    save_LightModelfv(pname, ¶m);
  2013. }
  2014.  
  2015.  
  2016. static void save_LightModeliv( GLenum pname, const GLint *params )
  2017. {
  2018.    GLfloat fparam[4];
  2019.    switch (pname) {
  2020.       case GL_LIGHT_MODEL_AMBIENT:
  2021.          fparam[0] = INT_TO_FLOAT( params[0] );
  2022.          fparam[1] = INT_TO_FLOAT( params[1] );
  2023.          fparam[2] = INT_TO_FLOAT( params[2] );
  2024.          fparam[3] = INT_TO_FLOAT( params[3] );
  2025.          break;
  2026.       case GL_LIGHT_MODEL_LOCAL_VIEWER:
  2027.       case GL_LIGHT_MODEL_TWO_SIDE:
  2028.       case GL_LIGHT_MODEL_COLOR_CONTROL:
  2029.          fparam[0] = (GLfloat) params[0];
  2030.          break;
  2031.       default:
  2032.          /* Error will be caught later in gl_LightModelfv */
  2033.          ;
  2034.    }
  2035.    save_LightModelfv(pname, fparam);
  2036. }
  2037.  
  2038.  
  2039. static void save_LightModeli( GLenum pname, GLint param )
  2040. {
  2041.    save_LightModeliv(pname, ¶m);
  2042. }
  2043.  
  2044.  
  2045. static void save_LineStipple( GLint factor, GLushort pattern )
  2046. {
  2047.    GET_CURRENT_CONTEXT(ctx);
  2048.    Node *n;
  2049.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2050.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
  2051.    if (n) {
  2052.       n[1].i = factor;
  2053.       n[2].us = pattern;
  2054.    }
  2055.    if (ctx->ExecuteFlag) {
  2056.       (*ctx->Exec->LineStipple)( factor, pattern );
  2057.    }
  2058. }
  2059.  
  2060.  
  2061. static void save_LineWidth( GLfloat width )
  2062. {
  2063.    GET_CURRENT_CONTEXT(ctx);
  2064.    Node *n;
  2065.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2066.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
  2067.    if (n) {
  2068.       n[1].f = width;
  2069.    }
  2070.    if (ctx->ExecuteFlag) {
  2071.       (*ctx->Exec->LineWidth)( width );
  2072.    }
  2073. }
  2074.  
  2075.  
  2076. static void save_ListBase( GLuint base )
  2077. {
  2078.    GET_CURRENT_CONTEXT(ctx);
  2079.    Node *n;
  2080.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2081.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
  2082.    if (n) {
  2083.       n[1].ui = base;
  2084.    }
  2085.    if (ctx->ExecuteFlag) {
  2086.       (*ctx->Exec->ListBase)( base );
  2087.    }
  2088. }
  2089.  
  2090.  
  2091. static void save_LoadIdentity( void )
  2092. {
  2093.    GET_CURRENT_CONTEXT(ctx);
  2094.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2095.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
  2096.    if (ctx->ExecuteFlag) {
  2097.       (*ctx->Exec->LoadIdentity)();
  2098.    }
  2099. }
  2100.  
  2101.  
  2102. static void save_LoadMatrixf( const GLfloat *m )
  2103. {
  2104.    GET_CURRENT_CONTEXT(ctx);
  2105.    Node *n;
  2106.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2107.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
  2108.    if (n) {
  2109.       GLuint i;
  2110.       for (i=0;i<16;i++) {
  2111.      n[1+i].f = m[i];
  2112.       }
  2113.    }
  2114.    if (ctx->ExecuteFlag) {
  2115.       (*ctx->Exec->LoadMatrixf)( m );
  2116.    }
  2117. }
  2118.  
  2119.  
  2120. static void save_LoadMatrixd( const GLdouble *m )
  2121. {
  2122.    GLfloat f[16];
  2123.    GLint i;
  2124.    for (i = 0; i < 16; i++) {
  2125.       f[i] = (GLfloat) m[i];
  2126.    }
  2127.    save_LoadMatrixf(f);
  2128. }
  2129.  
  2130.  
  2131. static void save_LoadName( GLuint name )
  2132. {
  2133.    GET_CURRENT_CONTEXT(ctx);
  2134.    Node *n;
  2135.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2136.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
  2137.    if (n) {
  2138.       n[1].ui = name;
  2139.    }
  2140.    if (ctx->ExecuteFlag) {
  2141.       (*ctx->Exec->LoadName)( name );
  2142.    }
  2143. }
  2144.  
  2145.  
  2146. static void save_LogicOp( GLenum opcode )
  2147. {
  2148.    GET_CURRENT_CONTEXT(ctx);
  2149.    Node *n;
  2150.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2151.    n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
  2152.    if (n) {
  2153.       n[1].e = opcode;
  2154.    }
  2155.    if (ctx->ExecuteFlag) {
  2156.       (*ctx->Exec->LogicOp)( opcode );
  2157.    }
  2158. }
  2159.  
  2160.  
  2161. static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
  2162.                         GLint order, const GLdouble *points)
  2163. {
  2164.    GET_CURRENT_CONTEXT(ctx);
  2165.    Node *n;
  2166.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2167.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
  2168.    if (n) {
  2169.       GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
  2170.       n[1].e = target;
  2171.       n[2].f = (GLfloat) u1;
  2172.       n[3].f = (GLfloat) u2;
  2173.       n[4].i = _mesa_evaluator_components(target);  /* stride */
  2174.       n[5].i = order;
  2175.       n[6].data = (void *) pnts;
  2176.    }
  2177.    if (ctx->ExecuteFlag) {
  2178.       (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
  2179.    }
  2180. }
  2181.  
  2182. static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
  2183.                         GLint order, const GLfloat *points)
  2184. {
  2185.    GET_CURRENT_CONTEXT(ctx);
  2186.    Node *n;
  2187.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2188.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
  2189.    if (n) {
  2190.       GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
  2191.       n[1].e = target;
  2192.       n[2].f = u1;
  2193.       n[3].f = u2;
  2194.       n[4].i = _mesa_evaluator_components(target);  /* stride */
  2195.       n[5].i = order;
  2196.       n[6].data = (void *) pnts;
  2197.    }
  2198.    if (ctx->ExecuteFlag) {
  2199.       (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
  2200.    }
  2201. }
  2202.  
  2203.  
  2204. static void save_Map2d( GLenum target,
  2205.                         GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
  2206.                         GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
  2207.                         const GLdouble *points )
  2208. {
  2209.    GET_CURRENT_CONTEXT(ctx);
  2210.    Node *n;
  2211.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2212.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
  2213.    if (n) {
  2214.       GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
  2215.                                             vstride, vorder, points );
  2216.       n[1].e = target;
  2217.       n[2].f = (GLfloat) u1;
  2218.       n[3].f = (GLfloat) u2;
  2219.       n[4].f = (GLfloat) v1;
  2220.       n[5].f = (GLfloat) v2;
  2221.       /* XXX verify these strides are correct */
  2222.       n[6].i = _mesa_evaluator_components(target) * vorder;  /*ustride*/
  2223.       n[7].i = _mesa_evaluator_components(target);           /*vstride*/
  2224.       n[8].i = uorder;
  2225.       n[9].i = vorder;
  2226.       n[10].data = (void *) pnts;
  2227.    }
  2228.    if (ctx->ExecuteFlag) {
  2229.       (*ctx->Exec->Map2d)( target,
  2230.                           u1, u2, ustride, uorder,
  2231.                           v1, v2, vstride, vorder, points );
  2232.    }
  2233. }
  2234.  
  2235.  
  2236. static void save_Map2f( GLenum target,
  2237.                         GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
  2238.                         GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
  2239.                         const GLfloat *points )
  2240. {
  2241.    GET_CURRENT_CONTEXT(ctx);
  2242.    Node *n;
  2243.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2244.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
  2245.    if (n) {
  2246.       GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
  2247.                                             vstride, vorder, points );
  2248.       n[1].e = target;
  2249.       n[2].f = u1;
  2250.       n[3].f = u2;
  2251.       n[4].f = v1;
  2252.       n[5].f = v2;
  2253.       /* XXX verify these strides are correct */
  2254.       n[6].i = _mesa_evaluator_components(target) * vorder;  /*ustride*/
  2255.       n[7].i = _mesa_evaluator_components(target);           /*vstride*/
  2256.       n[8].i = uorder;
  2257.       n[9].i = vorder;
  2258.       n[10].data = (void *) pnts;
  2259.    }
  2260.    if (ctx->ExecuteFlag) {
  2261.       (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
  2262.                           v1, v2, vstride, vorder, points );
  2263.    }
  2264. }
  2265.  
  2266.  
  2267. static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
  2268. {
  2269.    GET_CURRENT_CONTEXT(ctx);
  2270.    Node *n;
  2271.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2272.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
  2273.    if (n) {
  2274.       n[1].i = un;
  2275.       n[2].f = u1;
  2276.       n[3].f = u2;
  2277.    }
  2278.    if (ctx->ExecuteFlag) {
  2279.       (*ctx->Exec->MapGrid1f)( un, u1, u2 );
  2280.    }
  2281. }
  2282.  
  2283.  
  2284. static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
  2285. {
  2286.    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
  2287. }
  2288.  
  2289.  
  2290. static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
  2291.                             GLint vn, GLfloat v1, GLfloat v2 )
  2292. {
  2293.    GET_CURRENT_CONTEXT(ctx);
  2294.    Node *n;
  2295.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2296.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
  2297.    if (n) {
  2298.       n[1].i = un;
  2299.       n[2].f = u1;
  2300.       n[3].f = u2;
  2301.       n[4].i = vn;
  2302.       n[5].f = v1;
  2303.       n[6].f = v2;
  2304.    }
  2305.    if (ctx->ExecuteFlag) {
  2306.       (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
  2307.    }
  2308. }
  2309.  
  2310.  
  2311.  
  2312. static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
  2313.                             GLint vn, GLdouble v1, GLdouble v2 )
  2314. {
  2315.    save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, 
  2316.           vn, (GLfloat) v1, (GLfloat) v2);
  2317. }
  2318.  
  2319.  
  2320. static void save_MatrixMode( GLenum mode )
  2321. {
  2322.    GET_CURRENT_CONTEXT(ctx);
  2323.    Node *n;
  2324.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2325.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
  2326.    if (n) {
  2327.       n[1].e = mode;
  2328.    }
  2329.    if (ctx->ExecuteFlag) {
  2330.       (*ctx->Exec->MatrixMode)( mode );
  2331.    }
  2332. }
  2333.  
  2334.  
  2335. static void
  2336. save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
  2337. {
  2338.    GET_CURRENT_CONTEXT(ctx);
  2339.    Node *n;
  2340.  
  2341.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2342.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MIN_MAX, 3 );
  2343.    if (n) {
  2344.       n[1].e = target;
  2345.       n[2].e = internalFormat;
  2346.       n[3].b = sink;
  2347.    }
  2348.    if (ctx->ExecuteFlag) {
  2349.       (*ctx->Exec->Minmax)( target, internalFormat, sink );
  2350.    }
  2351. }
  2352.  
  2353.  
  2354. static void save_MultMatrixf( const GLfloat *m )
  2355. {
  2356.    GET_CURRENT_CONTEXT(ctx);
  2357.    Node *n;
  2358.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2359.    n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
  2360.    if (n) {
  2361.       GLuint i;
  2362.       for (i=0;i<16;i++) {
  2363.      n[1+i].f = m[i];
  2364.       }
  2365.    }
  2366.    if (ctx->ExecuteFlag) {
  2367.       (*ctx->Exec->MultMatrixf)( m );
  2368.    }
  2369. }
  2370.  
  2371.  
  2372. static void save_MultMatrixd( const GLdouble *m )
  2373. {
  2374.    GLfloat f[16];
  2375.    GLint i;
  2376.    for (i = 0; i < 16; i++) {
  2377.       f[i] = (GLfloat) m[i];
  2378.    }
  2379.    save_MultMatrixf(f);
  2380. }
  2381.  
  2382.  
  2383. static void save_NewList( GLuint list, GLenum mode )
  2384. {
  2385.    GET_CURRENT_CONTEXT(ctx);
  2386.    /* It's an error to call this function while building a display list */
  2387.    _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  2388.    (void) list;
  2389.    (void) mode;
  2390. }
  2391.  
  2392.  
  2393.  
  2394. static void save_Ortho( GLdouble left, GLdouble right,
  2395.                     GLdouble bottom, GLdouble top,
  2396.                     GLdouble nearval, GLdouble farval )
  2397. {
  2398.    GET_CURRENT_CONTEXT(ctx);
  2399.    Node *n;
  2400.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2401.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
  2402.    if (n) {
  2403.       n[1].f = (GLfloat) left;
  2404.       n[2].f = (GLfloat) right;
  2405.       n[3].f = (GLfloat) bottom;
  2406.       n[4].f = (GLfloat) top;
  2407.       n[5].f = (GLfloat) nearval;
  2408.       n[6].f = (GLfloat) farval;
  2409.    }
  2410.    if (ctx->ExecuteFlag) {
  2411.       (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
  2412.    }
  2413. }
  2414.  
  2415.  
  2416. static void
  2417. save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
  2418. {
  2419.    GET_CURRENT_CONTEXT(ctx);
  2420.    Node *n;
  2421.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2422.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
  2423.    if (n) {
  2424.       n[1].e = map;
  2425.       n[2].i = mapsize;
  2426.       n[3].data  = (void *) MALLOC( mapsize * sizeof(GLfloat) );
  2427.       MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
  2428.    }
  2429.    if (ctx->ExecuteFlag) {
  2430.       (*ctx->Exec->PixelMapfv)( map, mapsize, values );
  2431.    }
  2432. }
  2433.  
  2434.  
  2435. static void
  2436. save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
  2437. {
  2438.    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
  2439.    GLint i;
  2440.    if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
  2441.       for (i=0;i<mapsize;i++) {
  2442.          fvalues[i] = (GLfloat) values[i];
  2443.       }
  2444.    }
  2445.    else {
  2446.       for (i=0;i<mapsize;i++) {
  2447.          fvalues[i] = UINT_TO_FLOAT( values[i] );
  2448.       }
  2449.    }
  2450.    save_PixelMapfv(map, mapsize, fvalues);
  2451. }
  2452.  
  2453.  
  2454. static void
  2455. save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
  2456. {
  2457.    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
  2458.    GLint i;
  2459.    if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
  2460.       for (i=0;i<mapsize;i++) {
  2461.          fvalues[i] = (GLfloat) values[i];
  2462.       }
  2463.    }
  2464.    else {
  2465.       for (i=0;i<mapsize;i++) {
  2466.          fvalues[i] = USHORT_TO_FLOAT( values[i] );
  2467.       }
  2468.    }
  2469.    save_PixelMapfv(map, mapsize, fvalues);
  2470. }
  2471.  
  2472.  
  2473. static void
  2474. save_PixelTransferf( GLenum pname, GLfloat param )
  2475. {
  2476.    GET_CURRENT_CONTEXT(ctx);
  2477.    Node *n;
  2478.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2479.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
  2480.    if (n) {
  2481.       n[1].e = pname;
  2482.       n[2].f = param;
  2483.    }
  2484.    if (ctx->ExecuteFlag) {
  2485.       (*ctx->Exec->PixelTransferf)( pname, param );
  2486.    }
  2487. }
  2488.  
  2489.  
  2490. static void
  2491. save_PixelTransferi( GLenum pname, GLint param )
  2492. {
  2493.    save_PixelTransferf( pname, (GLfloat) param );
  2494. }
  2495.  
  2496.  
  2497. static void
  2498. save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
  2499. {
  2500.    GET_CURRENT_CONTEXT(ctx);
  2501.    Node *n;
  2502.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2503.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
  2504.    if (n) {
  2505.       n[1].f = xfactor;
  2506.       n[2].f = yfactor;
  2507.    }
  2508.    if (ctx->ExecuteFlag) {
  2509.       (*ctx->Exec->PixelZoom)( xfactor, yfactor );
  2510.    }
  2511. }
  2512.  
  2513.  
  2514. static void
  2515. save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
  2516. {
  2517.    GET_CURRENT_CONTEXT(ctx);
  2518.    Node *n;
  2519.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2520.    n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
  2521.    if (n) {
  2522.       n[1].e = pname;
  2523.       n[2].f = params[0];
  2524.       n[3].f = params[1];
  2525.       n[4].f = params[2];
  2526.    }
  2527.    if (ctx->ExecuteFlag) {
  2528.       (*ctx->Exec->PointParameterfvEXT)( pname, params );
  2529.    }
  2530. }
  2531.  
  2532.  
  2533. static void save_PointParameterfEXT( GLenum pname, GLfloat param )
  2534. {
  2535.    save_PointParameterfvEXT(pname, ¶m);
  2536. }
  2537.  
  2538. static void save_PointParameteriNV( GLenum pname, GLint param )
  2539. {
  2540.    GLfloat p = (GLfloat) param;
  2541.    save_PointParameterfvEXT(pname, &p);
  2542. }
  2543.  
  2544. static void save_PointParameterivNV( GLenum pname, const GLint *param )
  2545. {
  2546.    GLfloat p = (GLfloat) param[0];
  2547.    save_PointParameterfvEXT(pname, &p);
  2548. }
  2549.  
  2550.  
  2551. static void save_PointSize( GLfloat size )
  2552. {
  2553.    GET_CURRENT_CONTEXT(ctx);
  2554.    Node *n;
  2555.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2556.    n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
  2557.    if (n) {
  2558.       n[1].f = size;
  2559.    }
  2560.    if (ctx->ExecuteFlag) {
  2561.       (*ctx->Exec->PointSize)( size );
  2562.    }
  2563. }
  2564.  
  2565.  
  2566. static void save_PolygonMode( GLenum face, GLenum mode )
  2567. {
  2568.    GET_CURRENT_CONTEXT(ctx);
  2569.    Node *n;
  2570.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2571.    n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
  2572.    if (n) {
  2573.       n[1].e = face;
  2574.       n[2].e = mode;
  2575.    }
  2576.    if (ctx->ExecuteFlag) {
  2577.       (*ctx->Exec->PolygonMode)( face, mode );
  2578.    }
  2579. }
  2580.  
  2581.  
  2582. /*
  2583.  * Polygon stipple must have been upacked already!
  2584.  */
  2585. static void save_PolygonStipple( const GLubyte *pattern )
  2586. {
  2587.    GET_CURRENT_CONTEXT(ctx);
  2588.    Node *n;
  2589.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2590.    n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
  2591.    if (n) {
  2592.       void *data;
  2593.       n[1].data = MALLOC( 32 * 4 );
  2594.       data = n[1].data;   /* This needed for Acorn compiler */
  2595.       MEMCPY( data, pattern, 32 * 4 );
  2596.    }
  2597.    if (ctx->ExecuteFlag) {
  2598.       (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
  2599.    }
  2600. }
  2601.  
  2602.  
  2603. static void save_PolygonOffset( GLfloat factor, GLfloat units )
  2604. {
  2605.    GET_CURRENT_CONTEXT(ctx);
  2606.    Node *n;
  2607.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2608.    n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
  2609.    if (n) {
  2610.       n[1].f = factor;
  2611.       n[2].f = units;
  2612.    }
  2613.    if (ctx->ExecuteFlag) {
  2614.       (*ctx->Exec->PolygonOffset)( factor, units );
  2615.    }
  2616. }
  2617.  
  2618.  
  2619. static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
  2620. {
  2621.    GET_CURRENT_CONTEXT(ctx);
  2622.    save_PolygonOffset(factor, ctx->DepthMaxF * bias);
  2623. }
  2624.  
  2625.  
  2626. static void save_PopAttrib( void )
  2627. {
  2628.    GET_CURRENT_CONTEXT(ctx);
  2629.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2630.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
  2631.    if (ctx->ExecuteFlag) {
  2632.       (*ctx->Exec->PopAttrib)();
  2633.    }
  2634. }
  2635.  
  2636.  
  2637. static void save_PopMatrix( void )
  2638. {
  2639.    GET_CURRENT_CONTEXT(ctx);
  2640.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2641.    FLUSH_CURRENT(ctx, 0);
  2642.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
  2643.    if (ctx->ExecuteFlag) {
  2644.       (*ctx->Exec->PopMatrix)();
  2645.    }
  2646. }
  2647.  
  2648.  
  2649. static void save_PopName( void )
  2650. {
  2651.    GET_CURRENT_CONTEXT(ctx);
  2652.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2653.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
  2654.    if (ctx->ExecuteFlag) {
  2655.       (*ctx->Exec->PopName)();
  2656.    }
  2657. }
  2658.  
  2659.  
  2660. static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
  2661.                                      const GLclampf *priorities )
  2662. {
  2663.    GET_CURRENT_CONTEXT(ctx);
  2664.    GLint i;
  2665.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2666.  
  2667.    for (i=0;i<num;i++) {
  2668.       Node *n;
  2669.       n = ALLOC_INSTRUCTION( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
  2670.       if (n) {
  2671.          n[1].ui = textures[i];
  2672.          n[2].f = priorities[i];
  2673.       }
  2674.    }
  2675.    if (ctx->ExecuteFlag) {
  2676.       (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
  2677.    }
  2678. }
  2679.  
  2680.  
  2681. static void save_PushAttrib( GLbitfield mask )
  2682. {
  2683.    GET_CURRENT_CONTEXT(ctx);
  2684.    Node *n;
  2685.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2686.    FLUSH_CURRENT(ctx, 0);
  2687.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
  2688.    if (n) {
  2689.       n[1].bf = mask;
  2690.    }
  2691.    if (ctx->ExecuteFlag) {
  2692.       (*ctx->Exec->PushAttrib)( mask );
  2693.    }
  2694. }
  2695.  
  2696.  
  2697. static void save_PushMatrix( void )
  2698. {
  2699.    GET_CURRENT_CONTEXT(ctx);
  2700.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2701.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
  2702.    if (ctx->ExecuteFlag) {
  2703.       (*ctx->Exec->PushMatrix)();
  2704.    }
  2705. }
  2706.  
  2707.  
  2708. static void save_PushName( GLuint name )
  2709. {
  2710.    GET_CURRENT_CONTEXT(ctx);
  2711.    Node *n;
  2712.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2713.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
  2714.    if (n) {
  2715.       n[1].ui = name;
  2716.    }
  2717.    if (ctx->ExecuteFlag) {
  2718.       (*ctx->Exec->PushName)( name );
  2719.    }
  2720. }
  2721.  
  2722.  
  2723. static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2724. {
  2725.    GET_CURRENT_CONTEXT(ctx);
  2726.    Node *n;
  2727.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2728.    FLUSH_CURRENT(ctx, 0);
  2729.    n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
  2730.    if (n) {
  2731.       n[1].f = x;
  2732.       n[2].f = y;
  2733.       n[3].f = z;
  2734.       n[4].f = w;
  2735.    }
  2736.    if (ctx->ExecuteFlag) {
  2737.       (*ctx->Exec->RasterPos4f)( x, y, z, w );
  2738.    }
  2739. }
  2740.  
  2741. static void save_RasterPos2d(GLdouble x, GLdouble y)
  2742. {
  2743.    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
  2744. }
  2745.  
  2746. static void save_RasterPos2f(GLfloat x, GLfloat y)
  2747. {
  2748.    save_RasterPos4f(x, y, 0.0F, 1.0F);
  2749. }
  2750.  
  2751. static void save_RasterPos2i(GLint x, GLint y)
  2752. {
  2753.    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
  2754. }
  2755.  
  2756. static void save_RasterPos2s(GLshort x, GLshort y)
  2757. {
  2758.    save_RasterPos4f(x, y, 0.0F, 1.0F);
  2759. }
  2760.  
  2761. static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
  2762. {
  2763.    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
  2764. }
  2765.  
  2766. static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
  2767. {
  2768.    save_RasterPos4f(x, y, z, 1.0F);
  2769. }
  2770.  
  2771. static void save_RasterPos3i(GLint x, GLint y, GLint z)
  2772. {
  2773.    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
  2774. }
  2775.  
  2776. static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
  2777. {
  2778.    save_RasterPos4f(x, y, z, 1.0F);
  2779. }
  2780.  
  2781. static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
  2782. {
  2783.    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  2784. }
  2785.  
  2786. static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
  2787. {
  2788.    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  2789. }
  2790.  
  2791. static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
  2792. {
  2793.    save_RasterPos4f(x, y, z, w);
  2794. }
  2795.  
  2796. static void save_RasterPos2dv(const GLdouble *v)
  2797. {
  2798.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
  2799. }
  2800.  
  2801. static void save_RasterPos2fv(const GLfloat *v)
  2802. {
  2803.    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
  2804. }
  2805.  
  2806. static void save_RasterPos2iv(const GLint *v)
  2807. {
  2808.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
  2809. }
  2810.  
  2811. static void save_RasterPos2sv(const GLshort *v)
  2812. {
  2813.    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
  2814. }
  2815.  
  2816. static void save_RasterPos3dv(const GLdouble *v)
  2817. {
  2818.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
  2819. }
  2820.  
  2821. static void save_RasterPos3fv(const GLfloat *v)
  2822. {
  2823.    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
  2824. }
  2825.  
  2826. static void save_RasterPos3iv(const GLint *v)
  2827. {
  2828.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
  2829. }
  2830.  
  2831. static void save_RasterPos3sv(const GLshort *v)
  2832. {
  2833.    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
  2834. }
  2835.  
  2836. static void save_RasterPos4dv(const GLdouble *v)
  2837. {
  2838.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
  2839.             (GLfloat) v[2], (GLfloat) v[3]);
  2840. }
  2841.  
  2842. static void save_RasterPos4fv(const GLfloat *v)
  2843. {
  2844.    save_RasterPos4f(v[0], v[1], v[2], v[3]);
  2845. }
  2846.  
  2847. static void save_RasterPos4iv(const GLint *v)
  2848. {
  2849.    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
  2850.             (GLfloat) v[2], (GLfloat) v[3]);
  2851. }
  2852.  
  2853. static void save_RasterPos4sv(const GLshort *v)
  2854. {
  2855.    save_RasterPos4f(v[0], v[1], v[2], v[3]);
  2856. }
  2857.  
  2858.  
  2859. static void save_PassThrough( GLfloat token )
  2860. {
  2861.    GET_CURRENT_CONTEXT(ctx);
  2862.    Node *n;
  2863.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2864.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
  2865.    if (n) {
  2866.       n[1].f = token;
  2867.    }
  2868.    if (ctx->ExecuteFlag) {
  2869.       (*ctx->Exec->PassThrough)( token );
  2870.    }
  2871. }
  2872.  
  2873.  
  2874. static void save_ReadBuffer( GLenum mode )
  2875. {
  2876.    GET_CURRENT_CONTEXT(ctx);
  2877.    Node *n;
  2878.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2879.    n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
  2880.    if (n) {
  2881.       n[1].e = mode;
  2882.    }
  2883.    if (ctx->ExecuteFlag) {
  2884.       (*ctx->Exec->ReadBuffer)( mode );
  2885.    }
  2886. }
  2887.  
  2888.  
  2889. static void
  2890. save_ResetHistogram(GLenum target)
  2891. {
  2892.    GET_CURRENT_CONTEXT(ctx);
  2893.    Node *n;
  2894.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2895.    n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
  2896.    if (n) {
  2897.       n[1].e = target;
  2898.    }
  2899.    if (ctx->ExecuteFlag) {
  2900.       (*ctx->Exec->ResetHistogram)( target );
  2901.    }
  2902. }
  2903.  
  2904.  
  2905. static void
  2906. save_ResetMinmax(GLenum target)
  2907. {
  2908.    GET_CURRENT_CONTEXT(ctx);
  2909.    Node *n;
  2910.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2911.    n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
  2912.    if (n) {
  2913.       n[1].e = target;
  2914.    }
  2915.    if (ctx->ExecuteFlag) {
  2916.       (*ctx->Exec->ResetMinmax)( target );
  2917.    }
  2918. }
  2919.  
  2920.  
  2921. static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
  2922. {
  2923.    GET_CURRENT_CONTEXT(ctx);
  2924.    Node *n;
  2925.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2926.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
  2927.    if (n) {
  2928.       n[1].f = angle;
  2929.       n[2].f = x;
  2930.       n[3].f = y;
  2931.       n[4].f = z;
  2932.    }
  2933.    if (ctx->ExecuteFlag) {
  2934.       (*ctx->Exec->Rotatef)( angle, x, y, z );
  2935.    }
  2936. }
  2937.  
  2938.  
  2939. static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
  2940. {
  2941.    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
  2942. }
  2943.  
  2944.  
  2945. static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
  2946. {
  2947.    GET_CURRENT_CONTEXT(ctx);
  2948.    Node *n;
  2949.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2950.    n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
  2951.    if (n) {
  2952.       n[1].f = x;
  2953.       n[2].f = y;
  2954.       n[3].f = z;
  2955.    }
  2956.    if (ctx->ExecuteFlag) {
  2957.       (*ctx->Exec->Scalef)( x, y, z );
  2958.    }
  2959. }
  2960.  
  2961.  
  2962. static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
  2963. {
  2964.    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
  2965. }
  2966.  
  2967.  
  2968. static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
  2969. {
  2970.    GET_CURRENT_CONTEXT(ctx);
  2971.    Node *n;
  2972.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2973.    n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
  2974.    if (n) {
  2975.       n[1].i = x;
  2976.       n[2].i = y;
  2977.       n[3].i = width;
  2978.       n[4].i = height;
  2979.    }
  2980.    if (ctx->ExecuteFlag) {
  2981.       (*ctx->Exec->Scissor)( x, y, width, height );
  2982.    }
  2983. }
  2984.  
  2985.  
  2986. static void save_ShadeModel( GLenum mode )
  2987. {
  2988.    GET_CURRENT_CONTEXT(ctx);
  2989.    Node *n;
  2990.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  2991.    n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
  2992.    if (n) {
  2993.       n[1].e = mode;
  2994.    }
  2995.    if (ctx->ExecuteFlag) {
  2996.       (*ctx->Exec->ShadeModel)( mode );
  2997.    }
  2998. }
  2999.  
  3000.  
  3001. static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
  3002. {
  3003.    GET_CURRENT_CONTEXT(ctx);
  3004.    Node *n;
  3005.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3006.    n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
  3007.    if (n) {
  3008.       n[1].e = func;
  3009.       n[2].i = ref;
  3010.       n[3].ui = mask;
  3011.    }
  3012.    if (ctx->ExecuteFlag) {
  3013.       (*ctx->Exec->StencilFunc)( func, ref, mask );
  3014.    }
  3015. }
  3016.  
  3017.  
  3018. static void save_StencilMask( GLuint mask )
  3019. {
  3020.    GET_CURRENT_CONTEXT(ctx);
  3021.    Node *n;
  3022.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3023.    n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
  3024.    if (n) {
  3025.       n[1].ui = mask;
  3026.    }
  3027.    if (ctx->ExecuteFlag) {
  3028.       (*ctx->Exec->StencilMask)( mask );
  3029.    }
  3030. }
  3031.  
  3032.  
  3033. static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
  3034. {
  3035.    GET_CURRENT_CONTEXT(ctx);
  3036.    Node *n;
  3037.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3038.    n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
  3039.    if (n) {
  3040.       n[1].e = fail;
  3041.       n[2].e = zfail;
  3042.       n[3].e = zpass;
  3043.    }
  3044.    if (ctx->ExecuteFlag) {
  3045.       (*ctx->Exec->StencilOp)( fail, zfail, zpass );
  3046.    }
  3047. }
  3048.  
  3049.  
  3050. static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
  3051. {
  3052.    GET_CURRENT_CONTEXT(ctx);
  3053.    Node *n;
  3054.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3055.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
  3056.    if (n) {
  3057.       n[1].e = target;
  3058.       n[2].e = pname;
  3059.       n[3].f = params[0];
  3060.       n[4].f = params[1];
  3061.       n[5].f = params[2];
  3062.       n[6].f = params[3];
  3063.    }
  3064.    if (ctx->ExecuteFlag) {
  3065.       (*ctx->Exec->TexEnvfv)( target, pname, params );
  3066.    }
  3067. }
  3068.  
  3069.  
  3070. static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
  3071. {
  3072.    save_TexEnvfv( target, pname, ¶m );
  3073. }
  3074.  
  3075.  
  3076. static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
  3077. {
  3078.    GLfloat p[4];
  3079.    p[0] = (GLfloat) param;
  3080.    p[1] = p[2] = p[3] = 0.0;
  3081.    save_TexEnvfv( target, pname, p );
  3082. }
  3083.  
  3084.  
  3085. static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
  3086. {
  3087.    GLfloat p[4];
  3088.    p[0] = INT_TO_FLOAT( param[0] );
  3089.    p[1] = INT_TO_FLOAT( param[1] );
  3090.    p[2] = INT_TO_FLOAT( param[2] );
  3091.    p[3] = INT_TO_FLOAT( param[3] );
  3092.    save_TexEnvfv( target, pname, p );
  3093. }
  3094.  
  3095.  
  3096. static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
  3097. {
  3098.    GET_CURRENT_CONTEXT(ctx);
  3099.    Node *n;
  3100.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3101.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
  3102.    if (n) {
  3103.       n[1].e = coord;
  3104.       n[2].e = pname;
  3105.       n[3].f = params[0];
  3106.       n[4].f = params[1];
  3107.       n[5].f = params[2];
  3108.       n[6].f = params[3];
  3109.    }
  3110.    if (ctx->ExecuteFlag) {
  3111.       (*ctx->Exec->TexGenfv)( coord, pname, params );
  3112.    }
  3113. }
  3114.  
  3115.  
  3116. static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
  3117. {
  3118.    GLfloat p[4];
  3119.    p[0] = (GLfloat) params[0];
  3120.    p[1] = (GLfloat) params[1];
  3121.    p[2] = (GLfloat) params[2];
  3122.    p[3] = (GLfloat) params[3];
  3123.    save_TexGenfv(coord, pname, p);
  3124. }
  3125.  
  3126.  
  3127. static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
  3128. {
  3129.    GLfloat p = (GLfloat) param;
  3130.    save_TexGenfv( coord, pname, &p );
  3131. }
  3132.  
  3133.  
  3134. static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
  3135. {
  3136.    GLfloat p[4];
  3137.    p[0] = (GLfloat) params[0];
  3138.    p[1] = (GLfloat) params[1];
  3139.    p[2] = (GLfloat) params[2];
  3140.    p[3] = (GLfloat) params[3];
  3141.    save_TexGenfv( coord, pname, p );
  3142. }
  3143.  
  3144.  
  3145. static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
  3146. {
  3147.    save_TexGenfv(coord, pname, ¶m);
  3148. }
  3149.  
  3150.  
  3151. static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
  3152. {
  3153.    save_TexGeniv( coord, pname, ¶m );
  3154. }
  3155.  
  3156.  
  3157. static void save_TexParameterfv( GLenum target,
  3158.                              GLenum pname, const GLfloat *params )
  3159. {
  3160.    GET_CURRENT_CONTEXT(ctx);
  3161.    Node *n;
  3162.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3163.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
  3164.    if (n) {
  3165.       n[1].e = target;
  3166.       n[2].e = pname;
  3167.       n[3].f = params[0];
  3168.       n[4].f = params[1];
  3169.       n[5].f = params[2];
  3170.       n[6].f = params[3];
  3171.    }
  3172.    if (ctx->ExecuteFlag) {
  3173.       (*ctx->Exec->TexParameterfv)( target, pname, params );
  3174.    }
  3175. }
  3176.  
  3177.  
  3178. static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
  3179. {
  3180.    save_TexParameterfv(target, pname, ¶m);
  3181. }
  3182.  
  3183.  
  3184. static void save_TexParameteri( GLenum target, GLenum pname, GLint param )
  3185. {
  3186.    GLfloat fparam[4];
  3187.    fparam[0] = (GLfloat) param;
  3188.    fparam[1] = fparam[2] = fparam[3] = 0.0;
  3189.    save_TexParameterfv(target, pname, fparam);
  3190. }
  3191.  
  3192.  
  3193. static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
  3194. {
  3195.    GLfloat fparam[4];
  3196.    fparam[0] = (GLfloat) params[0];
  3197.    fparam[1] = fparam[2] = fparam[3] = 0.0;
  3198.    save_TexParameterfv(target, pname, fparam);
  3199. }
  3200.  
  3201.  
  3202. static void save_TexImage1D( GLenum target,
  3203.                              GLint level, GLint components,
  3204.                              GLsizei width, GLint border,
  3205.                              GLenum format, GLenum type,
  3206.                              const GLvoid *pixels )
  3207. {
  3208.    GET_CURRENT_CONTEXT(ctx);
  3209.    if (target == GL_PROXY_TEXTURE_1D) {
  3210.       /* don't compile, execute immediately */
  3211.       (*ctx->Exec->TexImage1D)( target, level, components, width,
  3212.                                border, format, type, pixels );
  3213.    }
  3214.    else {
  3215.       GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
  3216.                                          pixels, &ctx->Unpack);
  3217.       Node *n;
  3218.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3219.       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
  3220.       if (n) {
  3221.          n[1].e = target;
  3222.          n[2].i = level;
  3223.          n[3].i = components;
  3224.          n[4].i = (GLint) width;
  3225.          n[5].i = border;
  3226.          n[6].e = format;
  3227.          n[7].e = type;
  3228.          n[8].data = image;
  3229.       }
  3230.       else if (image) {
  3231.          FREE(image);
  3232.       }
  3233.       if (ctx->ExecuteFlag) {
  3234.          (*ctx->Exec->TexImage1D)( target, level, components, width,
  3235.                                   border, format, type, pixels );
  3236.       }
  3237.    }
  3238. }
  3239.  
  3240.  
  3241. static void save_TexImage2D( GLenum target,
  3242.                              GLint level, GLint components,
  3243.                              GLsizei width, GLsizei height, GLint border,
  3244.                              GLenum format, GLenum type,
  3245.                              const GLvoid *pixels)
  3246. {
  3247.    GET_CURRENT_CONTEXT(ctx);
  3248.    if (target == GL_PROXY_TEXTURE_2D) {
  3249.       /* don't compile, execute immediately */
  3250.       (*ctx->Exec->TexImage2D)( target, level, components, width,
  3251.                                height, border, format, type, pixels );
  3252.    }
  3253.    else {
  3254.       GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
  3255.                                          pixels, &ctx->Unpack);
  3256.       Node *n;
  3257.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3258.       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
  3259.       if (n) {
  3260.          n[1].e = target;
  3261.          n[2].i = level;
  3262.          n[3].i = components;
  3263.          n[4].i = (GLint) width;
  3264.          n[5].i = (GLint) height;
  3265.          n[6].i = border;
  3266.          n[7].e = format;
  3267.          n[8].e = type;
  3268.          n[9].data = image;
  3269.       }
  3270.       else if (image) {
  3271.          FREE(image);
  3272.       }
  3273.       if (ctx->ExecuteFlag) {
  3274.          (*ctx->Exec->TexImage2D)( target, level, components, width,
  3275.                                   height, border, format, type, pixels );
  3276.       }
  3277.    }
  3278. }
  3279.  
  3280.  
  3281. static void save_TexImage3D( GLenum target,
  3282.                              GLint level, GLint internalFormat,
  3283.                              GLsizei width, GLsizei height, GLsizei depth,
  3284.                              GLint border,
  3285.                              GLenum format, GLenum type,
  3286.                              const GLvoid *pixels )
  3287. {
  3288.    GET_CURRENT_CONTEXT(ctx);
  3289.    if (target == GL_PROXY_TEXTURE_3D) {
  3290.       /* don't compile, execute immediately */
  3291.       (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
  3292.                                height, depth, border, format, type, pixels );
  3293.    }
  3294.    else {
  3295.       Node *n;
  3296.       GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
  3297.                                          pixels, &ctx->Unpack);
  3298.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3299.       n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
  3300.       if (n) {
  3301.          n[1].e = target;
  3302.          n[2].i = level;
  3303.          n[3].i = (GLint) internalFormat;
  3304.          n[4].i = (GLint) width;
  3305.          n[5].i = (GLint) height;
  3306.          n[6].i = (GLint) depth;
  3307.          n[7].i = border;
  3308.          n[8].e = format;
  3309.          n[9].e = type;
  3310.          n[10].data = image;
  3311.       }
  3312.       else if (image) {
  3313.          FREE(image);
  3314.       }
  3315.       if (ctx->ExecuteFlag) {
  3316.          (*ctx->Exec->TexImage3D)( target, level, internalFormat, width,
  3317.                                 height, depth, border, format, type, pixels );
  3318.       }
  3319.    }
  3320. }
  3321.  
  3322.  
  3323. static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
  3324.                                 GLsizei width, GLenum format, GLenum type,
  3325.                                 const GLvoid *pixels )
  3326. {
  3327.    GET_CURRENT_CONTEXT(ctx);
  3328.    Node *n;
  3329.    GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
  3330.                                       pixels, &ctx->Unpack);
  3331.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3332.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
  3333.    if (n) {
  3334.       n[1].e = target;
  3335.       n[2].i = level;
  3336.       n[3].i = xoffset;
  3337.       n[4].i = (GLint) width;
  3338.       n[5].e = format;
  3339.       n[6].e = type;
  3340.       n[7].data = image;
  3341.    }
  3342.    else if (image) {
  3343.       FREE(image);
  3344.    }
  3345.    if (ctx->ExecuteFlag) {
  3346.       (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
  3347.                                   format, type, pixels );
  3348.    }
  3349. }
  3350.  
  3351.  
  3352. static void save_TexSubImage2D( GLenum target, GLint level,
  3353.                                 GLint xoffset, GLint yoffset,
  3354.                                 GLsizei width, GLsizei height,
  3355.                                 GLenum format, GLenum type,
  3356.                                 const GLvoid *pixels )
  3357. {
  3358.    GET_CURRENT_CONTEXT(ctx);
  3359.    Node *n;
  3360.    GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
  3361.                                       pixels, &ctx->Unpack);
  3362.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3363.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
  3364.    if (n) {
  3365.       n[1].e = target;
  3366.       n[2].i = level;
  3367.       n[3].i = xoffset;
  3368.       n[4].i = yoffset;
  3369.       n[5].i = (GLint) width;
  3370.       n[6].i = (GLint) height;
  3371.       n[7].e = format;
  3372.       n[8].e = type;
  3373.       n[9].data = image;
  3374.    }
  3375.    else if (image) {
  3376.       FREE(image);
  3377.    }
  3378.    if (ctx->ExecuteFlag) {
  3379.       (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
  3380.                            width, height, format, type, pixels );
  3381.    }
  3382. }
  3383.  
  3384.  
  3385. static void save_TexSubImage3D( GLenum target, GLint level,
  3386.                                 GLint xoffset, GLint yoffset,GLint zoffset,
  3387.                                 GLsizei width, GLsizei height, GLsizei depth,
  3388.                                 GLenum format, GLenum type,
  3389.                                 const GLvoid *pixels )
  3390. {
  3391.    GET_CURRENT_CONTEXT(ctx);
  3392.    Node *n;
  3393.    GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
  3394.                                       pixels, &ctx->Unpack);
  3395.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3396.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
  3397.    if (n) {
  3398.       n[1].e = target;
  3399.       n[2].i = level;
  3400.       n[3].i = xoffset;
  3401.       n[4].i = yoffset;
  3402.       n[5].i = zoffset;
  3403.       n[6].i = (GLint) width;
  3404.       n[7].i = (GLint) height;
  3405.       n[8].i = (GLint) depth;
  3406.       n[9].e = format;
  3407.       n[10].e = type;
  3408.       n[11].data = image;
  3409.    }
  3410.    else if (image) {
  3411.       FREE(image);
  3412.    }
  3413.    if (ctx->ExecuteFlag) {
  3414.       (*ctx->Exec->TexSubImage3D)( target, level,
  3415.                                   xoffset, yoffset, zoffset,
  3416.                                   width, height, depth, format, type, pixels );
  3417.    }
  3418. }
  3419.  
  3420.  
  3421. static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
  3422. {
  3423.    GET_CURRENT_CONTEXT(ctx);
  3424.    Node *n;
  3425.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3426.    n = ALLOC_INSTRUCTION( ctx,  OPCODE_TRANSLATE, 3 );
  3427.    if (n) {
  3428.       n[1].f = x;
  3429.       n[2].f = y;
  3430.       n[3].f = z;
  3431.    }
  3432.    if (ctx->ExecuteFlag) {
  3433.       (*ctx->Exec->Translatef)( x, y, z );
  3434.    }
  3435. }
  3436.  
  3437.  
  3438. static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
  3439. {
  3440.    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
  3441. }
  3442.  
  3443.  
  3444.  
  3445. static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
  3446. {
  3447.    GET_CURRENT_CONTEXT(ctx);
  3448.    Node *n;
  3449.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3450.    n = ALLOC_INSTRUCTION( ctx,  OPCODE_VIEWPORT, 4 );
  3451.    if (n) {
  3452.       n[1].i = x;
  3453.       n[2].i = y;
  3454.       n[3].i = (GLint) width;
  3455.       n[4].i = (GLint) height;
  3456.    }
  3457.    if (ctx->ExecuteFlag) {
  3458.       (*ctx->Exec->Viewport)( x, y, width, height );
  3459.    }
  3460. }
  3461.  
  3462.  
  3463. static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  3464. {
  3465.    GET_CURRENT_CONTEXT(ctx);
  3466.    Node *n;
  3467.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3468.    FLUSH_CURRENT(ctx, 0);
  3469.    n = ALLOC_INSTRUCTION( ctx,  OPCODE_WINDOW_POS, 4 );
  3470.    if (n) {
  3471.       n[1].f = x;
  3472.       n[2].f = y;
  3473.       n[3].f = z;
  3474.       n[4].f = w;
  3475.    }
  3476.    if (ctx->ExecuteFlag) {
  3477.       (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
  3478.    }
  3479. }
  3480.  
  3481. static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
  3482. {
  3483.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
  3484. }
  3485.  
  3486. static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
  3487. {
  3488.    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
  3489. }
  3490.  
  3491. static void save_WindowPos2iMESA(GLint x, GLint y)
  3492. {
  3493.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
  3494. }
  3495.  
  3496. static void save_WindowPos2sMESA(GLshort x, GLshort y)
  3497. {
  3498.    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
  3499. }
  3500.  
  3501. static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
  3502. {
  3503.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
  3504. }
  3505.  
  3506. static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
  3507. {
  3508.    save_WindowPos4fMESA(x, y, z, 1.0F);
  3509. }
  3510.  
  3511. static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
  3512. {
  3513.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
  3514. }
  3515.  
  3516. static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
  3517. {
  3518.    save_WindowPos4fMESA(x, y, z, 1.0F);
  3519. }
  3520.  
  3521. static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
  3522. {
  3523.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3524. }
  3525.  
  3526. static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
  3527. {
  3528.    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3529. }
  3530.  
  3531. static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
  3532. {
  3533.    save_WindowPos4fMESA(x, y, z, w);
  3534. }
  3535.  
  3536. static void save_WindowPos2dvMESA(const GLdouble *v)
  3537. {
  3538.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
  3539. }
  3540.  
  3541. static void save_WindowPos2fvMESA(const GLfloat *v)
  3542. {
  3543.    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
  3544. }
  3545.  
  3546. static void save_WindowPos2ivMESA(const GLint *v)
  3547. {
  3548.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
  3549. }
  3550.  
  3551. static void save_WindowPos2svMESA(const GLshort *v)
  3552. {
  3553.    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
  3554. }
  3555.  
  3556. static void save_WindowPos3dvMESA(const GLdouble *v)
  3557. {
  3558.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
  3559. }
  3560.  
  3561. static void save_WindowPos3fvMESA(const GLfloat *v)
  3562. {
  3563.    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
  3564. }
  3565.  
  3566. static void save_WindowPos3ivMESA(const GLint *v)
  3567. {
  3568.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
  3569. }
  3570.  
  3571. static void save_WindowPos3svMESA(const GLshort *v)
  3572. {
  3573.    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
  3574. }
  3575.  
  3576. static void save_WindowPos4dvMESA(const GLdouble *v)
  3577. {
  3578.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
  3579.             (GLfloat) v[2], (GLfloat) v[3]);
  3580. }
  3581.  
  3582. static void save_WindowPos4fvMESA(const GLfloat *v)
  3583. {
  3584.    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
  3585. }
  3586.  
  3587. static void save_WindowPos4ivMESA(const GLint *v)
  3588. {
  3589.    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
  3590.             (GLfloat) v[2], (GLfloat) v[3]);
  3591. }
  3592.  
  3593. static void save_WindowPos4svMESA(const GLshort *v)
  3594. {
  3595.    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
  3596. }
  3597.  
  3598.  
  3599.  
  3600. /* GL_ARB_multitexture */
  3601. static void save_ActiveTextureARB( GLenum target )
  3602. {
  3603.    GET_CURRENT_CONTEXT(ctx);
  3604.    Node *n;
  3605.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3606.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
  3607.    if (n) {
  3608.       n[1].e = target;
  3609.    }
  3610.    if (ctx->ExecuteFlag) {
  3611.       (*ctx->Exec->ActiveTextureARB)( target );
  3612.    }
  3613. }
  3614.  
  3615.  
  3616. /* GL_ARB_transpose_matrix */
  3617.  
  3618. static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
  3619. {
  3620.    GLfloat tm[16];
  3621.    _math_transposefd(tm, m);
  3622.    save_LoadMatrixf(tm);
  3623. }
  3624.  
  3625.  
  3626. static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
  3627. {
  3628.    GLfloat tm[16];
  3629.    _math_transposef(tm, m);
  3630.    save_LoadMatrixf(tm);
  3631. }
  3632.  
  3633.  
  3634. static void
  3635. save_MultTransposeMatrixdARB( const GLdouble m[16] )
  3636. {
  3637.    GLfloat tm[16];
  3638.    _math_transposefd(tm, m);
  3639.    save_MultMatrixf(tm);
  3640. }
  3641.  
  3642.  
  3643. static void
  3644. save_MultTransposeMatrixfARB( const GLfloat m[16] )
  3645. {
  3646.    GLfloat tm[16];
  3647.    _math_transposef(tm, m);
  3648.    save_MultMatrixf(tm);
  3649. }
  3650.  
  3651.  
  3652. static void
  3653. save_PixelTexGenSGIX(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_PIXEL_TEXGEN_SGIX, 1 );
  3659.    if (n) {
  3660.       n[1].e = mode;
  3661.    }
  3662.    if (ctx->ExecuteFlag) {
  3663.       (*ctx->Exec->PixelTexGenSGIX)( mode );
  3664.    }
  3665. }
  3666.  
  3667.  
  3668. /* GL_ARB_texture_compression */
  3669. static void
  3670. save_CompressedTexImage1DARB(GLenum target, GLint level,
  3671.                              GLenum internalFormat, GLsizei width,
  3672.                              GLint border, GLsizei imageSize,
  3673.                              const GLvoid *data)
  3674. {
  3675.    GET_CURRENT_CONTEXT(ctx);
  3676.    if (target == GL_PROXY_TEXTURE_1D) {
  3677.       /* don't compile, execute immediately */
  3678.       (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
  3679.                                             width, border, imageSize, data);
  3680.    }
  3681.    else {
  3682.       Node *n;
  3683.       GLvoid *image;
  3684.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3685.       /* make copy of image */
  3686.       image = MALLOC(imageSize);
  3687.       if (!image) {
  3688.          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
  3689.          return;
  3690.       }
  3691.       MEMCPY(image, data, imageSize);
  3692.       n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
  3693.       if (n) {
  3694.          n[1].e = target;
  3695.          n[2].i = level;
  3696.          n[3].e = internalFormat;
  3697.          n[4].i = (GLint) width;
  3698.          n[5].i = border;
  3699.          n[6].i = imageSize;
  3700.          n[7].data = image;
  3701.       }
  3702.       else if (image) {
  3703.          FREE(image);
  3704.       }
  3705.       if (ctx->ExecuteFlag) {
  3706.          (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat,
  3707.                                                width, border, imageSize, data);
  3708.       }
  3709.    }
  3710. }
  3711.  
  3712.  
  3713. static void
  3714. save_CompressedTexImage2DARB(GLenum target, GLint level,
  3715.                              GLenum internalFormat, GLsizei width,
  3716.                              GLsizei height, GLint border, GLsizei imageSize,
  3717.                              const GLvoid *data)
  3718. {
  3719.    GET_CURRENT_CONTEXT(ctx);
  3720.    if (target == GL_PROXY_TEXTURE_2D) {
  3721.       /* don't compile, execute immediately */
  3722.       (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
  3723.                                        width, height, border, imageSize, data);
  3724.    }
  3725.    else {
  3726.       Node *n;
  3727.       GLvoid *image;
  3728.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3729.       /* make copy of image */
  3730.       image = MALLOC(imageSize);
  3731.       if (!image) {
  3732.          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
  3733.          return;
  3734.       }
  3735.       MEMCPY(image, data, imageSize);
  3736.       n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
  3737.       if (n) {
  3738.          n[1].e = target;
  3739.          n[2].i = level;
  3740.          n[3].e = internalFormat;
  3741.          n[4].i = (GLint) width;
  3742.          n[5].i = (GLint) height;
  3743.          n[6].i = border;
  3744.          n[7].i = imageSize;
  3745.          n[8].data = image;
  3746.       }
  3747.       else if (image) {
  3748.          FREE(image);
  3749.       }
  3750.       if (ctx->ExecuteFlag) {
  3751.          (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat,
  3752.                                       width, height, border, imageSize, data);
  3753.       }
  3754.    }
  3755. }
  3756.  
  3757.  
  3758. static void
  3759. save_CompressedTexImage3DARB(GLenum target, GLint level,
  3760.                              GLenum internalFormat, GLsizei width,
  3761.                              GLsizei height, GLsizei depth, GLint border,
  3762.                              GLsizei imageSize, const GLvoid *data)
  3763. {
  3764.    GET_CURRENT_CONTEXT(ctx);
  3765.    if (target == GL_PROXY_TEXTURE_3D) {
  3766.       /* don't compile, execute immediately */
  3767.       (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
  3768.                                 width, height, depth, border, imageSize, data);
  3769.    }
  3770.    else {
  3771.       Node *n;
  3772.       GLvoid *image;
  3773.       ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3774.       /* make copy of image */
  3775.       image = MALLOC(imageSize);
  3776.       if (!image) {
  3777.          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
  3778.          return;
  3779.       }
  3780.       MEMCPY(image, data, imageSize);
  3781.       n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9 );
  3782.       if (n) {
  3783.          n[1].e = target;
  3784.          n[2].i = level;
  3785.          n[3].e = internalFormat;
  3786.          n[4].i = (GLint) width;
  3787.          n[5].i = (GLint) height;
  3788.          n[6].i = (GLint) depth;
  3789.          n[7].i = border;
  3790.          n[8].i = imageSize;
  3791.          n[9].data = image;
  3792.       }
  3793.       else if (image) {
  3794.          FREE(image);
  3795.       }
  3796.       if (ctx->ExecuteFlag) {
  3797.          (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat,
  3798.                                 width, height, depth, border, imageSize, data);
  3799.       }
  3800.    }
  3801. }
  3802.  
  3803.  
  3804. static void
  3805. save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
  3806.                                 GLsizei width, GLenum format,
  3807.                                 GLsizei imageSize, const GLvoid *data)
  3808. {
  3809.    Node *n;
  3810.    GLvoid *image;
  3811.  
  3812.    GET_CURRENT_CONTEXT(ctx);
  3813.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3814.  
  3815.    /* make copy of image */
  3816.    image = MALLOC(imageSize);
  3817.    if (!image) {
  3818.       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
  3819.       return;
  3820.    }
  3821.    MEMCPY(image, data, imageSize);
  3822.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
  3823.    if (n) {
  3824.       n[1].e = target;
  3825.       n[2].i = level;
  3826.       n[3].i = xoffset;
  3827.       n[4].i = (GLint) width;
  3828.       n[5].e = format;
  3829.       n[6].i = imageSize;
  3830.       n[7].data = image;
  3831.    }
  3832.    else if (image) {
  3833.       FREE(image);
  3834.    }
  3835.    if (ctx->ExecuteFlag) {
  3836.       (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
  3837.                                             width, format, imageSize, data);
  3838.    }
  3839. }
  3840.  
  3841.  
  3842. static void
  3843. save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
  3844.                                 GLint yoffset, GLsizei width, GLsizei height,
  3845.                                 GLenum format, GLsizei imageSize,
  3846.                                 const GLvoid *data)
  3847. {
  3848.    Node *n;
  3849.    GLvoid *image;
  3850.  
  3851.    GET_CURRENT_CONTEXT(ctx);
  3852.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3853.  
  3854.    /* make copy of image */
  3855.    image = MALLOC(imageSize);
  3856.    if (!image) {
  3857.       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
  3858.       return;
  3859.    }
  3860.    MEMCPY(image, data, imageSize);
  3861.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
  3862.    if (n) {
  3863.       n[1].e = target;
  3864.       n[2].i = level;
  3865.       n[3].i = xoffset;
  3866.       n[4].i = yoffset;
  3867.       n[5].i = (GLint) width;
  3868.       n[6].i = (GLint) height;
  3869.       n[7].e = format;
  3870.       n[8].i = imageSize;
  3871.       n[9].data = image;
  3872.    }
  3873.    else if (image) {
  3874.       FREE(image);
  3875.    }
  3876.    if (ctx->ExecuteFlag) {
  3877.       (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset,
  3878.                                        width, height, format, imageSize, data);
  3879.    }
  3880. }
  3881.  
  3882.  
  3883. static void
  3884. save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
  3885.                                 GLint yoffset, GLint zoffset, GLsizei width,
  3886.                                 GLsizei height, GLsizei depth, GLenum format,
  3887.                                 GLsizei imageSize, const GLvoid *data)
  3888. {
  3889.    Node *n;
  3890.    GLvoid *image;
  3891.  
  3892.    GET_CURRENT_CONTEXT(ctx);
  3893.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3894.  
  3895.    /* make copy of image */
  3896.    image = MALLOC(imageSize);
  3897.    if (!image) {
  3898.       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
  3899.       return;
  3900.    }
  3901.    MEMCPY(image, data, imageSize);
  3902.    n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
  3903.    if (n) {
  3904.       n[1].e = target;
  3905.       n[2].i = level;
  3906.       n[3].i = xoffset;
  3907.       n[4].i = yoffset;
  3908.       n[5].i = zoffset;
  3909.       n[6].i = (GLint) width;
  3910.       n[7].i = (GLint) height;
  3911.       n[8].i = (GLint) depth;
  3912.       n[9].e = format;
  3913.       n[10].i = imageSize;
  3914.       n[11].data = image;
  3915.    }
  3916.    else if (image) {
  3917.       FREE(image);
  3918.    }
  3919.    if (ctx->ExecuteFlag) {
  3920.       (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset,
  3921.                        zoffset, width, height, depth, format, imageSize, data);
  3922.    }
  3923. }
  3924.  
  3925.  
  3926. /* GL_ARB_multisample */
  3927. static void
  3928. save_SampleCoverageARB(GLclampf value, GLboolean invert)
  3929. {
  3930.    GET_CURRENT_CONTEXT(ctx);
  3931.    Node *n;
  3932.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3933.    n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
  3934.    if (n) {
  3935.       n[1].f = value;
  3936.       n[2].b = invert;
  3937.    }
  3938.    if (ctx->ExecuteFlag) {
  3939.       (*ctx->Exec->SampleCoverageARB)( value, invert );
  3940.    }
  3941. }
  3942.  
  3943.  
  3944. /* GL_SGIS_pixel_texture */
  3945.  
  3946. static void
  3947. save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
  3948. {
  3949.    GET_CURRENT_CONTEXT(ctx);
  3950.    Node *n;
  3951.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3952.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
  3953.    if (n) {
  3954.       n[1].e = target;
  3955.       n[2].i = value;
  3956.    }
  3957.    if (ctx->ExecuteFlag) {
  3958.       (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value );
  3959.    }
  3960. }
  3961.  
  3962.  
  3963. static void
  3964. save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
  3965. {
  3966.    save_PixelTexGenParameteriSGIS(target, (GLint) value);
  3967. }
  3968.  
  3969.  
  3970. static void
  3971. save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
  3972. {
  3973.    save_PixelTexGenParameteriSGIS(target, *value);
  3974. }
  3975.  
  3976.  
  3977. static void
  3978. save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
  3979. {
  3980.    save_PixelTexGenParameteriSGIS(target, (GLint) *value);
  3981. }
  3982.  
  3983.  
  3984. /*
  3985.  * GL_NV_vertex_program
  3986.  */
  3987. #if FEATURE_NV_vertex_program
  3988. static void
  3989. save_BindProgramNV(GLenum target, GLuint id)
  3990. {
  3991.    GET_CURRENT_CONTEXT(ctx);
  3992.    Node *n;
  3993.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  3994.    n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
  3995.    if (n) {
  3996.       n[1].e = target;
  3997.       n[2].ui = id;
  3998.    }
  3999.    if (ctx->ExecuteFlag) {
  4000.       (*ctx->Exec->BindProgramNV)( target, id );
  4001.    }
  4002. }
  4003.  
  4004. static void
  4005. save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
  4006. {
  4007.    GET_CURRENT_CONTEXT(ctx);
  4008.    Node *n;
  4009.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  4010.    n = ALLOC_INSTRUCTION( ctx, OPCODE_EXECUTE_PROGRAM_NV, 6 );
  4011.    if (n) {
  4012.       n[1].e = target;
  4013.       n[2].ui = id;
  4014.       n[3].f = params[0];
  4015.       n[4].f = params[1];
  4016.       n[5].f = params[2];
  4017.       n[6].f = params[3];
  4018.    }
  4019.    if (ctx->ExecuteFlag) {
  4020.       (*ctx->Exec->ExecuteProgramNV)(target, id, params);
  4021.    }
  4022. }
  4023.  
  4024.  
  4025. static void
  4026. save_ProgramParameter4fNV(GLenum target, GLuint index,
  4027.                           GLfloat x, GLfloat y,
  4028.                           GLfloat z, GLfloat w)
  4029. {
  4030.    GET_CURRENT_CONTEXT(ctx);
  4031.    Node *n;
  4032.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  4033.    n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6 );
  4034.    if (n) {
  4035.       n[1].e = target;
  4036.       n[2].ui = index;
  4037.       n[3].f = x;
  4038.       n[4].f = y;
  4039.       n[5].f = z;
  4040.       n[6].f = w;
  4041.    }
  4042.    if (ctx->ExecuteFlag) {
  4043.       (*ctx->Exec->ProgramParameter4fNV)(target, index, x, y, z, w);
  4044.    }
  4045. }
  4046.  
  4047.  
  4048. static void
  4049. save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
  4050. {
  4051.    save_ProgramParameter4fNV(target, index, params[0], params[1],
  4052.                              params[2], params[3]);
  4053. }
  4054.  
  4055.  
  4056. static void
  4057. save_ProgramParameter4dNV(GLenum target, GLuint index,
  4058.                           GLdouble x, GLdouble y,
  4059.                           GLdouble z, GLdouble w)
  4060. {
  4061.    save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
  4062.                              (GLfloat) z, (GLfloat) w);
  4063. }
  4064.  
  4065.  
  4066. static void
  4067. save_ProgramParameter4dvNV(GLenum target, GLuint index,
  4068.                            const GLdouble *params)
  4069. {
  4070.    save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
  4071.                              (GLfloat) params[1], (GLfloat) params[2],
  4072.                              (GLfloat) params[3]);
  4073. }
  4074.  
  4075.  
  4076. static void
  4077. save_ProgramParameters4dvNV(GLenum target, GLuint index,
  4078.                             GLuint num, const GLdouble *params)
  4079. {
  4080.    GLuint i;
  4081.    for (i = 0; i < num; i++) {
  4082.       save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
  4083.    }
  4084. }
  4085.  
  4086.  
  4087. static void
  4088. save_ProgramParameters4fvNV(GLenum target, GLuint index,
  4089.                             GLuint num, const GLfloat *params)
  4090. {
  4091.    GLuint i;
  4092.    for (i = 0; i < num; i++) {
  4093.       save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
  4094.    }
  4095. }
  4096.  
  4097.  
  4098.  
  4099. static void
  4100. save_TrackMatrixNV(GLenum target, GLuint address,
  4101.                    GLenum matrix, GLenum transform)
  4102. {
  4103.    GET_CURRENT_CONTEXT(ctx);
  4104.    Node *n;
  4105.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  4106.    n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 4 );
  4107.    if (n) {
  4108.       n[1].e = target;
  4109.       n[2].ui = address;
  4110.       n[3].e = matrix;
  4111.       n[4].e = transform;
  4112.    }
  4113.    if (ctx->ExecuteFlag) {
  4114.       (*ctx->Exec->TrackMatrixNV)(target, address, matrix, transform);
  4115.    }
  4116. }
  4117. #endif /* FEATURE_NV_vertex_program */
  4118.  
  4119.  
  4120. /* GL_EXT_stencil_two_side */
  4121. static void save_ActiveStencilFaceEXT( GLenum face )
  4122. {
  4123.    GET_CURRENT_CONTEXT(ctx);
  4124.    Node *n;
  4125.    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
  4126.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1 );
  4127.    if (n) {
  4128.       n[1].e = face;
  4129.    }
  4130.    if (ctx->ExecuteFlag) {
  4131.       (*ctx->Exec->ActiveStencilFaceEXT)( face );
  4132.    }
  4133. }
  4134.  
  4135.  
  4136.  
  4137. /* KW: Compile commands
  4138.  *
  4139.  * Will appear in the list before the vertex buffer containing the
  4140.  * command that provoked the error.  I don't see this as a problem.
  4141.  */
  4142. void
  4143. _mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
  4144. {
  4145.    Node *n;
  4146.    n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
  4147.    if (n) {
  4148.       n[1].e = error;
  4149.       n[2].data = (void *) s;
  4150.    }
  4151.    /* execute already done */
  4152. }
  4153.  
  4154.  
  4155. /*
  4156.  * Compile an error into current display list.
  4157.  */
  4158. void
  4159. _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
  4160. {
  4161.    if (ctx->CompileFlag)
  4162.       _mesa_save_error( ctx, error, s );
  4163.  
  4164.    if (ctx->ExecuteFlag)
  4165.       _mesa_error( ctx, error, s );
  4166. }
  4167.  
  4168.  
  4169.  
  4170. static GLboolean
  4171. islist(GLcontext *ctx, GLuint list)
  4172. {
  4173.    if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
  4174.       return GL_TRUE;
  4175.    }
  4176.    else {
  4177.       return GL_FALSE;
  4178.    }
  4179. }
  4180.  
  4181.  
  4182.  
  4183. /**********************************************************************/
  4184. /*                     Display list execution                         */
  4185. /**********************************************************************/
  4186.  
  4187.  
  4188. /*
  4189.  * Execute a display list.  Note that the ListBase offset must have already
  4190.  * been added before calling this function.  I.e. the list argument is
  4191.  * the absolute list number, not relative to ListBase.
  4192.  * Input:  list - display list number
  4193.  */
  4194. static void
  4195. execute_list( GLcontext *ctx, GLuint list )
  4196. {
  4197.    Node *n;
  4198.    GLboolean done;
  4199.  
  4200.    if (!islist(ctx,list))
  4201.       return;
  4202.  
  4203.    if (ctx->Driver.BeginCallList)
  4204.       ctx->Driver.BeginCallList( ctx, list );
  4205.  
  4206.    ctx->CallDepth++;
  4207.  
  4208.    n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
  4209.  
  4210.    done = GL_FALSE;
  4211.    while (!done) {
  4212.       OpCode opcode = n[0].opcode;
  4213.       int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
  4214.  
  4215.       if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
  4216.      ctx->listext.opcode[i].execute(ctx, &n[1]);
  4217.      n += ctx->listext.opcode[i].size;
  4218.       }
  4219.       else {
  4220.      switch (opcode) {
  4221.      case OPCODE_ERROR:
  4222.         _mesa_error( ctx, n[1].e, (const char *) n[2].data );
  4223.         break;
  4224.          case OPCODE_ACCUM:
  4225.         (*ctx->Exec->Accum)( n[1].e, n[2].f );
  4226.         break;
  4227.          case OPCODE_ALPHA_FUNC:
  4228.         (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
  4229.         break;
  4230.          case OPCODE_BIND_TEXTURE:
  4231.             (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
  4232.             break;
  4233.      case OPCODE_BITMAP:
  4234.             {
  4235.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4236.                ctx->Unpack = _mesa_native_packing;
  4237.                (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
  4238.                  n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
  4239.                ctx->Unpack = save;  /* restore */
  4240.             }
  4241.         break;
  4242.      case OPCODE_BLEND_COLOR:
  4243.         (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
  4244.         break;
  4245.      case OPCODE_BLEND_EQUATION:
  4246.         (*ctx->Exec->BlendEquation)( n[1].e );
  4247.         break;
  4248.      case OPCODE_BLEND_FUNC:
  4249.         (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
  4250.         break;
  4251.      case OPCODE_BLEND_FUNC_SEPARATE:
  4252.         (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
  4253.         break;
  4254.          case OPCODE_CALL_LIST:
  4255.         /* Generated by glCallList(), don't add ListBase */
  4256.             if (ctx->CallDepth<MAX_LIST_NESTING) {
  4257.                execute_list( ctx, n[1].ui );
  4258.             }
  4259.             break;
  4260.          case OPCODE_CALL_LIST_OFFSET:
  4261.         /* Generated by glCallLists() so we must add ListBase */
  4262.             if (n[2].b) {
  4263.                /* user specified a bad datatype at compile time */
  4264.                _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
  4265.             }
  4266.             else if (ctx->CallDepth < MAX_LIST_NESTING) {
  4267.                execute_list( ctx, ctx->List.ListBase + n[1].ui );
  4268.             }
  4269.             break;
  4270.      case OPCODE_CLEAR:
  4271.         (*ctx->Exec->Clear)( n[1].bf );
  4272.         break;
  4273.      case OPCODE_CLEAR_COLOR:
  4274.         (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
  4275.         break;
  4276.      case OPCODE_CLEAR_ACCUM:
  4277.         (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
  4278.         break;
  4279.      case OPCODE_CLEAR_DEPTH:
  4280.         (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
  4281.         break;
  4282.      case OPCODE_CLEAR_INDEX:
  4283.         (*ctx->Exec->ClearIndex)( (GLfloat) n[1].ui );
  4284.         break;
  4285.      case OPCODE_CLEAR_STENCIL:
  4286.         (*ctx->Exec->ClearStencil)( n[1].i );
  4287.         break;
  4288.          case OPCODE_CLIP_PLANE:
  4289.             {
  4290.                GLdouble eq[4];
  4291.                eq[0] = n[2].f;
  4292.                eq[1] = n[3].f;
  4293.                eq[2] = n[4].f;
  4294.                eq[3] = n[5].f;
  4295.                (*ctx->Exec->ClipPlane)( n[1].e, eq );
  4296.             }
  4297.             break;
  4298.      case OPCODE_COLOR_MASK:
  4299.         (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
  4300.         break;
  4301.      case OPCODE_COLOR_MATERIAL:
  4302.         (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
  4303.         break;
  4304.          case OPCODE_COLOR_TABLE:
  4305.             {
  4306.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4307.                ctx->Unpack = _mesa_native_packing;
  4308.                (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
  4309.                                          n[5].e, n[6].data );
  4310.                ctx->Unpack = save;  /* restore */
  4311.             }
  4312.             break;
  4313.          case OPCODE_COLOR_TABLE_PARAMETER_FV:
  4314.             {
  4315.                GLfloat params[4];
  4316.                params[0] = n[3].f;
  4317.                params[1] = n[4].f;
  4318.                params[2] = n[5].f;
  4319.                params[3] = n[6].f;
  4320.                (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params );
  4321.             }
  4322.             break;
  4323.          case OPCODE_COLOR_TABLE_PARAMETER_IV:
  4324.             {
  4325.                GLint params[4];
  4326.                params[0] = n[3].i;
  4327.                params[1] = n[4].i;
  4328.                params[2] = n[5].i;
  4329.                params[3] = n[6].i;
  4330.                (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params );
  4331.             }
  4332.             break;
  4333.          case OPCODE_COLOR_SUB_TABLE:
  4334.             {
  4335.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4336.                ctx->Unpack = _mesa_native_packing;
  4337.                (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
  4338.                                             n[4].e, n[5].e, n[6].data );
  4339.                ctx->Unpack = save;  /* restore */
  4340.             }
  4341.             break;
  4342.          case OPCODE_CONVOLUTION_FILTER_1D:
  4343.             {
  4344.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4345.                ctx->Unpack = _mesa_native_packing;
  4346.                (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i,
  4347.                                                   n[4].e, n[5].e, n[6].data );
  4348.                ctx->Unpack = save;  /* restore */
  4349.             }
  4350.             break;
  4351.          case OPCODE_CONVOLUTION_FILTER_2D:
  4352.             {
  4353.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4354.                ctx->Unpack = _mesa_native_packing;
  4355.                (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i,
  4356.                                        n[4].i, n[5].e, n[6].e, n[7].data );
  4357.                ctx->Unpack = save;  /* restore */
  4358.             }
  4359.             break;
  4360.          case OPCODE_CONVOLUTION_PARAMETER_I:
  4361.             (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i );
  4362.             break;
  4363.          case OPCODE_CONVOLUTION_PARAMETER_IV:
  4364.             {
  4365.                GLint params[4];
  4366.                params[0] = n[3].i;
  4367.                params[1] = n[4].i;
  4368.                params[2] = n[5].i;
  4369.                params[3] = n[6].i;
  4370.                (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params );
  4371.             }
  4372.             break;
  4373.          case OPCODE_CONVOLUTION_PARAMETER_F:
  4374.             (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f );
  4375.             break;
  4376.          case OPCODE_CONVOLUTION_PARAMETER_FV:
  4377.             {
  4378.                GLfloat params[4];
  4379.                params[0] = n[3].f;
  4380.                params[1] = n[4].f;
  4381.                params[2] = n[5].f;
  4382.                params[3] = n[6].f;
  4383.                (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params );
  4384.             }
  4385.             break;
  4386.          case OPCODE_COPY_COLOR_SUB_TABLE:
  4387.             (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
  4388.                                              n[3].i, n[4].i, n[5].i );
  4389.             break;
  4390.          case OPCODE_COPY_COLOR_TABLE:
  4391.             (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i,
  4392.                                              n[3].i, n[4].i, n[5].i );
  4393.             break;
  4394.      case OPCODE_COPY_PIXELS:
  4395.         (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
  4396.                (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
  4397.         break;
  4398.          case OPCODE_COPY_TEX_IMAGE1D:
  4399.         (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
  4400.                                          n[5].i, n[6].i, n[7].i );
  4401.             break;
  4402.          case OPCODE_COPY_TEX_IMAGE2D:
  4403.         (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
  4404.                                          n[5].i, n[6].i, n[7].i, n[8].i );
  4405.             break;
  4406.          case OPCODE_COPY_TEX_SUB_IMAGE1D:
  4407.         (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
  4408.                                             n[4].i, n[5].i, n[6].i );
  4409.             break;
  4410.          case OPCODE_COPY_TEX_SUB_IMAGE2D:
  4411.         (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
  4412.                                      n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
  4413.             break;
  4414.          case OPCODE_COPY_TEX_SUB_IMAGE3D:
  4415.             (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
  4416.                             n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
  4417.             break;
  4418.      case OPCODE_CULL_FACE:
  4419.         (*ctx->Exec->CullFace)( n[1].e );
  4420.         break;
  4421.      case OPCODE_DEPTH_FUNC:
  4422.         (*ctx->Exec->DepthFunc)( n[1].e );
  4423.         break;
  4424.      case OPCODE_DEPTH_MASK:
  4425.         (*ctx->Exec->DepthMask)( n[1].b );
  4426.         break;
  4427.      case OPCODE_DEPTH_RANGE:
  4428.         (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
  4429.         break;
  4430.      case OPCODE_DISABLE:
  4431.         (*ctx->Exec->Disable)( n[1].e );
  4432.         break;
  4433.      case OPCODE_DRAW_BUFFER:
  4434.         (*ctx->Exec->DrawBuffer)( n[1].e );
  4435.         break;
  4436.      case OPCODE_DRAW_PIXELS:
  4437.             {
  4438.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4439.                ctx->Unpack = _mesa_native_packing;
  4440.                (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
  4441.                                         n[5].data );
  4442.                ctx->Unpack = save;  /* restore */
  4443.             }
  4444.         break;
  4445.      case OPCODE_ENABLE:
  4446.         (*ctx->Exec->Enable)( n[1].e );
  4447.         break;
  4448.      case OPCODE_EVALMESH1:
  4449.         (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
  4450.         break;
  4451.      case OPCODE_EVALMESH2:
  4452.         (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
  4453.         break;
  4454.      case OPCODE_FOG:
  4455.         {
  4456.            GLfloat p[4];
  4457.            p[0] = n[2].f;
  4458.            p[1] = n[3].f;
  4459.            p[2] = n[4].f;
  4460.            p[3] = n[5].f;
  4461.            (*ctx->Exec->Fogfv)( n[1].e, p );
  4462.         }
  4463.         break;
  4464.      case OPCODE_FRONT_FACE:
  4465.         (*ctx->Exec->FrontFace)( n[1].e );
  4466.         break;
  4467.          case OPCODE_FRUSTUM:
  4468.             (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  4469.             break;
  4470.      case OPCODE_HINT:
  4471.         (*ctx->Exec->Hint)( n[1].e, n[2].e );
  4472.         break;
  4473.      case OPCODE_HISTOGRAM:
  4474.         (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
  4475.         break;
  4476.      case OPCODE_INDEX_MASK:
  4477.         (*ctx->Exec->IndexMask)( n[1].ui );
  4478.         break;
  4479.      case OPCODE_INIT_NAMES:
  4480.         (*ctx->Exec->InitNames)();
  4481.         break;
  4482.          case OPCODE_LIGHT:
  4483.         {
  4484.            GLfloat p[4];
  4485.            p[0] = n[3].f;
  4486.            p[1] = n[4].f;
  4487.            p[2] = n[5].f;
  4488.            p[3] = n[6].f;
  4489.            (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
  4490.         }
  4491.         break;
  4492.          case OPCODE_LIGHT_MODEL:
  4493.         {
  4494.            GLfloat p[4];
  4495.            p[0] = n[2].f;
  4496.            p[1] = n[3].f;
  4497.            p[2] = n[4].f;
  4498.            p[3] = n[5].f;
  4499.            (*ctx->Exec->LightModelfv)( n[1].e, p );
  4500.         }
  4501.         break;
  4502.      case OPCODE_LINE_STIPPLE:
  4503.         (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
  4504.         break;
  4505.      case OPCODE_LINE_WIDTH:
  4506.         (*ctx->Exec->LineWidth)( n[1].f );
  4507.         break;
  4508.      case OPCODE_LIST_BASE:
  4509.         (*ctx->Exec->ListBase)( n[1].ui );
  4510.         break;
  4511.      case OPCODE_LOAD_IDENTITY:
  4512.             (*ctx->Exec->LoadIdentity)();
  4513.             break;
  4514.      case OPCODE_LOAD_MATRIX:
  4515.         if (sizeof(Node)==sizeof(GLfloat)) {
  4516.            (*ctx->Exec->LoadMatrixf)( &n[1].f );
  4517.         }
  4518.         else {
  4519.            GLfloat m[16];
  4520.            GLuint i;
  4521.            for (i=0;i<16;i++) {
  4522.           m[i] = n[1+i].f;
  4523.            }
  4524.            (*ctx->Exec->LoadMatrixf)( m );
  4525.         }
  4526.         break;
  4527.      case OPCODE_LOAD_NAME:
  4528.         (*ctx->Exec->LoadName)( n[1].ui );
  4529.         break;
  4530.      case OPCODE_LOGIC_OP:
  4531.         (*ctx->Exec->LogicOp)( n[1].e );
  4532.         break;
  4533.      case OPCODE_MAP1:
  4534.             {
  4535.                GLenum target = n[1].e;
  4536.                GLint ustride = _mesa_evaluator_components(target);
  4537.                GLint uorder = n[5].i;
  4538.                GLfloat u1 = n[2].f;
  4539.                GLfloat u2 = n[3].f;
  4540.                (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
  4541.                                    (GLfloat *) n[6].data );
  4542.             }
  4543.         break;
  4544.      case OPCODE_MAP2:
  4545.             {
  4546.                GLenum target = n[1].e;
  4547.                GLfloat u1 = n[2].f;
  4548.                GLfloat u2 = n[3].f;
  4549.                GLfloat v1 = n[4].f;
  4550.                GLfloat v2 = n[5].f;
  4551.                GLint ustride = n[6].i;
  4552.                GLint vstride = n[7].i;
  4553.                GLint uorder = n[8].i;
  4554.                GLint vorder = n[9].i;
  4555.                (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
  4556.                                    v1, v2, vstride, vorder,
  4557.                                    (GLfloat *) n[10].data );
  4558.             }
  4559.         break;
  4560.      case OPCODE_MAPGRID1:
  4561.         (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
  4562.         break;
  4563.      case OPCODE_MAPGRID2:
  4564.         (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
  4565.         break;
  4566.          case OPCODE_MATRIX_MODE:
  4567.             (*ctx->Exec->MatrixMode)( n[1].e );
  4568.             break;
  4569.          case OPCODE_MIN_MAX:
  4570.             (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b);
  4571.             break;
  4572.      case OPCODE_MULT_MATRIX:
  4573.         if (sizeof(Node)==sizeof(GLfloat)) {
  4574.            (*ctx->Exec->MultMatrixf)( &n[1].f );
  4575.         }
  4576.         else {
  4577.            GLfloat m[16];
  4578.            GLuint i;
  4579.            for (i=0;i<16;i++) {
  4580.           m[i] = n[1+i].f;
  4581.            }
  4582.            (*ctx->Exec->MultMatrixf)( m );
  4583.         }
  4584.         break;
  4585.          case OPCODE_ORTHO:
  4586.             (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  4587.             break;
  4588.      case OPCODE_PASSTHROUGH:
  4589.         (*ctx->Exec->PassThrough)( n[1].f );
  4590.         break;
  4591.      case OPCODE_PIXEL_MAP:
  4592.         (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
  4593.         break;
  4594.      case OPCODE_PIXEL_TRANSFER:
  4595.         (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
  4596.         break;
  4597.      case OPCODE_PIXEL_ZOOM:
  4598.         (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
  4599.         break;
  4600.      case OPCODE_POINT_SIZE:
  4601.         (*ctx->Exec->PointSize)( n[1].f );
  4602.         break;
  4603.      case OPCODE_POINT_PARAMETERS:
  4604.         {
  4605.         GLfloat params[3];
  4606.         params[0] = n[2].f;
  4607.         params[1] = n[3].f;
  4608.         params[2] = n[4].f;
  4609.         (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
  4610.         }
  4611.         break;
  4612.      case OPCODE_POLYGON_MODE:
  4613.         (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
  4614.         break;
  4615.      case OPCODE_POLYGON_STIPPLE:
  4616.         (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
  4617.         break;
  4618.      case OPCODE_POLYGON_OFFSET:
  4619.         (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
  4620.         break;
  4621.      case OPCODE_POP_ATTRIB:
  4622.         (*ctx->Exec->PopAttrib)();
  4623.         break;
  4624.      case OPCODE_POP_MATRIX:
  4625.         (*ctx->Exec->PopMatrix)();
  4626.         break;
  4627.      case OPCODE_POP_NAME:
  4628.         (*ctx->Exec->PopName)();
  4629.         break;
  4630.      case OPCODE_PRIORITIZE_TEXTURE:
  4631.             (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
  4632.         break;
  4633.      case OPCODE_PUSH_ATTRIB:
  4634.         (*ctx->Exec->PushAttrib)( n[1].bf );
  4635.         break;
  4636.      case OPCODE_PUSH_MATRIX:
  4637.         (*ctx->Exec->PushMatrix)();
  4638.         break;
  4639.      case OPCODE_PUSH_NAME:
  4640.         (*ctx->Exec->PushName)( n[1].ui );
  4641.         break;
  4642.      case OPCODE_RASTER_POS:
  4643.             (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
  4644.         break;
  4645.      case OPCODE_READ_BUFFER:
  4646.         (*ctx->Exec->ReadBuffer)( n[1].e );
  4647.         break;
  4648.          case OPCODE_RESET_HISTOGRAM:
  4649.             (*ctx->Exec->ResetHistogram)( n[1].e );
  4650.             break;
  4651.          case OPCODE_RESET_MIN_MAX:
  4652.             (*ctx->Exec->ResetMinmax)( n[1].e );
  4653.             break;
  4654.          case OPCODE_ROTATE:
  4655.             (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
  4656.             break;
  4657.          case OPCODE_SCALE:
  4658.             (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
  4659.             break;
  4660.      case OPCODE_SCISSOR:
  4661.         (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
  4662.         break;
  4663.      case OPCODE_SHADE_MODEL:
  4664.         (*ctx->Exec->ShadeModel)( n[1].e );
  4665.         break;
  4666.      case OPCODE_STENCIL_FUNC:
  4667.         (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
  4668.         break;
  4669.      case OPCODE_STENCIL_MASK:
  4670.         (*ctx->Exec->StencilMask)( n[1].ui );
  4671.         break;
  4672.      case OPCODE_STENCIL_OP:
  4673.         (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
  4674.         break;
  4675.          case OPCODE_TEXENV:
  4676.             {
  4677.                GLfloat params[4];
  4678.                params[0] = n[3].f;
  4679.                params[1] = n[4].f;
  4680.                params[2] = n[5].f;
  4681.                params[3] = n[6].f;
  4682.                (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
  4683.             }
  4684.             break;
  4685.          case OPCODE_TEXGEN:
  4686.             {
  4687.                GLfloat params[4];
  4688.                params[0] = n[3].f;
  4689.                params[1] = n[4].f;
  4690.                params[2] = n[5].f;
  4691.                params[3] = n[6].f;
  4692.                (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
  4693.             }
  4694.             break;
  4695.          case OPCODE_TEXPARAMETER:
  4696.             {
  4697.                GLfloat params[4];
  4698.                params[0] = n[3].f;
  4699.                params[1] = n[4].f;
  4700.                params[2] = n[5].f;
  4701.                params[3] = n[6].f;
  4702.                (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
  4703.             }
  4704.             break;
  4705.      case OPCODE_TEX_IMAGE1D:
  4706.             {
  4707.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4708.                ctx->Unpack = _mesa_native_packing;
  4709.                (*ctx->Exec->TexImage1D)(
  4710.                                         n[1].e, /* target */
  4711.                                         n[2].i, /* level */
  4712.                                         n[3].i, /* components */
  4713.                                         n[4].i, /* width */
  4714.                                         n[5].e, /* border */
  4715.                                         n[6].e, /* format */
  4716.                                         n[7].e, /* type */
  4717.                                         n[8].data );
  4718.                ctx->Unpack = save;  /* restore */
  4719.             }
  4720.         break;
  4721.      case OPCODE_TEX_IMAGE2D:
  4722.             {
  4723.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4724.                ctx->Unpack = _mesa_native_packing;
  4725.                (*ctx->Exec->TexImage2D)(
  4726.                                         n[1].e, /* target */
  4727.                                         n[2].i, /* level */
  4728.                                         n[3].i, /* components */
  4729.                                         n[4].i, /* width */
  4730.                                         n[5].i, /* height */
  4731.                                         n[6].e, /* border */
  4732.                                         n[7].e, /* format */
  4733.                                         n[8].e, /* type */
  4734.                                         n[9].data );
  4735.                ctx->Unpack = save;  /* restore */
  4736.             }
  4737.         break;
  4738.          case OPCODE_TEX_IMAGE3D:
  4739.             {
  4740.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4741.                ctx->Unpack = _mesa_native_packing;
  4742.                (*ctx->Exec->TexImage3D)(
  4743.                                         n[1].e, /* target */
  4744.                                         n[2].i, /* level */
  4745.                                         n[3].i, /* components */
  4746.                                         n[4].i, /* width */
  4747.                                         n[5].i, /* height */
  4748.                                         n[6].i, /* depth  */
  4749.                                         n[7].e, /* border */
  4750.                                         n[8].e, /* format */
  4751.                                         n[9].e, /* type */
  4752.                                         n[10].data );
  4753.                ctx->Unpack = save;  /* restore */
  4754.             }
  4755.             break;
  4756.          case OPCODE_TEX_SUB_IMAGE1D:
  4757.             {
  4758.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4759.                ctx->Unpack = _mesa_native_packing;
  4760.                (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
  4761.                                            n[4].i, n[5].e,
  4762.                                            n[6].e, n[7].data );
  4763.                ctx->Unpack = save;  /* restore */
  4764.             }
  4765.             break;
  4766.          case OPCODE_TEX_SUB_IMAGE2D:
  4767.             {
  4768.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4769.                ctx->Unpack = _mesa_native_packing;
  4770.                (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
  4771.                                            n[4].i, n[5].e,
  4772.                                            n[6].i, n[7].e, n[8].e, n[9].data );
  4773.                ctx->Unpack = save;  /* restore */
  4774.             }
  4775.             break;
  4776.          case OPCODE_TEX_SUB_IMAGE3D:
  4777.             {
  4778.                struct gl_pixelstore_attrib save = ctx->Unpack;
  4779.                ctx->Unpack = _mesa_native_packing;
  4780.                (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
  4781.                                            n[4].i, n[5].i, n[6].i, n[7].i,
  4782.                                            n[8].i, n[9].e, n[10].e,
  4783.                                            n[11].data );
  4784.                ctx->Unpack = save;  /* restore */
  4785.             }
  4786.             break;
  4787.          case OPCODE_TRANSLATE:
  4788.             (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
  4789.             break;
  4790.      case OPCODE_VIEWPORT:
  4791.         (*ctx->Exec->Viewport)(n[1].i, n[2].i,
  4792.                                   (GLsizei) n[3].i, (GLsizei) n[4].i);
  4793.         break;
  4794.      case OPCODE_WINDOW_POS:
  4795.             (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
  4796.         break;
  4797.          case OPCODE_ACTIVE_TEXTURE:  /* GL_ARB_multitexture */
  4798.             (*ctx->Exec->ActiveTextureARB)( n[1].e );
  4799.             break;
  4800.          case OPCODE_PIXEL_TEXGEN_SGIX:  /* GL_SGIX_pixel_texture */
  4801.             (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
  4802.             break;
  4803.          case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS:  /* GL_SGIS_pixel_texture */
  4804.             (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i );
  4805.             break;
  4806.          case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
  4807.             (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e,
  4808.                                             n[4].i, n[5].i, n[6].i, n[7].data);
  4809.             break;
  4810.          case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */
  4811.             (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e,
  4812.                                     n[4].i, n[5].i, n[6].i, n[7].i, n[8].data);
  4813.             break;
  4814.          case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */
  4815.             (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e,
  4816.                             n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data);
  4817.             break;
  4818.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */
  4819.             (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i,
  4820.                                             n[4].i, n[5].e, n[6].i, n[7].data);
  4821.             break;
  4822.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */
  4823.             (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i,
  4824.                             n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data);
  4825.             break;
  4826.          case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */
  4827.             (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i,
  4828.                                         n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
  4829.                                         n[9].e, n[10].i, n[11].data);
  4830.             break;
  4831.          case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
  4832.             (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
  4833.             break;
  4834.      case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
  4835.             (*ctx->Exec->WindowPos3fMESA)( n[1].f, n[2].f, n[3].f );
  4836.         break;
  4837.          case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
  4838.             (*ctx->Exec->BindProgramNV)( n[1].e, n[2].ui );
  4839.             break;
  4840.          case OPCODE_EXECUTE_PROGRAM_NV:
  4841.             {
  4842.                GLfloat v[4];
  4843.                v[0] = n[3].f;
  4844.                v[1] = n[4].f;
  4845.                v[2] = n[5].f;
  4846.                v[3] = n[6].f;
  4847.                (*ctx->Exec->ExecuteProgramNV)(n[1].e, n[2].ui, v);
  4848.             }
  4849.             break;
  4850.          case OPCODE_REQUEST_PROGRAMS_RESIDENT_NV:
  4851.             /*
  4852.             (*ctx->Exec->RequestResidentProgramsNV)();
  4853.             */
  4854.             break;
  4855.          case OPCODE_LOAD_PROGRAM_NV:
  4856.             /*
  4857.             (*ctx->Exec->LoadProgramNV)();
  4858.             */
  4859.             break;
  4860.          case OPCODE_PROGRAM_PARAMETER4F_NV:
  4861.             (*ctx->Exec->ProgramParameter4fNV)(n[1].e, n[2].ui, n[3].f,
  4862.                                                n[4].f, n[5].f, n[6].f);
  4863.             break;
  4864.          case OPCODE_TRACK_MATRIX_NV:
  4865.             (*ctx->Exec->TrackMatrixNV)(n[1].e, n[2].ui, n[3].e, n[4].e);
  4866.             break;
  4867.  
  4868.      case OPCODE_CONTINUE:
  4869.         n = (Node *) n[1].next;
  4870.         break;
  4871.      case OPCODE_END_OF_LIST:
  4872.         done = GL_TRUE;
  4873.         break;
  4874.      default:
  4875.             {
  4876.                char msg[1000];
  4877.                _mesa_sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
  4878.                _mesa_problem(ctx, msg);
  4879.             }
  4880.             done = GL_TRUE;
  4881.      }
  4882.  
  4883.      /* increment n to point to next compiled command */
  4884.      if (opcode!=OPCODE_CONTINUE) {
  4885.         n += InstSize[opcode];
  4886.      }
  4887.       }
  4888.    }
  4889.    ctx->CallDepth--;
  4890.  
  4891.    if (ctx->Driver.EndCallList)
  4892.       ctx->Driver.EndCallList( ctx );
  4893. }
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  
  4899. /**********************************************************************/
  4900. /*                           GL functions                             */
  4901. /**********************************************************************/
  4902.  
  4903.  
  4904.  
  4905.  
  4906. /*
  4907.  * Test if a display list number is valid.
  4908.  */
  4909. GLboolean
  4910. _mesa_IsList( GLuint list )
  4911. {
  4912.    GET_CURRENT_CONTEXT(ctx);
  4913.    FLUSH_VERTICES(ctx, 0);    /* must be called before assert */
  4914.    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
  4915.    return islist(ctx, list);
  4916. }
  4917.  
  4918.  
  4919. /*
  4920.  * Delete a sequence of consecutive display lists.
  4921.  */
  4922. void
  4923. _mesa_DeleteLists( GLuint list, GLsizei range )
  4924. {
  4925.    GET_CURRENT_CONTEXT(ctx);
  4926.    GLuint i;
  4927.    FLUSH_VERTICES(ctx, 0);    /* must be called before assert */
  4928.    ASSERT_OUTSIDE_BEGIN_END(ctx);
  4929.  
  4930.    if (range<0) {
  4931.       _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
  4932.       return;
  4933.    }
  4934.    for (i=list;i<list+range;i++) {
  4935.       _mesa_destroy_list( ctx, i );
  4936.    }
  4937. }
  4938.  
  4939.  
  4940.  
  4941. /*
  4942.  * Return a display list number, n, such that lists n through n+range-1
  4943.  * are free.
  4944.  */
  4945. GLuint
  4946. _mesa_GenLists(GLsizei range )
  4947. {
  4948.    GET_CURRENT_CONTEXT(ctx);
  4949.    GLuint base;
  4950.    FLUSH_VERTICES(ctx, 0);    /* must be called before assert */
  4951.    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
  4952.  
  4953.    if (range<0) {
  4954.       _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
  4955.       return 0;
  4956.    }
  4957.    if (range==0) {
  4958.       return 0;
  4959.    }
  4960.  
  4961.    /*
  4962.     * Make this an atomic operation
  4963.     */
  4964.    _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
  4965.  
  4966.    base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
  4967.    if (base) {
  4968.       /* reserve the list IDs by with empty/dummy lists */
  4969.       GLint i;
  4970.       for (i=0; i<range; i++) {
  4971.          _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
  4972.       }
  4973.    }
  4974.  
  4975.    _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
  4976.  
  4977.    return base;
  4978. }
  4979.  
  4980.  
  4981.  
  4982. /*
  4983.  * Begin a new display list.
  4984.  */
  4985. void
  4986. _mesa_NewList( GLuint list, GLenum mode )
  4987. {
  4988.    GET_CURRENT_CONTEXT(ctx);
  4989.    FLUSH_CURRENT(ctx, 0);    /* must be called before assert */
  4990.    ASSERT_OUTSIDE_BEGIN_END(ctx);
  4991.  
  4992.    if (MESA_VERBOSE&VERBOSE_API)
  4993.       _mesa_debug(ctx, "glNewList %u %s\n", list,
  4994.                   _mesa_lookup_enum_by_nr(mode));
  4995.  
  4996.    if (list==0) {
  4997.       _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
  4998.       return;
  4999.    }
  5000.  
  5001.    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
  5002.       _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
  5003.       return;
  5004.    }
  5005.  
  5006.    if (ctx->CurrentListPtr) {
  5007.       /* already compiling a display list */
  5008.       _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  5009.       return;
  5010.    }
  5011.  
  5012.    /* Allocate new display list */
  5013.    ctx->CurrentListNum = list;
  5014.    ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
  5015.    ctx->CurrentListPtr = ctx->CurrentBlock;
  5016.    ctx->CurrentPos = 0;
  5017.    ctx->CompileFlag = GL_TRUE;
  5018.    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
  5019.  
  5020.    ctx->Driver.NewList( ctx, list, mode );
  5021.  
  5022.    ctx->CurrentDispatch = ctx->Save;
  5023.    _glapi_set_dispatch( ctx->CurrentDispatch );
  5024. }
  5025.  
  5026.  
  5027.  
  5028. /*
  5029.  * End definition of current display list.  Is the current
  5030.  * ASSERT_OUTSIDE_BEGIN_END strong enough to really guarentee that
  5031.  * we are outside begin/end calls?
  5032.  */
  5033. void
  5034. _mesa_EndList( void )
  5035. {
  5036.    GET_CURRENT_CONTEXT(ctx);
  5037.    FLUSH_CURRENT(ctx, 0);    /* must be called before assert */
  5038.    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
  5039.  
  5040.    if (MESA_VERBOSE&VERBOSE_API)
  5041.       _mesa_debug(ctx, "glEndList\n");
  5042.  
  5043.    /* Check that a list is under construction */
  5044.    if (!ctx->CurrentListPtr) {
  5045.       _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
  5046.       return;
  5047.    }
  5048.  
  5049.    (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
  5050.  
  5051.    /* Destroy old list, if any */
  5052.    _mesa_destroy_list(ctx, ctx->CurrentListNum);
  5053.    /* Install the list */
  5054.    _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
  5055.  
  5056.  
  5057.    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
  5058.       mesa_print_display_list(ctx->CurrentListNum);
  5059.  
  5060.    ctx->CurrentListNum = 0;
  5061.    ctx->CurrentListPtr = NULL;
  5062.    ctx->ExecuteFlag = GL_TRUE;
  5063.    ctx->CompileFlag = GL_FALSE;
  5064.  
  5065.    ctx->Driver.EndList( ctx );
  5066.  
  5067.    ctx->CurrentDispatch = ctx->Exec;
  5068.    _glapi_set_dispatch( ctx->CurrentDispatch );
  5069. }
  5070.  
  5071.  
  5072.  
  5073. void
  5074. _mesa_CallList( GLuint list )
  5075. {
  5076.    GLboolean save_compile_flag;
  5077.    GET_CURRENT_CONTEXT(ctx);
  5078.    FLUSH_CURRENT(ctx, 0);
  5079.    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
  5080.    /* execute the display list, and restore the CompileFlag. */
  5081.  
  5082.  
  5083.    if (MESA_VERBOSE & VERBOSE_API)
  5084.       _mesa_debug(ctx, "_mesa_CallList %d\n", list); 
  5085.  
  5086. /*     mesa_print_display_list( list ); */
  5087.  
  5088.    save_compile_flag = ctx->CompileFlag;
  5089.    if (save_compile_flag) {
  5090.       ctx->CompileFlag = GL_FALSE;
  5091.    }
  5092.  
  5093.    execute_list( ctx, list );
  5094.    ctx->CompileFlag = save_compile_flag;
  5095.  
  5096.    /* also restore API function pointers to point to "save" versions */
  5097.    if (save_compile_flag) {
  5098.       ctx->CurrentDispatch = ctx->Save;
  5099.       _glapi_set_dispatch( ctx->CurrentDispatch );
  5100.    }
  5101. }
  5102.  
  5103.  
  5104.  
  5105. /*
  5106.  * Execute glCallLists:  call multiple display lists.
  5107.  */
  5108. void
  5109. _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
  5110. {
  5111.    GET_CURRENT_CONTEXT(ctx);
  5112.    GLuint list;
  5113.    GLint i;
  5114.    GLboolean save_compile_flag;
  5115.  
  5116.    if (MESA_VERBOSE & VERBOSE_API)
  5117.       _mesa_debug(ctx, "_mesa_CallLists %d\n", n); 
  5118.  
  5119.    switch (type) {
  5120.       case GL_BYTE:
  5121.       case GL_UNSIGNED_BYTE:
  5122.       case GL_SHORT:
  5123.       case GL_UNSIGNED_SHORT:
  5124.       case GL_INT:
  5125.       case GL_UNSIGNED_INT:
  5126.       case GL_FLOAT:
  5127.       case GL_2_BYTES:
  5128.       case GL_3_BYTES:
  5129.       case GL_4_BYTES:
  5130.          /* OK */
  5131.          break;
  5132.       default:
  5133.          _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
  5134.          return;
  5135.    }
  5136.  
  5137.    /* Save the CompileFlag status, turn it off, execute display list,
  5138.     * and restore the CompileFlag.
  5139.     */
  5140.    save_compile_flag = ctx->CompileFlag;
  5141.    ctx->CompileFlag = GL_FALSE;
  5142.  
  5143.    for (i=0;i<n;i++) {
  5144.       list = translate_id( i, type, lists );
  5145.       execute_list( ctx, ctx->List.ListBase + list );
  5146.    }
  5147.  
  5148.    ctx->CompileFlag = save_compile_flag;
  5149.  
  5150.    /* also restore API function pointers to point to "save" versions */
  5151.    if (save_compile_flag) {
  5152.       ctx->CurrentDispatch = ctx->Save;
  5153.       _glapi_set_dispatch( ctx->CurrentDispatch );
  5154.    }
  5155. }
  5156.  
  5157.  
  5158.  
  5159. /*
  5160.  * Set the offset added to list numbers in glCallLists.
  5161.  */
  5162. void
  5163. _mesa_ListBase( GLuint base )
  5164. {
  5165.    GET_CURRENT_CONTEXT(ctx);
  5166.    FLUSH_VERTICES(ctx, 0);    /* must be called before assert */
  5167.    ASSERT_OUTSIDE_BEGIN_END(ctx);
  5168.    ctx->List.ListBase = base;
  5169. }
  5170.  
  5171.  
  5172. /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
  5173.  */
  5174. static void exec_Finish( void )
  5175. {
  5176.    GET_CURRENT_CONTEXT(ctx);
  5177.    FLUSH_VERTICES(ctx, 0);
  5178.    ctx->Exec->Finish();
  5179. }
  5180.  
  5181. static void exec_Flush( void )
  5182. {
  5183.    GET_CURRENT_CONTEXT(ctx);
  5184.    FLUSH_VERTICES(ctx, 0);
  5185.    ctx->Exec->Flush( );
  5186. }
  5187.  
  5188. static void exec_GetBooleanv( GLenum pname, GLboolean *params )
  5189. {
  5190.    GET_CURRENT_CONTEXT(ctx);
  5191.    FLUSH_VERTICES(ctx, 0);
  5192.    ctx->Exec->GetBooleanv( pname, params );
  5193. }
  5194.  
  5195. static void exec_GetClipPlane( GLenum plane, GLdouble *equation )
  5196. {
  5197.    GET_CURRENT_CONTEXT(ctx);
  5198.    FLUSH_VERTICES(ctx, 0);
  5199.    ctx->Exec->GetClipPlane( plane, equation );
  5200. }
  5201.  
  5202. static void exec_GetDoublev( GLenum pname, GLdouble *params )
  5203. {
  5204.    GET_CURRENT_CONTEXT(ctx);
  5205.    FLUSH_VERTICES(ctx, 0);
  5206.    ctx->Exec->GetDoublev(  pname, params );
  5207. }
  5208.  
  5209. static GLenum exec_GetError( void )
  5210. {
  5211.    GET_CURRENT_CONTEXT(ctx);
  5212.    FLUSH_VERTICES(ctx, 0);
  5213.    return ctx->Exec->GetError( );
  5214. }
  5215.  
  5216. static void exec_GetFloatv( GLenum pname, GLfloat *params )
  5217. {
  5218.    GET_CURRENT_CONTEXT(ctx);
  5219.    FLUSH_VERTICES(ctx, 0);
  5220.    ctx->Exec->GetFloatv( pname, params );
  5221. }
  5222.  
  5223. static void exec_GetIntegerv( GLenum pname, GLint *params )
  5224. {
  5225.    GET_CURRENT_CONTEXT(ctx);
  5226.    FLUSH_VERTICES(ctx, 0);
  5227.    ctx->Exec->GetIntegerv( pname, params );
  5228. }
  5229.  
  5230. static void exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
  5231. {
  5232.    GET_CURRENT_CONTEXT(ctx);
  5233.    FLUSH_VERTICES(ctx, 0);
  5234.    ctx->Exec->GetLightfv( light, pname, params );
  5235. }
  5236.  
  5237. static void exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
  5238. {
  5239.    GET_CURRENT_CONTEXT(ctx);
  5240.    FLUSH_VERTICES(ctx, 0);
  5241.    ctx->Exec->GetLightiv( light, pname, params );
  5242. }
  5243.  
  5244. static void exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
  5245. {
  5246.    GET_CURRENT_CONTEXT(ctx);
  5247.    FLUSH_VERTICES(ctx, 0);
  5248.    ctx->Exec->GetMapdv( target, query, v );
  5249. }
  5250.  
  5251. static void exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
  5252. {
  5253.    GET_CURRENT_CONTEXT(ctx);
  5254.    FLUSH_VERTICES(ctx, 0);
  5255.    ctx->Exec->GetMapfv( target, query, v );
  5256. }
  5257.  
  5258. static void exec_GetMapiv( GLenum target, GLenum query, GLint *v )
  5259. {
  5260.    GET_CURRENT_CONTEXT(ctx);
  5261.    FLUSH_VERTICES(ctx, 0);
  5262.    ctx->Exec->GetMapiv( target, query, v );
  5263. }
  5264.  
  5265. static void exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
  5266. {
  5267.    GET_CURRENT_CONTEXT(ctx);
  5268.    FLUSH_VERTICES(ctx, 0);
  5269.    ctx->Exec->GetMaterialfv( face, pname, params );
  5270. }
  5271.  
  5272. static void exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
  5273. {
  5274.    GET_CURRENT_CONTEXT(ctx);
  5275.    FLUSH_VERTICES(ctx, 0);
  5276.    ctx->Exec->GetMaterialiv( face, pname, params );
  5277. }
  5278.  
  5279. static void exec_GetPixelMapfv( GLenum map, GLfloat *values )
  5280. {
  5281.    GET_CURRENT_CONTEXT(ctx);
  5282.    FLUSH_VERTICES(ctx, 0);
  5283.    ctx->Exec->GetPixelMapfv( map,  values );
  5284. }
  5285.  
  5286. static void exec_GetPixelMapuiv( GLenum map, GLuint *values )
  5287. {
  5288.    GET_CURRENT_CONTEXT(ctx);
  5289.    FLUSH_VERTICES(ctx, 0);
  5290.    ctx->Exec->GetPixelMapuiv( map, values );
  5291. }
  5292.  
  5293. static void exec_GetPixelMapusv( GLenum map, GLushort *values )
  5294. {
  5295.    GET_CURRENT_CONTEXT(ctx);
  5296.    FLUSH_VERTICES(ctx, 0);
  5297.    ctx->Exec->GetPixelMapusv( map, values );
  5298. }
  5299.  
  5300. static void exec_GetPolygonStipple( GLubyte *dest )
  5301. {
  5302.    GET_CURRENT_CONTEXT(ctx);
  5303.    FLUSH_VERTICES(ctx, 0);
  5304.    ctx->Exec->GetPolygonStipple( dest );
  5305. }
  5306.  
  5307. static const GLubyte *exec_GetString( GLenum name )
  5308. {
  5309.    GET_CURRENT_CONTEXT(ctx);
  5310.    FLUSH_VERTICES(ctx, 0);
  5311.    return ctx->Exec->GetString( name );
  5312. }
  5313.  
  5314. static void exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
  5315. {
  5316.    GET_CURRENT_CONTEXT(ctx);
  5317.    FLUSH_VERTICES(ctx, 0);
  5318.    ctx->Exec->GetTexEnvfv( target, pname, params );
  5319. }
  5320.  
  5321. static void exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
  5322. {
  5323.    GET_CURRENT_CONTEXT(ctx);
  5324.    FLUSH_VERTICES(ctx, 0);
  5325.    ctx->Exec->GetTexEnviv( target, pname, params );
  5326. }
  5327.  
  5328. static void exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
  5329. {
  5330.    GET_CURRENT_CONTEXT(ctx);
  5331.    FLUSH_VERTICES(ctx, 0);
  5332.    ctx->Exec->GetTexGendv( coord, pname, params );
  5333. }
  5334.  
  5335. static void exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
  5336. {
  5337.    GET_CURRENT_CONTEXT(ctx);
  5338.    FLUSH_VERTICES(ctx, 0);
  5339.    ctx->Exec->GetTexGenfv( coord, pname, params );
  5340. }
  5341.  
  5342. static void exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
  5343. {
  5344.    GET_CURRENT_CONTEXT(ctx);
  5345.    FLUSH_VERTICES(ctx, 0);
  5346.    ctx->Exec->GetTexGeniv( coord, pname, params );
  5347. }
  5348.  
  5349. static void exec_GetTexImage( GLenum target, GLint level, GLenum format,
  5350.                    GLenum type, GLvoid *pixels )
  5351. {
  5352.    GET_CURRENT_CONTEXT(ctx);
  5353.    FLUSH_VERTICES(ctx, 0);
  5354.    ctx->Exec->GetTexImage( target, level, format, type, pixels );
  5355. }
  5356.  
  5357. static void exec_GetTexLevelParameterfv( GLenum target, GLint level,
  5358.                               GLenum pname, GLfloat *params )
  5359. {
  5360.    GET_CURRENT_CONTEXT(ctx);
  5361.    FLUSH_VERTICES(ctx, 0);
  5362.    ctx->Exec->GetTexLevelParameterfv( target, level, pname, params );
  5363. }
  5364.  
  5365. static void exec_GetTexLevelParameteriv( GLenum target, GLint level,
  5366.                               GLenum pname, GLint *params )
  5367. {
  5368.    GET_CURRENT_CONTEXT(ctx);
  5369.    FLUSH_VERTICES(ctx, 0);
  5370.    ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
  5371. }
  5372.  
  5373. static void exec_GetTexParameterfv( GLenum target, GLenum pname,
  5374.                     GLfloat *params )
  5375. {
  5376.    GET_CURRENT_CONTEXT(ctx);
  5377.    FLUSH_VERTICES(ctx, 0);
  5378.    ctx->Exec->GetTexParameterfv( target, pname, params );
  5379. }
  5380.  
  5381. static void exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
  5382. {
  5383.    GET_CURRENT_CONTEXT(ctx);
  5384.    FLUSH_VERTICES(ctx, 0);
  5385.    ctx->Exec->GetTexParameteriv( target, pname, params );
  5386. }
  5387.  
  5388. static GLboolean exec_IsEnabled( GLenum cap )
  5389. {
  5390.    GET_CURRENT_CONTEXT(ctx);
  5391.    FLUSH_VERTICES(ctx, 0);
  5392.    return ctx->Exec->IsEnabled( cap );
  5393. }
  5394.  
  5395. static void exec_PixelStoref( GLenum pname, GLfloat param )
  5396. {
  5397.    GET_CURRENT_CONTEXT(ctx);
  5398.    FLUSH_VERTICES(ctx, 0);
  5399.    ctx->Exec->PixelStoref( pname, param );
  5400. }
  5401.  
  5402. static void exec_PixelStorei( GLenum pname, GLint param )
  5403. {
  5404.    GET_CURRENT_CONTEXT(ctx);
  5405.    FLUSH_VERTICES(ctx, 0);
  5406.    ctx->Exec->PixelStorei( pname, param );
  5407. }
  5408.  
  5409. static void exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
  5410.           GLenum format, GLenum type, GLvoid *pixels )
  5411. {
  5412.    GET_CURRENT_CONTEXT(ctx);
  5413.    FLUSH_VERTICES(ctx, 0);
  5414.    ctx->Exec->ReadPixels( x, y, width, height, format, type, pixels );
  5415. }
  5416.  
  5417. static GLint exec_RenderMode( GLenum mode )
  5418. {
  5419.    GET_CURRENT_CONTEXT(ctx);
  5420.    FLUSH_VERTICES(ctx, 0);
  5421.    return ctx->Exec->RenderMode( mode );
  5422. }
  5423.  
  5424. static void exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
  5425. {
  5426.    GET_CURRENT_CONTEXT(ctx);
  5427.    FLUSH_VERTICES(ctx, 0);
  5428.    ctx->Exec->FeedbackBuffer( size, type, buffer );
  5429. }
  5430.  
  5431. static void exec_SelectBuffer( GLsizei size, GLuint *buffer )
  5432. {
  5433.    GET_CURRENT_CONTEXT(ctx);
  5434.    FLUSH_VERTICES(ctx, 0);
  5435.    ctx->Exec->SelectBuffer( size, buffer );
  5436. }
  5437.  
  5438. static GLboolean exec_AreTexturesResident(GLsizei n, const GLuint *texName,
  5439.                       GLboolean *residences)
  5440. {
  5441.    GET_CURRENT_CONTEXT(ctx);
  5442.    FLUSH_VERTICES(ctx, 0);
  5443.    return ctx->Exec->AreTexturesResident( n, texName, residences);
  5444. }
  5445.  
  5446. static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
  5447.                   const GLvoid *ptr)
  5448. {
  5449.    GET_CURRENT_CONTEXT(ctx);
  5450.    FLUSH_VERTICES(ctx, 0);
  5451.    ctx->Exec->ColorPointer( size, type, stride, ptr);
  5452. }
  5453.  
  5454. static void exec_DeleteTextures( GLsizei n, const GLuint *texName)
  5455. {
  5456.    GET_CURRENT_CONTEXT(ctx);
  5457.    FLUSH_VERTICES(ctx, 0);
  5458.    ctx->Exec->DeleteTextures( n, texName);
  5459. }
  5460.  
  5461. static void exec_DisableClientState( GLenum cap )
  5462. {
  5463.    GET_CURRENT_CONTEXT(ctx);
  5464.    FLUSH_VERTICES(ctx, 0);
  5465.    ctx->Exec->DisableClientState( cap );
  5466. }
  5467.  
  5468. static void exec_EdgeFlagPointer(GLsizei stride, const void *vptr)
  5469. {
  5470.    GET_CURRENT_CONTEXT(ctx);
  5471.    FLUSH_VERTICES(ctx, 0);
  5472.    ctx->Exec->EdgeFlagPointer( stride, vptr);
  5473. }
  5474.  
  5475. static void exec_EnableClientState( GLenum cap )
  5476. {
  5477.    GET_CURRENT_CONTEXT(ctx);
  5478.    FLUSH_VERTICES(ctx, 0);
  5479.    ctx->Exec->EnableClientState( cap );
  5480. }
  5481.  
  5482. static void exec_GenTextures( GLsizei n, GLuint *texName )
  5483. {
  5484.    GET_CURRENT_CONTEXT(ctx);
  5485.    FLUSH_VERTICES(ctx, 0);
  5486.    ctx->Exec->GenTextures( n, texName );
  5487. }
  5488.  
  5489. static void exec_GetPointerv( GLenum pname, GLvoid **params )
  5490. {
  5491.    GET_CURRENT_CONTEXT(ctx);
  5492.    FLUSH_VERTICES(ctx, 0);
  5493.    ctx->Exec->GetPointerv( pname, params );
  5494. }
  5495.  
  5496. static void exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
  5497. {
  5498.    GET_CURRENT_CONTEXT(ctx);
  5499.    FLUSH_VERTICES(ctx, 0);
  5500.    ctx->Exec->IndexPointer( type, stride, ptr);
  5501. }
  5502.  
  5503. static void exec_InterleavedArrays(GLenum format, GLsizei stride,
  5504.                    const GLvoid *pointer)
  5505. {
  5506.    GET_CURRENT_CONTEXT(ctx);
  5507.    FLUSH_VERTICES(ctx, 0);
  5508.    ctx->Exec->InterleavedArrays( format, stride, pointer);
  5509. }
  5510.  
  5511. static GLboolean exec_IsTexture( GLuint texture )
  5512. {
  5513.    GET_CURRENT_CONTEXT(ctx);
  5514.    FLUSH_VERTICES(ctx, 0);
  5515.    return ctx->Exec->IsTexture( texture );
  5516. }
  5517.  
  5518. static void exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
  5519. {
  5520.    GET_CURRENT_CONTEXT(ctx);
  5521.    FLUSH_VERTICES(ctx, 0);
  5522.    ctx->Exec->NormalPointer( type, stride, ptr );
  5523. }
  5524.  
  5525. static void exec_PopClientAttrib(void)
  5526. {
  5527.    GET_CURRENT_CONTEXT(ctx);
  5528.    FLUSH_VERTICES(ctx, 0);
  5529.    ctx->Exec->PopClientAttrib();
  5530. }
  5531.  
  5532. static void exec_PushClientAttrib(GLbitfield mask)
  5533. {
  5534.    GET_CURRENT_CONTEXT(ctx);
  5535.    FLUSH_VERTICES(ctx, 0);
  5536.    ctx->Exec->PushClientAttrib( mask);
  5537. }
  5538.  
  5539. static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
  5540.                  const GLvoid *ptr)
  5541. {
  5542.    GET_CURRENT_CONTEXT(ctx);
  5543.    FLUSH_VERTICES(ctx, 0);
  5544.    ctx->Exec->TexCoordPointer( size,  type,  stride, ptr);
  5545. }
  5546.  
  5547. static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
  5548.                       GLvoid *img)
  5549. {
  5550.    GET_CURRENT_CONTEXT(ctx);
  5551.    FLUSH_VERTICES(ctx, 0);
  5552.    ctx->Exec->GetCompressedTexImageARB( target, level, img);
  5553. }
  5554.  
  5555. static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
  5556.                    const GLvoid *ptr)
  5557. {
  5558.    GET_CURRENT_CONTEXT(ctx);
  5559.    FLUSH_VERTICES(ctx, 0);
  5560.    ctx->Exec->VertexPointer( size, type, stride, ptr);
  5561. }
  5562.  
  5563. static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
  5564.                      GLint x, GLint y, GLsizei width)
  5565. {
  5566.    GET_CURRENT_CONTEXT(ctx);
  5567.    FLUSH_VERTICES(ctx, 0);
  5568.    ctx->Exec->CopyConvolutionFilter1D( target, internalFormat, x, y, width);
  5569. }
  5570.  
  5571. static void exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
  5572.                      GLint x, GLint y, GLsizei width,
  5573.                      GLsizei height)
  5574. {
  5575.    GET_CURRENT_CONTEXT(ctx);
  5576.    FLUSH_VERTICES(ctx, 0);
  5577.    ctx->Exec->CopyConvolutionFilter2D( target, internalFormat, x, y, width,
  5578.                        height);
  5579. }
  5580.  
  5581. static void exec_GetColorTable( GLenum target, GLenum format,
  5582.                 GLenum type, GLvoid *data )
  5583. {
  5584.    GET_CURRENT_CONTEXT(ctx);
  5585.    FLUSH_VERTICES(ctx, 0);
  5586.    ctx->Exec->GetColorTable( target, format, type, data );
  5587. }
  5588.  
  5589. static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
  5590.                        GLfloat *params )
  5591. {
  5592.    GET_CURRENT_CONTEXT(ctx);
  5593.    FLUSH_VERTICES(ctx, 0);
  5594.    ctx->Exec->GetColorTableParameterfv( target, pname, params );
  5595. }
  5596.  
  5597. static void exec_GetColorTableParameteriv( GLenum target, GLenum pname,
  5598.                        GLint *params )
  5599. {
  5600.    GET_CURRENT_CONTEXT(ctx);
  5601.    FLUSH_VERTICES(ctx, 0);
  5602.    ctx->Exec->GetColorTableParameteriv( target, pname, params );
  5603. }
  5604.  
  5605. static void exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
  5606.                       GLvoid *image)
  5607. {
  5608.    GET_CURRENT_CONTEXT(ctx);
  5609.    FLUSH_VERTICES(ctx, 0);
  5610.    ctx->Exec->GetConvolutionFilter( target, format, type, image);
  5611. }
  5612.  
  5613. static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
  5614.                        GLfloat *params)
  5615. {
  5616.    GET_CURRENT_CONTEXT(ctx);
  5617.    FLUSH_VERTICES(ctx, 0);
  5618.    ctx->Exec->GetConvolutionParameterfv( target, pname, params);
  5619. }
  5620.  
  5621. static void exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
  5622.                        GLint *params)
  5623. {
  5624.    GET_CURRENT_CONTEXT(ctx);
  5625.    FLUSH_VERTICES(ctx, 0);
  5626.    ctx->Exec->GetConvolutionParameteriv( target, pname, params);
  5627. }
  5628.  
  5629. static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
  5630.                   GLenum type, GLvoid *values)
  5631. {
  5632.    GET_CURRENT_CONTEXT(ctx);
  5633.    FLUSH_VERTICES(ctx, 0);
  5634.    ctx->Exec->GetHistogram( target, reset, format, type, values);
  5635. }
  5636.  
  5637. static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
  5638.                      GLfloat *params)
  5639. {
  5640.    GET_CURRENT_CONTEXT(ctx);
  5641.    FLUSH_VERTICES(ctx, 0);
  5642.    ctx->Exec->GetHistogramParameterfv( target, pname, params);
  5643. }
  5644.  
  5645. static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
  5646.                      GLint *params)
  5647. {
  5648.    GET_CURRENT_CONTEXT(ctx);
  5649.    FLUSH_VERTICES(ctx, 0);
  5650.    ctx->Exec->GetHistogramParameteriv( target, pname, params);
  5651. }
  5652.  
  5653. static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
  5654.                GLenum type, GLvoid *values)
  5655. {
  5656.    GET_CURRENT_CONTEXT(ctx);
  5657.    FLUSH_VERTICES(ctx, 0);
  5658.    ctx->Exec->GetMinmax( target, reset, format, type, values);
  5659. }
  5660.  
  5661. static void exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
  5662.                       GLfloat *params)
  5663. {
  5664.    GET_CURRENT_CONTEXT(ctx);
  5665.    FLUSH_VERTICES(ctx, 0);
  5666.    ctx->Exec->GetMinmaxParameterfv( target, pname, params);
  5667. }
  5668.  
  5669. static void exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
  5670.                       GLint *params)
  5671. {
  5672.    GET_CURRENT_CONTEXT(ctx);
  5673.    FLUSH_VERTICES(ctx, 0);
  5674.    ctx->Exec->GetMinmaxParameteriv( target, pname, params);
  5675. }
  5676.  
  5677. static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
  5678.                     GLvoid *row, GLvoid *column, GLvoid *span)
  5679. {
  5680.    GET_CURRENT_CONTEXT(ctx);
  5681.    FLUSH_VERTICES(ctx, 0);
  5682.    ctx->Exec->GetSeparableFilter( target, format, type, row, column, span);
  5683. }
  5684.  
  5685. static void exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
  5686.                    GLsizei width, GLsizei height, GLenum format,
  5687.                    GLenum type, const GLvoid *row,
  5688.                    const GLvoid *column)
  5689. {
  5690.    GET_CURRENT_CONTEXT(ctx);
  5691.    FLUSH_VERTICES(ctx, 0);
  5692.    ctx->Exec->SeparableFilter2D( target, internalFormat, width, height, format,
  5693.                  type, row, column);
  5694. }
  5695.  
  5696. static void exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
  5697. {
  5698.    GET_CURRENT_CONTEXT(ctx);
  5699.    FLUSH_VERTICES(ctx, 0);
  5700.    ctx->Exec->GetPixelTexGenParameterivSGIS( target, value);
  5701. }
  5702.  
  5703. static void exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
  5704. {
  5705.    GET_CURRENT_CONTEXT(ctx);
  5706.    FLUSH_VERTICES(ctx, 0);
  5707.    ctx->Exec->GetPixelTexGenParameterfvSGIS( target, value);
  5708. }
  5709.  
  5710. static void exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
  5711.                  GLsizei count, const GLvoid *ptr)
  5712. {
  5713.    GET_CURRENT_CONTEXT(ctx);
  5714.    FLUSH_VERTICES(ctx, 0);
  5715.    ctx->Exec->ColorPointerEXT( size, type, stride, count, ptr);
  5716. }
  5717.  
  5718. static void exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
  5719.                     const GLboolean *ptr)
  5720. {
  5721.    GET_CURRENT_CONTEXT(ctx);
  5722.    FLUSH_VERTICES(ctx, 0);
  5723.    ctx->Exec->EdgeFlagPointerEXT( stride, count, ptr);
  5724. }
  5725.  
  5726. static void exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
  5727.                       const GLvoid *ptr)
  5728. {
  5729.    GET_CURRENT_CONTEXT(ctx);
  5730.    FLUSH_VERTICES(ctx, 0);
  5731.    ctx->Exec->IndexPointerEXT( type, stride, count, ptr);
  5732. }
  5733.  
  5734. static void exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
  5735.                        const GLvoid *ptr)
  5736. {
  5737.    GET_CURRENT_CONTEXT(ctx);
  5738.    FLUSH_VERTICES(ctx, 0);
  5739.    ctx->Exec->NormalPointerEXT( type, stride, count, ptr);
  5740. }
  5741.  
  5742. static void exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
  5743.                     GLsizei count, const GLvoid *ptr)
  5744. {
  5745.    GET_CURRENT_CONTEXT(ctx);
  5746.    FLUSH_VERTICES(ctx, 0);
  5747.    ctx->Exec->TexCoordPointerEXT( size, type, stride, count, ptr);
  5748. }
  5749.  
  5750. static void exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
  5751.                        GLsizei count, const GLvoid *ptr)
  5752. {
  5753.    GET_CURRENT_CONTEXT(ctx);
  5754.    FLUSH_VERTICES(ctx, 0);
  5755.    ctx->Exec->VertexPointerEXT( size, type, stride, count, ptr);
  5756. }
  5757.  
  5758. static void exec_LockArraysEXT(GLint first, GLsizei count)
  5759. {
  5760.    GET_CURRENT_CONTEXT(ctx);
  5761.    FLUSH_VERTICES(ctx, 0);
  5762.    ctx->Exec->LockArraysEXT( first, count);
  5763. }
  5764.  
  5765. static void exec_UnlockArraysEXT( void )
  5766. {
  5767.    GET_CURRENT_CONTEXT(ctx);
  5768.    FLUSH_VERTICES(ctx, 0);
  5769.    ctx->Exec->UnlockArraysEXT( );
  5770. }
  5771.  
  5772. static void exec_ResizeBuffersMESA( void )
  5773. {
  5774.    GET_CURRENT_CONTEXT(ctx);
  5775.    FLUSH_VERTICES(ctx, 0);
  5776.    ctx->Exec->ResizeBuffersMESA( );
  5777. }
  5778.  
  5779.  
  5780. static void exec_ClientActiveTextureARB( GLenum target )
  5781. {
  5782.    GET_CURRENT_CONTEXT(ctx);
  5783.    FLUSH_VERTICES(ctx, 0);
  5784.    ctx->Exec->ClientActiveTextureARB(target);
  5785. }
  5786.  
  5787. static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
  5788.                    GLsizei stride, const GLvoid *ptr)
  5789. {
  5790.    GET_CURRENT_CONTEXT(ctx);
  5791.    FLUSH_VERTICES(ctx, 0);
  5792.    ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
  5793. }
  5794.  
  5795. static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
  5796.                     const GLvoid *ptr)
  5797. {
  5798.    GET_CURRENT_CONTEXT(ctx);
  5799.    FLUSH_VERTICES(ctx, 0);
  5800.    ctx->Exec->FogCoordPointerEXT( type, stride, ptr);
  5801. }
  5802.  
  5803. /* GL_EXT_multi_draw_arrays */
  5804. static void exec_MultiDrawArraysEXT(GLenum mode, GLint *first,
  5805.                                     GLsizei *count, GLsizei primcount)
  5806. {
  5807.    GET_CURRENT_CONTEXT(ctx);
  5808.    FLUSH_VERTICES(ctx, 0);
  5809.    ctx->Exec->MultiDrawArraysEXT( mode, first, count, primcount );
  5810. }
  5811.  
  5812. /* GL_EXT_multi_draw_arrays */
  5813. static void exec_MultiDrawElementsEXT(GLenum mode, const GLsizei *count,
  5814.                                       GLenum type, const GLvoid **indices,
  5815.                                       GLsizei primcount)
  5816. {
  5817.    GET_CURRENT_CONTEXT(ctx);
  5818.    FLUSH_VERTICES(ctx, 0);
  5819.    ctx->Exec->MultiDrawElementsEXT(mode, count, type, indices, primcount);
  5820. }
  5821.  
  5822.  
  5823.  
  5824. /*
  5825.  * Assign all the pointers in <table> to point to Mesa's display list
  5826.  * building functions.
  5827.  *
  5828.  * This does not include any of the tnl functions - they are
  5829.  * initialized from _mesa_init_api_defaults and from the active vtxfmt
  5830.  * struct.
  5831.  */
  5832. void
  5833. _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
  5834. {
  5835.    _mesa_init_no_op_table(table, tableSize);
  5836.  
  5837.    _mesa_loopback_init_api_table( table, GL_TRUE );
  5838.  
  5839.    /* GL 1.0 */
  5840.    table->Accum = save_Accum;
  5841.    table->AlphaFunc = save_AlphaFunc;
  5842.    table->Bitmap = save_Bitmap;
  5843.    table->BlendFunc = save_BlendFunc;
  5844.    table->CallList = _mesa_save_CallList;
  5845.    table->CallLists = _mesa_save_CallLists;
  5846.    table->Clear = save_Clear;
  5847.    table->ClearAccum = save_ClearAccum;
  5848.    table->ClearColor = save_ClearColor;
  5849.    table->ClearDepth = save_ClearDepth;
  5850.    table->ClearIndex = save_ClearIndex;
  5851.    table->ClearStencil = save_ClearStencil;
  5852.    table->ClipPlane = save_ClipPlane;
  5853.    table->ColorMask = save_ColorMask;
  5854.    table->ColorMaterial = save_ColorMaterial;
  5855.    table->CopyPixels = save_CopyPixels;
  5856.    table->CullFace = save_CullFace;
  5857.    table->DeleteLists = _mesa_DeleteLists;
  5858.    table->DepthFunc = save_DepthFunc;
  5859.    table->DepthMask = save_DepthMask;
  5860.    table->DepthRange = save_DepthRange;
  5861.    table->Disable = save_Disable;
  5862.    table->DrawBuffer = save_DrawBuffer;
  5863.    table->DrawPixels = save_DrawPixels;
  5864.    table->Enable = save_Enable;
  5865.    table->EndList = _mesa_EndList;
  5866.    table->EvalMesh1 = _mesa_save_EvalMesh1;
  5867.    table->EvalMesh2 = _mesa_save_EvalMesh2;
  5868.    table->Finish = exec_Finish;
  5869.    table->Flush = exec_Flush;
  5870.    table->Fogf = save_Fogf;
  5871.    table->Fogfv = save_Fogfv;
  5872.    table->Fogi = save_Fogi;
  5873.    table->Fogiv = save_Fogiv;
  5874.    table->FrontFace = save_FrontFace;
  5875.    table->Frustum = save_Frustum;
  5876.    table->GenLists = _mesa_GenLists;
  5877.    table->GetBooleanv = exec_GetBooleanv;
  5878.    table->GetClipPlane = exec_GetClipPlane;
  5879.    table->GetDoublev = exec_GetDoublev;
  5880.    table->GetError = exec_GetError;
  5881.    table->GetFloatv = exec_GetFloatv;
  5882.    table->GetIntegerv = exec_GetIntegerv;
  5883.    table->GetLightfv = exec_GetLightfv;
  5884.    table->GetLightiv = exec_GetLightiv;
  5885.    table->GetMapdv = exec_GetMapdv;
  5886.    table->GetMapfv = exec_GetMapfv;
  5887.    table->GetMapiv = exec_GetMapiv;
  5888.    table->GetMaterialfv = exec_GetMaterialfv;
  5889.    table->GetMaterialiv = exec_GetMaterialiv;
  5890.    table->GetPixelMapfv = exec_GetPixelMapfv;
  5891.    table->GetPixelMapuiv = exec_GetPixelMapuiv;
  5892.    table->GetPixelMapusv = exec_GetPixelMapusv;
  5893.    table->GetPolygonStipple = exec_GetPolygonStipple;
  5894.    table->GetString = exec_GetString;
  5895.    table->GetTexEnvfv = exec_GetTexEnvfv;
  5896.    table->GetTexEnviv = exec_GetTexEnviv;
  5897.    table->GetTexGendv = exec_GetTexGendv;
  5898.    table->GetTexGenfv = exec_GetTexGenfv;
  5899.    table->GetTexGeniv = exec_GetTexGeniv;
  5900.    table->GetTexImage = exec_GetTexImage;
  5901.    table->GetTexLevelParameterfv = exec_GetTexLevelParameterfv;
  5902.    table->GetTexLevelParameteriv = exec_GetTexLevelParameteriv;
  5903.    table->GetTexParameterfv = exec_GetTexParameterfv;
  5904.    table->GetTexParameteriv = exec_GetTexParameteriv;
  5905.    table->Hint = save_Hint;
  5906.    table->IndexMask = save_IndexMask;
  5907.    table->InitNames = save_InitNames;
  5908.    table->IsEnabled = exec_IsEnabled;
  5909.    table->IsList = _mesa_IsList;
  5910.    table->LightModelf = save_LightModelf;
  5911.    table->LightModelfv = save_LightModelfv;
  5912.    table->LightModeli = save_LightModeli;
  5913.    table->LightModeliv = save_LightModeliv;
  5914.    table->Lightf = save_Lightf;
  5915.    table->Lightfv = save_Lightfv;
  5916.    table->Lighti = save_Lighti;
  5917.    table->Lightiv = save_Lightiv;
  5918.    table->LineStipple = save_LineStipple;
  5919.    table->LineWidth = save_LineWidth;
  5920.    table->ListBase = save_ListBase;
  5921.    table->LoadIdentity = save_LoadIdentity;
  5922.    table->LoadMatrixd = save_LoadMatrixd;
  5923.    table->LoadMatrixf = save_LoadMatrixf;
  5924.    table->LoadName = save_LoadName;
  5925.    table->LogicOp = save_LogicOp;
  5926.    table->Map1d = save_Map1d;
  5927.    table->Map1f = save_Map1f;
  5928.    table->Map2d = save_Map2d;
  5929.    table->Map2f = save_Map2f;
  5930.    table->MapGrid1d = save_MapGrid1d;
  5931.    table->MapGrid1f = save_MapGrid1f;
  5932.    table->MapGrid2d = save_MapGrid2d;
  5933.    table->MapGrid2f = save_MapGrid2f;
  5934.    table->MatrixMode = save_MatrixMode;
  5935.    table->MultMatrixd = save_MultMatrixd;
  5936.    table->MultMatrixf = save_MultMatrixf;
  5937.    table->NewList = save_NewList;
  5938.    table->Ortho = save_Ortho;
  5939.    table->PassThrough = save_PassThrough;
  5940.    table->PixelMapfv = save_PixelMapfv;
  5941.    table->PixelMapuiv = save_PixelMapuiv;
  5942.    table->PixelMapusv = save_PixelMapusv;
  5943.    table->PixelStoref = exec_PixelStoref;
  5944.    table->PixelStorei = exec_PixelStorei;
  5945.    table->PixelTransferf = save_PixelTransferf;
  5946.    table->PixelTransferi = save_PixelTransferi;
  5947.    table->PixelZoom = save_PixelZoom;
  5948.    table->PointSize = save_PointSize;
  5949.    table->PolygonMode = save_PolygonMode;
  5950.    table->PolygonOffset = save_PolygonOffset;
  5951.    table->PolygonStipple = save_PolygonStipple;
  5952.    table->PopAttrib = save_PopAttrib;
  5953.    table->PopMatrix = save_PopMatrix;
  5954.    table->PopName = save_PopName;
  5955.    table->PushAttrib = save_PushAttrib;
  5956.    table->PushMatrix = save_PushMatrix;
  5957.    table->PushName = save_PushName;
  5958.    table->RasterPos2d = save_RasterPos2d;
  5959.    table->RasterPos2dv = save_RasterPos2dv;
  5960.    table->RasterPos2f = save_RasterPos2f;
  5961.    table->RasterPos2fv = save_RasterPos2fv;
  5962.    table->RasterPos2i = save_RasterPos2i;
  5963.    table->RasterPos2iv = save_RasterPos2iv;
  5964.    table->RasterPos2s = save_RasterPos2s;
  5965.    table->RasterPos2sv = save_RasterPos2sv;
  5966.    table->RasterPos3d = save_RasterPos3d;
  5967.    table->RasterPos3dv = save_RasterPos3dv;
  5968.    table->RasterPos3f = save_RasterPos3f;
  5969.    table->RasterPos3fv = save_RasterPos3fv;
  5970.    table->RasterPos3i = save_RasterPos3i;
  5971.    table->RasterPos3iv = save_RasterPos3iv;
  5972.    table->RasterPos3s = save_RasterPos3s;
  5973.    table->RasterPos3sv = save_RasterPos3sv;
  5974.    table->RasterPos4d = save_RasterPos4d;
  5975.    table->RasterPos4dv = save_RasterPos4dv;
  5976.    table->RasterPos4f = save_RasterPos4f;
  5977.    table->RasterPos4fv = save_RasterPos4fv;
  5978.    table->RasterPos4i = save_RasterPos4i;
  5979.    table->RasterPos4iv = save_RasterPos4iv;
  5980.    table->RasterPos4s = save_RasterPos4s;
  5981.    table->RasterPos4sv = save_RasterPos4sv;
  5982.    table->ReadBuffer = save_ReadBuffer;
  5983.    table->ReadPixels = exec_ReadPixels;
  5984.    table->RenderMode = exec_RenderMode;
  5985.    table->Rotated = save_Rotated;
  5986.    table->Rotatef = save_Rotatef;
  5987.    table->Scaled = save_Scaled;
  5988.    table->Scalef = save_Scalef;
  5989.    table->Scissor = save_Scissor;
  5990.    table->FeedbackBuffer = exec_FeedbackBuffer;
  5991.    table->SelectBuffer = exec_SelectBuffer;
  5992.    table->ShadeModel = save_ShadeModel;
  5993.    table->StencilFunc = save_StencilFunc;
  5994.    table->StencilMask = save_StencilMask;
  5995.    table->StencilOp = save_StencilOp;
  5996.    table->TexEnvf = save_TexEnvf;
  5997.    table->TexEnvfv = save_TexEnvfv;
  5998.    table->TexEnvi = save_TexEnvi;
  5999.    table->TexEnviv = save_TexEnviv;
  6000.    table->TexGend = save_TexGend;
  6001.    table->TexGendv = save_TexGendv;
  6002.    table->TexGenf = save_TexGenf;
  6003.    table->TexGenfv = save_TexGenfv;
  6004.    table->TexGeni = save_TexGeni;
  6005.    table->TexGeniv = save_TexGeniv;
  6006.    table->TexImage1D = save_TexImage1D;
  6007.    table->TexImage2D = save_TexImage2D;
  6008.    table->TexParameterf = save_TexParameterf;
  6009.    table->TexParameterfv = save_TexParameterfv;
  6010.    table->TexParameteri = save_TexParameteri;
  6011.    table->TexParameteriv = save_TexParameteriv;
  6012.    table->Translated = save_Translated;
  6013.    table->Translatef = save_Translatef;
  6014.    table->Viewport = save_Viewport;
  6015.  
  6016.    /* GL 1.1 */
  6017.    table->AreTexturesResident = exec_AreTexturesResident;
  6018.    table->AreTexturesResidentEXT = exec_AreTexturesResident;
  6019.    table->BindTexture = save_BindTexture;
  6020.    table->ColorPointer = exec_ColorPointer;
  6021.    table->CopyTexImage1D = save_CopyTexImage1D;
  6022.    table->CopyTexImage2D = save_CopyTexImage2D;
  6023.    table->CopyTexSubImage1D = save_CopyTexSubImage1D;
  6024.    table->CopyTexSubImage2D = save_CopyTexSubImage2D;
  6025.    table->DeleteTextures = exec_DeleteTextures;
  6026.    table->DisableClientState = exec_DisableClientState;
  6027.    table->EdgeFlagPointer = exec_EdgeFlagPointer;
  6028.    table->EnableClientState = exec_EnableClientState;
  6029.    table->GenTextures = exec_GenTextures;
  6030.    table->GenTexturesEXT = exec_GenTextures;
  6031.    table->GetPointerv = exec_GetPointerv;
  6032.    table->IndexPointer = exec_IndexPointer;
  6033.    table->InterleavedArrays = exec_InterleavedArrays;
  6034.    table->IsTexture = exec_IsTexture;
  6035.    table->IsTextureEXT = exec_IsTexture;
  6036.    table->NormalPointer = exec_NormalPointer;
  6037.    table->PopClientAttrib = exec_PopClientAttrib;
  6038.    table->PrioritizeTextures = save_PrioritizeTextures;
  6039.    table->PushClientAttrib = exec_PushClientAttrib;
  6040.    table->TexCoordPointer = exec_TexCoordPointer;
  6041.    table->TexSubImage1D = save_TexSubImage1D;
  6042.    table->TexSubImage2D = save_TexSubImage2D;
  6043.    table->VertexPointer = exec_VertexPointer;
  6044.  
  6045.    /* GL 1.2 */
  6046.    table->CopyTexSubImage3D = save_CopyTexSubImage3D;
  6047.    table->TexImage3D = save_TexImage3D;
  6048.    table->TexSubImage3D = save_TexSubImage3D;
  6049.  
  6050.    /* GL_ARB_imaging */
  6051.    /* Not all are supported */
  6052.    table->BlendColor = save_BlendColor;
  6053.    table->BlendEquation = save_BlendEquation;
  6054.    table->ColorSubTable = save_ColorSubTable;
  6055.    table->ColorTable = save_ColorTable;
  6056.    table->ColorTableParameterfv = save_ColorTableParameterfv;
  6057.    table->ColorTableParameteriv = save_ColorTableParameteriv;
  6058.    table->ConvolutionFilter1D = save_ConvolutionFilter1D;
  6059.    table->ConvolutionFilter2D = save_ConvolutionFilter2D;
  6060.    table->ConvolutionParameterf = save_ConvolutionParameterf;
  6061.    table->ConvolutionParameterfv = save_ConvolutionParameterfv;
  6062.    table->ConvolutionParameteri = save_ConvolutionParameteri;
  6063.    table->ConvolutionParameteriv = save_ConvolutionParameteriv;
  6064.    table->CopyColorSubTable = save_CopyColorSubTable;
  6065.    table->CopyColorTable = save_CopyColorTable;
  6066.    table->CopyConvolutionFilter1D = exec_CopyConvolutionFilter1D;
  6067.    table->CopyConvolutionFilter2D = exec_CopyConvolutionFilter2D;
  6068.    table->GetColorTable = exec_GetColorTable;
  6069.    table->GetColorTableEXT = exec_GetColorTable;
  6070.    table->GetColorTableParameterfv = exec_GetColorTableParameterfv;
  6071.    table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
  6072.    table->GetColorTableParameteriv = exec_GetColorTableParameteriv;
  6073.    table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
  6074.    table->GetConvolutionFilter = exec_GetConvolutionFilter;
  6075.    table->GetConvolutionFilterEXT = exec_GetConvolutionFilter;
  6076.    table->GetConvolutionParameterfv = exec_GetConvolutionParameterfv;
  6077.    table->GetConvolutionParameterfvEXT = exec_GetConvolutionParameterfv;
  6078.    table->GetConvolutionParameteriv = exec_GetConvolutionParameteriv;
  6079.    table->GetConvolutionParameterivEXT = exec_GetConvolutionParameteriv;
  6080.    table->GetHistogram = exec_GetHistogram;
  6081.    table->GetHistogramEXT = exec_GetHistogram;
  6082.    table->GetHistogramParameterfv = exec_GetHistogramParameterfv;
  6083.    table->GetHistogramParameterfvEXT = exec_GetHistogramParameterfv;
  6084.    table->GetHistogramParameteriv = exec_GetHistogramParameteriv;
  6085.    table->GetHistogramParameterivEXT = exec_GetHistogramParameteriv;
  6086.    table->GetMinmax = exec_GetMinmax;
  6087.    table->GetMinmaxEXT = exec_GetMinmax;
  6088.    table->GetMinmaxParameterfv = exec_GetMinmaxParameterfv;
  6089.    table->GetMinmaxParameterfvEXT = exec_GetMinmaxParameterfv;
  6090.    table->GetMinmaxParameteriv = exec_GetMinmaxParameteriv;
  6091.    table->GetMinmaxParameterivEXT = exec_GetMinmaxParameteriv;
  6092.    table->GetSeparableFilter = exec_GetSeparableFilter;
  6093.    table->GetSeparableFilterEXT = exec_GetSeparableFilter;
  6094.    table->Histogram = save_Histogram;
  6095.    table->Minmax = save_Minmax;
  6096.    table->ResetHistogram = save_ResetHistogram;
  6097.    table->ResetMinmax = save_ResetMinmax;
  6098.    table->SeparableFilter2D = exec_SeparableFilter2D;
  6099.  
  6100.    /* 2. GL_EXT_blend_color */
  6101. #if 0
  6102.    table->BlendColorEXT = save_BlendColorEXT;
  6103. #endif
  6104.  
  6105.    /* 3. GL_EXT_polygon_offset */
  6106.    table->PolygonOffsetEXT = save_PolygonOffsetEXT;
  6107.  
  6108.    /* 6. GL_EXT_texture3d */
  6109. #if 0
  6110.    table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
  6111.    table->TexImage3DEXT = save_TexImage3DEXT;
  6112.    table->TexSubImage3DEXT = save_TexSubImage3D;
  6113. #endif
  6114.  
  6115.    /* 15. GL_SGIX_pixel_texture */
  6116.    table->PixelTexGenSGIX = save_PixelTexGenSGIX;
  6117.  
  6118.    /* 15. GL_SGIS_pixel_texture */
  6119.    table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS;
  6120.    table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS;
  6121.    table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS;
  6122.    table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS;
  6123.    table->GetPixelTexGenParameterivSGIS = exec_GetPixelTexGenParameterivSGIS;
  6124.    table->GetPixelTexGenParameterfvSGIS = exec_GetPixelTexGenParameterfvSGIS;
  6125.  
  6126.    /* 30. GL_EXT_vertex_array */
  6127.    table->ColorPointerEXT = exec_ColorPointerEXT;
  6128.    table->EdgeFlagPointerEXT = exec_EdgeFlagPointerEXT;
  6129.    table->IndexPointerEXT = exec_IndexPointerEXT;
  6130.    table->NormalPointerEXT = exec_NormalPointerEXT;
  6131.    table->TexCoordPointerEXT = exec_TexCoordPointerEXT;
  6132.    table->VertexPointerEXT = exec_VertexPointerEXT;
  6133.  
  6134.    /* 37. GL_EXT_blend_minmax */
  6135. #if 0
  6136.    table->BlendEquationEXT = save_BlendEquationEXT;
  6137. #endif
  6138.  
  6139.    /* 54. GL_EXT_point_parameters */
  6140.    table->PointParameterfEXT = save_PointParameterfEXT;
  6141.    table->PointParameterfvEXT = save_PointParameterfvEXT;
  6142.  
  6143.    /* 78. GL_EXT_paletted_texture */
  6144. #if 0
  6145.    table->ColorTableEXT = save_ColorTable;
  6146.    table->ColorSubTableEXT = save_ColorSubTable;
  6147. #endif
  6148.    table->GetColorTableEXT = exec_GetColorTable;
  6149.    table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
  6150.    table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
  6151.  
  6152.    /* 97. GL_EXT_compiled_vertex_array */
  6153.    table->LockArraysEXT = exec_LockArraysEXT;
  6154.    table->UnlockArraysEXT = exec_UnlockArraysEXT;
  6155.  
  6156.    /* 145. GL_EXT_secondary_color */
  6157.    table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
  6158.  
  6159.    /* 148. GL_EXT_multi_draw_arrays */
  6160.    table->MultiDrawArraysEXT = exec_MultiDrawArraysEXT;
  6161.    table->MultiDrawElementsEXT = exec_MultiDrawElementsEXT;
  6162.  
  6163.    /* 149. GL_EXT_fog_coord */
  6164.    table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
  6165.  
  6166.    /* 173. GL_EXT_blend_func_separate */
  6167.    table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
  6168.  
  6169.    /* 196. GL_MESA_resize_buffers */
  6170.    table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
  6171.  
  6172.    /* 197. GL_MESA_window_pos */
  6173.    table->WindowPos2dMESA = save_WindowPos2dMESA;
  6174.    table->WindowPos2dvMESA = save_WindowPos2dvMESA;
  6175.    table->WindowPos2fMESA = save_WindowPos2fMESA;
  6176.    table->WindowPos2fvMESA = save_WindowPos2fvMESA;
  6177.    table->WindowPos2iMESA = save_WindowPos2iMESA;
  6178.    table->WindowPos2ivMESA = save_WindowPos2ivMESA;
  6179.    table->WindowPos2sMESA = save_WindowPos2sMESA;
  6180.    table->WindowPos2svMESA = save_WindowPos2svMESA;
  6181.    table->WindowPos3dMESA = save_WindowPos3dMESA;
  6182.    table->WindowPos3dvMESA = save_WindowPos3dvMESA;
  6183.    table->WindowPos3fMESA = save_WindowPos3fMESA;
  6184.    table->WindowPos3fvMESA = save_WindowPos3fvMESA;
  6185.    table->WindowPos3iMESA = save_WindowPos3iMESA;
  6186.    table->WindowPos3ivMESA = save_WindowPos3ivMESA;
  6187.    table->WindowPos3sMESA = save_WindowPos3sMESA;
  6188.    table->WindowPos3svMESA = save_WindowPos3svMESA;
  6189.    table->WindowPos4dMESA = save_WindowPos4dMESA;
  6190.    table->WindowPos4dvMESA = save_WindowPos4dvMESA;
  6191.    table->WindowPos4fMESA = save_WindowPos4fMESA;
  6192.    table->WindowPos4fvMESA = save_WindowPos4fvMESA;
  6193.    table->WindowPos4iMESA = save_WindowPos4iMESA;
  6194.    table->WindowPos4ivMESA = save_WindowPos4ivMESA;
  6195.    table->WindowPos4sMESA = save_WindowPos4sMESA;
  6196.    table->WindowPos4svMESA = save_WindowPos4svMESA;
  6197.  
  6198. #if FEATURE_NV_vertex_program
  6199.    /* 233. GL_NV_vertex_program */
  6200.    /* The following commands DO NOT go into display lists:
  6201.     * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
  6202.     * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
  6203.     */
  6204.    table->BindProgramNV = save_BindProgramNV;
  6205.    table->DeleteProgramsNV = _mesa_DeleteProgramsNV;
  6206.    table->ExecuteProgramNV = save_ExecuteProgramNV;
  6207.    table->GenProgramsNV = _mesa_GenProgramsNV;
  6208.    table->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
  6209.    table->RequestResidentProgramsNV = _mesa_RequestResidentProgramsNV;
  6210.    table->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV;
  6211.    table->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV;
  6212.    table->GetProgramivNV = _mesa_GetProgramivNV;
  6213.    table->GetProgramStringNV = _mesa_GetProgramStringNV;
  6214.    table->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV;
  6215.    table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
  6216.    table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
  6217.    table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
  6218.    table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
  6219.    table->IsProgramNV = _mesa_IsProgramNV;
  6220.    table->LoadProgramNV = _mesa_LoadProgramNV;
  6221.    table->ProgramParameter4dNV = save_ProgramParameter4dNV;
  6222.    table->ProgramParameter4dvNV = save_ProgramParameter4dvNV;
  6223.    table->ProgramParameter4fNV = save_ProgramParameter4fNV;
  6224.    table->ProgramParameter4fvNV = save_ProgramParameter4fvNV;
  6225.    table->ProgramParameters4dvNV = save_ProgramParameters4dvNV;
  6226.    table->ProgramParameters4fvNV = save_ProgramParameters4fvNV;
  6227.    table->TrackMatrixNV = save_TrackMatrixNV;
  6228.    table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
  6229. #endif
  6230.  
  6231.    /* 262. GL_NV_point_sprite */
  6232.    table->PointParameteriNV = save_PointParameteriNV;
  6233.    table->PointParameterivNV = save_PointParameterivNV;
  6234.  
  6235.    /* 268. GL_EXT_stencil_two_side */
  6236.    table->ActiveStencilFaceEXT = save_ActiveStencilFaceEXT;
  6237.  
  6238.    /* ARB 1. GL_ARB_multitexture */
  6239.    table->ActiveTextureARB = save_ActiveTextureARB;
  6240.    table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
  6241.  
  6242.    /* ARB 3. GL_ARB_transpose_matrix */
  6243.    table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
  6244.    table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
  6245.    table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
  6246.    table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
  6247.  
  6248.    /* ARB 5. GL_ARB_multisample */
  6249.    table->SampleCoverageARB = save_SampleCoverageARB;
  6250.  
  6251.    /* ARB 12. GL_ARB_texture_compression */
  6252.    table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
  6253.    table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
  6254.    table->CompressedTexImage1DARB = save_CompressedTexImage1DARB;
  6255.    table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB;
  6256.    table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB;
  6257.    table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
  6258.    table->GetCompressedTexImageARB = exec_GetCompressedTexImageARB;
  6259.  
  6260.    /* ARB 14. GL_ARB_point_parameters */
  6261.    /* re-use EXT_point_parameters functions */
  6262.  
  6263.    /* ARB 25. GL_ARB_window_pos */
  6264.    /* re-use MESA_window_pos functions */
  6265. }
  6266.  
  6267.  
  6268.  
  6269. /***
  6270.  *** Debugging code
  6271.  ***/
  6272. static const char *enum_string( GLenum k )
  6273. {
  6274.    return _mesa_lookup_enum_by_nr( k );
  6275. }
  6276.  
  6277.  
  6278. /*
  6279.  * Print the commands in a display list.  For debugging only.
  6280.  * TODO: many commands aren't handled yet.
  6281.  */
  6282. static void print_list( GLcontext *ctx, GLuint list )
  6283. {
  6284.    Node *n;
  6285.    GLboolean done;
  6286.  
  6287.    if (!glIsList(list)) {
  6288.       _mesa_printf("%u is not a display list ID\n", list);
  6289.       return;
  6290.    }
  6291.  
  6292.    n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
  6293.  
  6294.    _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
  6295.  
  6296.    done = n ? GL_FALSE : GL_TRUE;
  6297.    while (!done) {
  6298.       OpCode opcode = n[0].opcode;
  6299.       GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
  6300.  
  6301.       if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
  6302.      ctx->listext.opcode[i].print(ctx, &n[1]);
  6303.      n += ctx->listext.opcode[i].size;
  6304.       }
  6305.       else {
  6306.      switch (opcode) {
  6307.          case OPCODE_ACCUM:
  6308.             _mesa_printf("accum %s %g\n", enum_string(n[1].e), n[2].f );
  6309.         break;
  6310.      case OPCODE_BITMAP:
  6311.             _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
  6312.                n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
  6313.         break;
  6314.          case OPCODE_CALL_LIST:
  6315.             _mesa_printf("CallList %d\n", (int) n[1].ui );
  6316.             break;
  6317.          case OPCODE_CALL_LIST_OFFSET:
  6318.             _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
  6319.                     ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
  6320.             break;
  6321.          case OPCODE_COLOR_TABLE_PARAMETER_FV:
  6322.             _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
  6323.                     enum_string(n[1].e), enum_string(n[2].e),
  6324.                     n[3].f, n[4].f, n[5].f, n[6].f);
  6325.             break;
  6326.          case OPCODE_COLOR_TABLE_PARAMETER_IV:
  6327.             _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
  6328.                     enum_string(n[1].e), enum_string(n[2].e),
  6329.                     n[3].i, n[4].i, n[5].i, n[6].i);
  6330.             break;
  6331.      case OPCODE_DISABLE:
  6332.             _mesa_printf("Disable %s\n", enum_string(n[1].e));
  6333.         break;
  6334.      case OPCODE_ENABLE:
  6335.             _mesa_printf("Enable %s\n", enum_string(n[1].e));
  6336.         break;
  6337.          case OPCODE_FRUSTUM:
  6338.             _mesa_printf("Frustum %g %g %g %g %g %g\n",
  6339.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  6340.             break;
  6341.      case OPCODE_LINE_STIPPLE:
  6342.         _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us );
  6343.         break;
  6344.      case OPCODE_LOAD_IDENTITY:
  6345.             _mesa_printf("LoadIdentity\n");
  6346.         break;
  6347.      case OPCODE_LOAD_MATRIX:
  6348.             _mesa_printf("LoadMatrix\n");
  6349.             _mesa_printf("  %8f %8f %8f %8f\n",
  6350.                          n[1].f, n[5].f,  n[9].f, n[13].f);
  6351.             _mesa_printf("  %8f %8f %8f %8f\n",
  6352.                          n[2].f, n[6].f, n[10].f, n[14].f);
  6353.             _mesa_printf("  %8f %8f %8f %8f\n",
  6354.                          n[3].f, n[7].f, n[11].f, n[15].f);
  6355.             _mesa_printf("  %8f %8f %8f %8f\n",
  6356.                          n[4].f, n[8].f, n[12].f, n[16].f);
  6357.         break;
  6358.      case OPCODE_MULT_MATRIX:
  6359.             _mesa_printf("MultMatrix (or Rotate)\n");
  6360.             _mesa_printf("  %8f %8f %8f %8f\n",
  6361.                          n[1].f, n[5].f,  n[9].f, n[13].f);
  6362.             _mesa_printf("  %8f %8f %8f %8f\n",
  6363.                          n[2].f, n[6].f, n[10].f, n[14].f);
  6364.             _mesa_printf("  %8f %8f %8f %8f\n",
  6365.                          n[3].f, n[7].f, n[11].f, n[15].f);
  6366.             _mesa_printf("  %8f %8f %8f %8f\n",
  6367.                          n[4].f, n[8].f, n[12].f, n[16].f);
  6368.         break;
  6369.          case OPCODE_ORTHO:
  6370.             _mesa_printf("Ortho %g %g %g %g %g %g\n",
  6371.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  6372.             break;
  6373.      case OPCODE_POP_ATTRIB:
  6374.             _mesa_printf("PopAttrib\n");
  6375.         break;
  6376.      case OPCODE_POP_MATRIX:
  6377.             _mesa_printf("PopMatrix\n");
  6378.         break;
  6379.      case OPCODE_POP_NAME:
  6380.             _mesa_printf("PopName\n");
  6381.         break;
  6382.      case OPCODE_PUSH_ATTRIB:
  6383.             _mesa_printf("PushAttrib %x\n", n[1].bf );
  6384.         break;
  6385.      case OPCODE_PUSH_MATRIX:
  6386.             _mesa_printf("PushMatrix\n");
  6387.         break;
  6388.      case OPCODE_PUSH_NAME:
  6389.             _mesa_printf("PushName %d\n", (int) n[1].ui );
  6390.         break;
  6391.      case OPCODE_RASTER_POS:
  6392.             _mesa_printf("RasterPos %g %g %g %g\n",
  6393.                          n[1].f, n[2].f,n[3].f,n[4].f);
  6394.         break;
  6395.          case OPCODE_ROTATE:
  6396.             _mesa_printf("Rotate %g %g %g %g\n",
  6397.                          n[1].f, n[2].f, n[3].f, n[4].f );
  6398.             break;
  6399.          case OPCODE_SCALE:
  6400.             _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
  6401.             break;
  6402.          case OPCODE_TRANSLATE:
  6403.             _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
  6404.             break;
  6405.          case OPCODE_BIND_TEXTURE:
  6406.         _mesa_printf("BindTexture %s %d\n",
  6407.                          _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
  6408.         break;
  6409.          case OPCODE_SHADE_MODEL:
  6410.         _mesa_printf("ShadeModel %s\n",
  6411.                          _mesa_lookup_enum_by_nr(n[1].ui));
  6412.         break;
  6413.      case OPCODE_MAP1:
  6414.         _mesa_printf("Map1 %s %.3f %.3f %d %d\n", 
  6415.             _mesa_lookup_enum_by_nr(n[1].ui),
  6416.             n[2].f, n[3].f, n[4].i, n[5].i);
  6417.         break;
  6418.      case OPCODE_MAP2:
  6419.         _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", 
  6420.                          _mesa_lookup_enum_by_nr(n[1].ui),
  6421.                          n[2].f, n[3].f, n[4].f, n[5].f,
  6422.                          n[6].i, n[7].i, n[8].i, n[9].i);
  6423.         break;
  6424.      case OPCODE_MAPGRID1:
  6425.         _mesa_printf("MapGrid1 %d %.3f %.3f\n",
  6426.                          n[1].i, n[2].f, n[3].f);
  6427.         break;
  6428.      case OPCODE_MAPGRID2:
  6429.         _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", 
  6430.                          n[1].i, n[2].f, n[3].f,
  6431.                          n[4].i, n[5].f, n[6].f);
  6432.         break;
  6433.      case OPCODE_EVALMESH1:
  6434.         _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
  6435.         break;
  6436.      case OPCODE_EVALMESH2:
  6437.         _mesa_printf("EvalMesh2 %d %d %d %d\n",
  6438.                          n[1].i, n[2].i, n[3].i, n[4].i);
  6439.         break;
  6440.  
  6441.      /*
  6442.       * meta opcodes/commands
  6443.       */
  6444.          case OPCODE_ERROR:
  6445.             _mesa_printf("Error: %s %s\n",
  6446.                          enum_string(n[1].e), (const char *)n[2].data );
  6447.             break;
  6448.      case OPCODE_CONTINUE:
  6449.             _mesa_printf("DISPLAY-LIST-CONTINUE\n");
  6450.         n = (Node *) n[1].next;
  6451.         break;
  6452.      case OPCODE_END_OF_LIST:
  6453.             _mesa_printf("END-LIST %u\n", list);
  6454.         done = GL_TRUE;
  6455.         break;
  6456.          default:
  6457.             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
  6458.                _mesa_printf("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
  6459.                             opcode, (void*) n);
  6460.                return;
  6461.             }
  6462.             else {
  6463.                _mesa_printf("command %d, %u operands\n", opcode, InstSize[opcode]);
  6464.             }
  6465.      }
  6466.      /* increment n to point to next compiled command */
  6467.      if (opcode!=OPCODE_CONTINUE) {
  6468.         n += InstSize[opcode];
  6469.      }
  6470.       }
  6471.    }
  6472. }
  6473.  
  6474.  
  6475.  
  6476. /*
  6477.  * Clients may call this function to help debug display list problems.
  6478.  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
  6479.  * changed, or break in the future without notice.
  6480.  */
  6481. void mesa_print_display_list( GLuint list )
  6482. {
  6483.    GET_CURRENT_CONTEXT(ctx);
  6484.    print_list( ctx, list );
  6485. }
  6486.