From fbb8c9a149047ccb27e749053c83acf94dedcbf9 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 23 Feb 2011 07:03:24 +0000 Subject: xserver pixman mesa git update 23 Feb 2011 --- mesalib/src/mesa/main/dlist.c | 20662 ++++++++++++----------- mesalib/src/mesa/main/imports.h | 6 + mesalib/src/mesa/vbo/vbo.h | 2 + mesalib/src/mesa/vbo/vbo_exec.h | 9 +- mesalib/src/mesa/vbo/vbo_exec_api.c | 15 +- mesalib/src/mesa/vbo/vbo_exec_array.c | 2631 +-- pixman/Makefile.am | 2 +- pixman/RELEASING | 114 +- pixman/configure.ac | 2 +- pixman/pixman/Makefile.am | 254 +- pixman/pixman/pixman-x64-mmx-emulation.h | 263 - xorg-server/xkeyboard-config/rules/base.xml.in | 11532 ++++++------- 12 files changed, 17628 insertions(+), 17864 deletions(-) delete mode 100644 pixman/pixman/pixman-x64-mmx-emulation.h diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index a6502bbb7..8e904c778 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -1,10330 +1,10332 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file dlist.c - * Display lists management functions. - */ - -#include "glheader.h" -#include "imports.h" -#include "api_arrayelt.h" -#include "api_exec.h" -#include "api_loopback.h" -#if FEATURE_ATI_fragment_shader -#include "atifragshader.h" -#endif -#include "config.h" -#include "mfeatures.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "eval.h" -#include "framebuffer.h" -#include "glapi/glapi.h" -#include "hash.h" -#include "image.h" -#include "light.h" -#include "macros.h" -#include "pack.h" -#include "queryobj.h" -#include "teximage.h" -#include "mtypes.h" -#include "varray.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif - -#include "math/m_matrix.h" - -#include "main/dispatch.h" - - - -/** - * Other parts of Mesa (such as the VBO module) can plug into the display - * list system. This structure describes new display list instructions. - */ -struct gl_list_instruction -{ - GLuint Size; - void (*Execute)( struct gl_context *ctx, void *data ); - void (*Destroy)( struct gl_context *ctx, void *data ); - void (*Print)( struct gl_context *ctx, void *data ); -}; - - -#define MAX_DLIST_EXT_OPCODES 16 - -/** - * Used by device drivers to hook new commands into display lists. - */ -struct gl_list_extensions -{ - struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; - GLuint NumOpcodes; -}; - - - -/** - * Flush vertices. - * - * \param ctx GL context. - * - * Checks if dd_function_table::SaveNeedFlush is marked to flush - * stored (save) vertices, and calls - * dd_function_table::SaveFlushVertices if so. - */ -#define SAVE_FLUSH_VERTICES(ctx) \ -do { \ - if (ctx->Driver.SaveNeedFlush) \ - ctx->Driver.SaveFlushVertices(ctx); \ -} while (0) - - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - - - -/** - * Display list opcodes. - * - * The fact that these identifiers are assigned consecutive - * integer values starting at 0 is very important, see InstSize array usage) - */ -typedef enum -{ - OPCODE_INVALID = -1, /* Force signed enum */ - OPCODE_ACCUM, - OPCODE_ALPHA_FUNC, - OPCODE_BIND_TEXTURE, - OPCODE_BITMAP, - OPCODE_BLEND_COLOR, - OPCODE_BLEND_EQUATION, - OPCODE_BLEND_EQUATION_SEPARATE, - OPCODE_BLEND_FUNC_SEPARATE, - - OPCODE_BLEND_EQUATION_I, - OPCODE_BLEND_EQUATION_SEPARATE_I, - OPCODE_BLEND_FUNC_I, - OPCODE_BLEND_FUNC_SEPARATE_I, - - OPCODE_CALL_LIST, - OPCODE_CALL_LIST_OFFSET, - OPCODE_CLEAR, - OPCODE_CLEAR_ACCUM, - OPCODE_CLEAR_COLOR, - OPCODE_CLEAR_DEPTH, - OPCODE_CLEAR_INDEX, - OPCODE_CLEAR_STENCIL, - OPCODE_CLEAR_BUFFER_IV, - OPCODE_CLEAR_BUFFER_UIV, - OPCODE_CLEAR_BUFFER_FV, - OPCODE_CLEAR_BUFFER_FI, - OPCODE_CLIP_PLANE, - OPCODE_COLOR_MASK, - OPCODE_COLOR_MASK_INDEXED, - OPCODE_COLOR_MATERIAL, - OPCODE_COLOR_TABLE, - OPCODE_COLOR_TABLE_PARAMETER_FV, - OPCODE_COLOR_TABLE_PARAMETER_IV, - OPCODE_COLOR_SUB_TABLE, - OPCODE_CONVOLUTION_FILTER_1D, - OPCODE_CONVOLUTION_FILTER_2D, - OPCODE_CONVOLUTION_PARAMETER_I, - OPCODE_CONVOLUTION_PARAMETER_IV, - OPCODE_CONVOLUTION_PARAMETER_F, - OPCODE_CONVOLUTION_PARAMETER_FV, - OPCODE_COPY_COLOR_SUB_TABLE, - OPCODE_COPY_COLOR_TABLE, - OPCODE_COPY_PIXELS, - OPCODE_COPY_TEX_IMAGE1D, - OPCODE_COPY_TEX_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE1D, - OPCODE_COPY_TEX_SUB_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE3D, - OPCODE_CULL_FACE, - OPCODE_DEPTH_FUNC, - OPCODE_DEPTH_MASK, - OPCODE_DEPTH_RANGE, - OPCODE_DISABLE, - OPCODE_DISABLE_INDEXED, - OPCODE_DRAW_BUFFER, - OPCODE_DRAW_PIXELS, - OPCODE_ENABLE, - OPCODE_ENABLE_INDEXED, - OPCODE_EVALMESH1, - OPCODE_EVALMESH2, - OPCODE_FOG, - OPCODE_FRONT_FACE, - OPCODE_FRUSTUM, - OPCODE_HINT, - OPCODE_HISTOGRAM, - OPCODE_INDEX_MASK, - OPCODE_INIT_NAMES, - OPCODE_LIGHT, - OPCODE_LIGHT_MODEL, - OPCODE_LINE_STIPPLE, - OPCODE_LINE_WIDTH, - OPCODE_LIST_BASE, - OPCODE_LOAD_IDENTITY, - OPCODE_LOAD_MATRIX, - OPCODE_LOAD_NAME, - OPCODE_LOGIC_OP, - OPCODE_MAP1, - OPCODE_MAP2, - OPCODE_MAPGRID1, - OPCODE_MAPGRID2, - OPCODE_MATRIX_MODE, - OPCODE_MIN_MAX, - OPCODE_MULT_MATRIX, - OPCODE_ORTHO, - OPCODE_PASSTHROUGH, - OPCODE_PIXEL_MAP, - OPCODE_PIXEL_TRANSFER, - OPCODE_PIXEL_ZOOM, - OPCODE_POINT_SIZE, - OPCODE_POINT_PARAMETERS, - OPCODE_POLYGON_MODE, - OPCODE_POLYGON_STIPPLE, - OPCODE_POLYGON_OFFSET, - OPCODE_POP_ATTRIB, - OPCODE_POP_MATRIX, - OPCODE_POP_NAME, - OPCODE_PRIORITIZE_TEXTURE, - OPCODE_PUSH_ATTRIB, - OPCODE_PUSH_MATRIX, - OPCODE_PUSH_NAME, - OPCODE_RASTER_POS, - OPCODE_READ_BUFFER, - OPCODE_RESET_HISTOGRAM, - OPCODE_RESET_MIN_MAX, - OPCODE_ROTATE, - OPCODE_SCALE, - OPCODE_SCISSOR, - OPCODE_SELECT_TEXTURE_SGIS, - OPCODE_SELECT_TEXTURE_COORD_SET, - OPCODE_SHADE_MODEL, - OPCODE_STENCIL_FUNC, - OPCODE_STENCIL_MASK, - OPCODE_STENCIL_OP, - OPCODE_TEXENV, - OPCODE_TEXGEN, - OPCODE_TEXPARAMETER, - OPCODE_TEX_IMAGE1D, - OPCODE_TEX_IMAGE2D, - OPCODE_TEX_IMAGE3D, - OPCODE_TEX_SUB_IMAGE1D, - OPCODE_TEX_SUB_IMAGE2D, - OPCODE_TEX_SUB_IMAGE3D, - OPCODE_TRANSLATE, - OPCODE_VIEWPORT, - OPCODE_WINDOW_POS, - /* GL_ARB_multitexture */ - OPCODE_ACTIVE_TEXTURE, - /* GL_ARB_texture_compression */ - OPCODE_COMPRESSED_TEX_IMAGE_1D, - OPCODE_COMPRESSED_TEX_IMAGE_2D, - OPCODE_COMPRESSED_TEX_IMAGE_3D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, - /* GL_ARB_multisample */ - OPCODE_SAMPLE_COVERAGE, - /* GL_ARB_window_pos */ - OPCODE_WINDOW_POS_ARB, - /* GL_NV_vertex_program */ - OPCODE_BIND_PROGRAM_NV, - OPCODE_EXECUTE_PROGRAM_NV, - OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, - OPCODE_LOAD_PROGRAM_NV, - OPCODE_TRACK_MATRIX_NV, - /* GL_NV_fragment_program */ - OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, - OPCODE_PROGRAM_NAMED_PARAMETER_NV, - /* GL_EXT_stencil_two_side */ - OPCODE_ACTIVE_STENCIL_FACE_EXT, - /* GL_EXT_depth_bounds_test */ - OPCODE_DEPTH_BOUNDS_EXT, - /* GL_ARB_vertex/fragment_program */ - OPCODE_PROGRAM_STRING_ARB, - OPCODE_PROGRAM_ENV_PARAMETER_ARB, - /* GL_ARB_occlusion_query */ - OPCODE_BEGIN_QUERY_ARB, - OPCODE_END_QUERY_ARB, - /* GL_ARB_draw_buffers */ - OPCODE_DRAW_BUFFERS_ARB, - /* GL_ATI_fragment_shader */ - OPCODE_TEX_BUMP_PARAMETER_ATI, - /* GL_ATI_fragment_shader */ - OPCODE_BIND_FRAGMENT_SHADER_ATI, - OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, - /* OpenGL 2.0 */ - OPCODE_STENCIL_FUNC_SEPARATE, - OPCODE_STENCIL_OP_SEPARATE, - OPCODE_STENCIL_MASK_SEPARATE, - - /* GL_ARB_shader_objects */ - OPCODE_USE_PROGRAM, - OPCODE_UNIFORM_1F, - OPCODE_UNIFORM_2F, - OPCODE_UNIFORM_3F, - OPCODE_UNIFORM_4F, - OPCODE_UNIFORM_1FV, - OPCODE_UNIFORM_2FV, - OPCODE_UNIFORM_3FV, - OPCODE_UNIFORM_4FV, - OPCODE_UNIFORM_1I, - OPCODE_UNIFORM_2I, - OPCODE_UNIFORM_3I, - OPCODE_UNIFORM_4I, - OPCODE_UNIFORM_1IV, - OPCODE_UNIFORM_2IV, - OPCODE_UNIFORM_3IV, - OPCODE_UNIFORM_4IV, - OPCODE_UNIFORM_MATRIX22, - OPCODE_UNIFORM_MATRIX33, - OPCODE_UNIFORM_MATRIX44, - OPCODE_UNIFORM_MATRIX23, - OPCODE_UNIFORM_MATRIX32, - OPCODE_UNIFORM_MATRIX24, - OPCODE_UNIFORM_MATRIX42, - OPCODE_UNIFORM_MATRIX34, - OPCODE_UNIFORM_MATRIX43, - - /* OpenGL 3.0 */ - OPCODE_UNIFORM_1UI, - OPCODE_UNIFORM_2UI, - OPCODE_UNIFORM_3UI, - OPCODE_UNIFORM_4UI, - OPCODE_UNIFORM_1UIV, - OPCODE_UNIFORM_2UIV, - OPCODE_UNIFORM_3UIV, - OPCODE_UNIFORM_4UIV, - - /* GL_EXT_framebuffer_blit */ - OPCODE_BLIT_FRAMEBUFFER, - - /* Vertex attributes -- fallback for when optimized display - * list build isn't active. - */ - OPCODE_ATTR_1F_NV, - OPCODE_ATTR_2F_NV, - OPCODE_ATTR_3F_NV, - OPCODE_ATTR_4F_NV, - OPCODE_ATTR_1F_ARB, - OPCODE_ATTR_2F_ARB, - OPCODE_ATTR_3F_ARB, - OPCODE_ATTR_4F_ARB, - OPCODE_MATERIAL, - OPCODE_BEGIN, - OPCODE_END, - OPCODE_RECTF, - OPCODE_EVAL_C1, - OPCODE_EVAL_C2, - OPCODE_EVAL_P1, - OPCODE_EVAL_P2, - - /* GL_EXT_provoking_vertex */ - OPCODE_PROVOKING_VERTEX, - - /* GL_EXT_transform_feedback */ - OPCODE_BEGIN_TRANSFORM_FEEDBACK, - OPCODE_END_TRANSFORM_FEEDBACK, - - /* GL_EXT_texture_integer */ - OPCODE_CLEARCOLOR_I, - OPCODE_CLEARCOLOR_UI, - OPCODE_TEXPARAMETER_I, - OPCODE_TEXPARAMETER_UI, - - /* GL_EXT_separate_shader_objects */ - OPCODE_ACTIVE_PROGRAM_EXT, - OPCODE_USE_SHADER_PROGRAM_EXT, - - /* GL_ARB_instanced_arrays */ - OPCODE_VERTEX_ATTRIB_DIVISOR, - - /* The following three are meta instructions */ - OPCODE_ERROR, /* raise compiled-in error */ - OPCODE_CONTINUE, - OPCODE_END_OF_LIST, - OPCODE_EXT_0 -} OpCode; - - - -/** - * Display list node. - * - * Display list instructions are stored as sequences of "nodes". Nodes - * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks - * are linked together with a pointer. - * - * Each instruction in the display list is stored as a sequence of - * contiguous nodes in memory. - * Each node is the union of a variety of data types. - */ -union gl_dlist_node -{ - OpCode opcode; - GLboolean b; - GLbitfield bf; - GLubyte ub; - GLshort s; - GLushort us; - GLint i; - GLuint ui; - GLenum e; - GLfloat f; - GLvoid *data; - void *next; /* If prev node's opcode==OPCODE_CONTINUE */ -}; - - -typedef union gl_dlist_node Node; - - -/** - * How many nodes to allocate at a time. - * - * \note Reduced now that we hold vertices etc. elsewhere. - */ -#define BLOCK_SIZE 256 - - - -/** - * Number of nodes of storage needed for each instruction. - * Sizes for dynamically allocated opcodes are stored in the context struct. - */ -static GLuint InstSize[OPCODE_END_OF_LIST + 1]; - - -#if FEATURE_dlist - - -void mesa_print_display_list(GLuint list); - - -/**********************************************************************/ -/***** Private *****/ -/**********************************************************************/ - - -/** - * Make an empty display list. This is used by glGenLists() to - * reserve display list IDs. - */ -static struct gl_display_list * -make_list(GLuint name, GLuint count) -{ - struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); - dlist->Name = name; - dlist->Head = (Node *) malloc(sizeof(Node) * count); - dlist->Head[0].opcode = OPCODE_END_OF_LIST; - return dlist; -} - - -/** - * Lookup function to just encapsulate casting. - */ -static INLINE struct gl_display_list * -lookup_list(struct gl_context *ctx, GLuint list) -{ - return (struct gl_display_list *) - _mesa_HashLookup(ctx->Shared->DisplayList, list); -} - - -/** Is the given opcode an extension code? */ -static INLINE GLboolean -is_ext_opcode(OpCode opcode) -{ - return (opcode >= OPCODE_EXT_0); -} - - -/** Destroy an extended opcode instruction */ -static GLint -ext_opcode_destroy(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Execute an extended opcode instruction */ -static GLint -ext_opcode_execute(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Print an extended opcode instruction */ -static GLint -ext_opcode_print(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** - * Delete the named display list, but don't remove from hash table. - * \param dlist - display list pointer - */ -void -_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) -{ - Node *n, *block; - GLboolean done; - - n = block = dlist->Head; - - done = block ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - /* check for extension opcodes first */ - if (is_ext_opcode(opcode)) { - n += ext_opcode_destroy(ctx, n); - } - else { - switch (opcode) { - /* for some commands, we need to free malloc'd memory */ - case OPCODE_MAP1: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_MAP2: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_DRAW_PIXELS: - free(n[5].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_BITMAP: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_SUB_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_1D: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_2D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_POLYGON_STIPPLE: - free(n[1].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE1D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE3D: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_2D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_3D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; -#if FEATURE_NV_vertex_program - case OPCODE_LOAD_PROGRAM_NV: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - free(n[2].data); /* array of program ids */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - free(n[3].data); /* parameter name */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; -#endif - case OPCODE_UNIFORM_1FV: - case OPCODE_UNIFORM_2FV: - case OPCODE_UNIFORM_3FV: - case OPCODE_UNIFORM_4FV: - case OPCODE_UNIFORM_1IV: - case OPCODE_UNIFORM_2IV: - case OPCODE_UNIFORM_3IV: - case OPCODE_UNIFORM_4IV: - case OPCODE_UNIFORM_1UIV: - case OPCODE_UNIFORM_2UIV: - case OPCODE_UNIFORM_3UIV: - case OPCODE_UNIFORM_4UIV: - free(n[3].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_UNIFORM_MATRIX22: - case OPCODE_UNIFORM_MATRIX33: - case OPCODE_UNIFORM_MATRIX44: - case OPCODE_UNIFORM_MATRIX24: - case OPCODE_UNIFORM_MATRIX42: - case OPCODE_UNIFORM_MATRIX23: - case OPCODE_UNIFORM_MATRIX32: - case OPCODE_UNIFORM_MATRIX34: - case OPCODE_UNIFORM_MATRIX43: - free(n[4].data); - n += InstSize[n[0].opcode]; - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - free(block); - block = n; - break; - case OPCODE_END_OF_LIST: - free(block); - done = GL_TRUE; - break; - default: - /* Most frequent case */ - n += InstSize[n[0].opcode]; - break; - } - } - } - - free(dlist); -} - - -/** - * Destroy a display list and remove from hash table. - * \param list - display list number - */ -static void -destroy_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - - if (list == 0) - return; - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - _mesa_delete_list(ctx, dlist); - _mesa_HashRemove(ctx->Shared->DisplayList, list); -} - - -/* - * Translate the nth element of list from to GLint. - */ -static GLint -translate_id(GLsizei n, GLenum type, const GLvoid * list) -{ - GLbyte *bptr; - GLubyte *ubptr; - GLshort *sptr; - GLushort *usptr; - GLint *iptr; - GLuint *uiptr; - GLfloat *fptr; - - switch (type) { - case GL_BYTE: - bptr = (GLbyte *) list; - return (GLint) bptr[n]; - case GL_UNSIGNED_BYTE: - ubptr = (GLubyte *) list; - return (GLint) ubptr[n]; - case GL_SHORT: - sptr = (GLshort *) list; - return (GLint) sptr[n]; - case GL_UNSIGNED_SHORT: - usptr = (GLushort *) list; - return (GLint) usptr[n]; - case GL_INT: - iptr = (GLint *) list; - return iptr[n]; - case GL_UNSIGNED_INT: - uiptr = (GLuint *) list; - return (GLint) uiptr[n]; - case GL_FLOAT: - fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); - case GL_2_BYTES: - ubptr = ((GLubyte *) list) + 2 * n; - return (GLint) ubptr[0] * 256 - + (GLint) ubptr[1]; - case GL_3_BYTES: - ubptr = ((GLubyte *) list) + 3 * n; - return (GLint) ubptr[0] * 65536 - + (GLint) ubptr[1] * 256 - + (GLint) ubptr[2]; - case GL_4_BYTES: - ubptr = ((GLubyte *) list) + 4 * n; - return (GLint) ubptr[0] * 16777216 - + (GLint) ubptr[1] * 65536 - + (GLint) ubptr[2] * 256 - + (GLint) ubptr[3]; - default: - return 0; - } -} - - - - -/**********************************************************************/ -/***** Public *****/ -/**********************************************************************/ - -/** - * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. - * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. - */ -static GLvoid * -unpack_image(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *unpack) -{ - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); - if (pixels && !image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, pixels)) { - const GLubyte *map, *src; - GLvoid *image; - - map = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); - if (!map) { - /* unable to map src buffer! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); - return NULL; - } - - src = ADD_POINTERS(map, pixels); - image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, src, unpack); - - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - /* bad access! */ - return NULL; -} - - -/** - * Allocate space for a display list instruction (opcode + payload space). - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction payload size (not counting opcode) - * \return pointer to allocated memory (the opcode space) - */ -static Node * -dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) -{ - const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); - Node *n; - - if (opcode < (GLuint) OPCODE_EXT_0) { - if (InstSize[opcode] == 0) { - /* save instruction size now */ - InstSize[opcode] = numNodes; - } - else { - /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); - } - } - - if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { - /* This block is full. Allocate a new block and chain to it */ - Node *newblock; - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - n[0].opcode = OPCODE_CONTINUE; - newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); - if (!newblock) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); - return NULL; - } - n[1].next = (Node *) newblock; - ctx->ListState.CurrentBlock = newblock; - ctx->ListState.CurrentPos = 0; - } - - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - ctx->ListState.CurrentPos += numNodes; - - n[0].opcode = opcode; - - return n; -} - - - -/** - * Allocate space for a display list instruction. Used by callers outside - * this file for things like VBO vertex data. - * - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction size in bytes, not counting opcode. - * \return pointer to the usable data area (not including the internal - * opcode). - */ -void * -_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) -{ - Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); - if (n) - return n + 1; /* return pointer to payload area, after opcode */ - else - return NULL; -} - - -/** - * This function allows modules and drivers to get their own opcodes - * for extending display list functionality. - * \param ctx the rendering context - * \param size number of bytes for storing the new display list command - * \param execute function to execute the new display list command - * \param destroy function to destroy the new display list command - * \param print function to print the new display list command - * \return the new opcode number or -1 if error - */ -GLint -_mesa_dlist_alloc_opcode(struct gl_context *ctx, - GLuint size, - void (*execute) (struct gl_context *, void *), - void (*destroy) (struct gl_context *, void *), - void (*print) (struct gl_context *, void *)) -{ - if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { - const GLuint i = ctx->ListExt->NumOpcodes++; - ctx->ListExt->Opcode[i].Size = - 1 + (size + sizeof(Node) - 1) / sizeof(Node); - ctx->ListExt->Opcode[i].Execute = execute; - ctx->ListExt->Opcode[i].Destroy = destroy; - ctx->ListExt->Opcode[i].Print = print; - return i + OPCODE_EXT_0; - } - return -1; -} - - -/** - * Allocate space for a display list instruction. The space is basically - * an array of Nodes where node[0] holds the opcode, node[1] is the first - * function parameter, node[2] is the second parameter, etc. - * - * \param opcode one of OPCODE_x - * \param nparams number of function parameters - * \return pointer to start of instruction space - */ -static INLINE Node * -alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) -{ - return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); -} - - - -/* - * Display List compilation functions - */ -static void GLAPIENTRY -save_Accum(GLenum op, GLfloat value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACCUM, 2); - if (n) { - n[1].e = op; - n[2].f = value; - } - if (ctx->ExecuteFlag) { - CALL_Accum(ctx->Exec, (op, value)); - } -} - - -static void GLAPIENTRY -save_AlphaFunc(GLenum func, GLclampf ref) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); - if (n) { - n[1].e = func; - n[2].f = (GLfloat) ref; - } - if (ctx->ExecuteFlag) { - CALL_AlphaFunc(ctx->Exec, (func, ref)); - } -} - - -static void GLAPIENTRY -save_BindTexture(GLenum target, GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); - if (n) { - n[1].e = target; - n[2].ui = texture; - } - if (ctx->ExecuteFlag) { - CALL_BindTexture(ctx->Exec, (target, texture)); - } -} - - -static void GLAPIENTRY -save_Bitmap(GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, const GLubyte * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BITMAP, 7); - if (n) { - n[1].i = (GLint) width; - n[2].i = (GLint) height; - n[3].f = xorig; - n[4].f = yorig; - n[5].f = xmove; - n[6].f = ymove; - n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_Bitmap(ctx->Exec, (width, height, - xorig, yorig, xmove, ymove, pixels)); - } -} - - -static void GLAPIENTRY -save_BlendEquation(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquation(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); - if (n) { - n[1].e = modeRGB; - n[2].e = modeA; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); - } -} - - -static void GLAPIENTRY -save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); - if (n) { - n[1].e = sfactorRGB; - n[2].e = dfactorRGB; - n[3].e = sfactorA; - n[4].e = dfactorA; - } - if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateEXT(ctx->Exec, - (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); - } -} - - -static void GLAPIENTRY -save_BlendFunc(GLenum srcfactor, GLenum dstfactor) -{ - save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); -} - - -static void GLAPIENTRY -save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5); - if (n) { - n[1].ui = buf; - n[2].e = sfactorRGB; - n[3].e = dfactorRGB; - n[4].e = sfactorA; - n[5].e = dfactorA; - } - if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB, - sfactorA, dfactorA)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3); - if (n) { - n[1].ui = buf; - n[2].e = sfactor; - n[3].e = dfactor; - } - if (ctx->ExecuteFlag) { - CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendEquationi(GLuint buf, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2); - if (n) { - n[1].ui = buf; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationiARB(ctx->Exec, (buf, mode)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3); - if (n) { - n[1].ui = buf; - n[2].e = modeRGB; - n[3].e = modeA; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA)); - } -} - - -static void invalidate_saved_current_state( struct gl_context *ctx ) -{ - GLint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - ctx->ListState.ActiveAttribSize[i] = 0; - - for (i = 0; i < MAT_ATTRIB_MAX; i++) - ctx->ListState.ActiveMaterialSize[i] = 0; - - memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - -static void GLAPIENTRY -save_CallList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); - if (n) { - n[1].ui = list; - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - _mesa_CallList(list); - } -} - - -static void GLAPIENTRY -save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean typeErrorFlag; - - SAVE_FLUSH_VERTICES(ctx); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - typeErrorFlag = GL_FALSE; - break; - default: - typeErrorFlag = GL_TRUE; - } - - for (i = 0; i < num; i++) { - GLint list = translate_id(i, type, lists); - Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); - if (n) { - n[1].i = list; - n[2].b = typeErrorFlag; - } - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - CALL_CallLists(ctx->Exec, (num, type, lists)); - } -} - - -static void GLAPIENTRY -save_Clear(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_Clear(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].i = value[0]; - if (buffer == GL_COLOR) { - n[4].i = value[1]; - n[5].i = value[2]; - n[6].i = value[3]; - } - else { - n[4].i = 0; - n[5].i = 0; - n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].ui = value[0]; - if (buffer == GL_COLOR) { - n[4].ui = value[1]; - n[5].ui = value[2]; - n[6].ui = value[3]; - } - else { - n[4].ui = 0; - n[5].ui = 0; - n[6].ui = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = value[0]; - if (buffer == GL_COLOR) { - n[4].f = value[1]; - n[5].f = value[2]; - n[6].f = value[3]; - } - else { - n[4].f = 0.0F; - n[5].f = 0.0F; - n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = depth; - n[4].i = stencil; - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ - } -} - - -static void GLAPIENTRY -save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearDepth(GLclampd depth) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); - if (n) { - n[1].f = (GLfloat) depth; - } - if (ctx->ExecuteFlag) { - CALL_ClearDepth(ctx->Exec, (depth)); - } -} - - -static void GLAPIENTRY -save_ClearIndex(GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); - if (n) { - n[1].f = c; - } - if (ctx->ExecuteFlag) { - CALL_ClearIndex(ctx->Exec, (c)); - } -} - - -static void GLAPIENTRY -save_ClearStencil(GLint s) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); - if (n) { - n[1].i = s; - } - if (ctx->ExecuteFlag) { - CALL_ClearStencil(ctx->Exec, (s)); - } -} - - -static void GLAPIENTRY -save_ClipPlane(GLenum plane, const GLdouble * equ) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); - if (n) { - n[1].e = plane; - n[2].f = (GLfloat) equ[0]; - n[3].f = (GLfloat) equ[1]; - n[4].f = (GLfloat) equ[2]; - n[5].f = (GLfloat) equ[3]; - } - if (ctx->ExecuteFlag) { - CALL_ClipPlane(ctx->Exec, (plane, equ)); - } -} - - - -static void GLAPIENTRY -save_ColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); - if (n) { - n[1].b = red; - n[2].b = green; - n[3].b = blue; - n[4].b = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); - if (n) { - n[1].ui = buf; - n[2].b = red; - n[3].b = green; - n[4].b = blue; - n[5].b = alpha; - } - if (ctx->ExecuteFlag) { - /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ - } -} - - -static void GLAPIENTRY -save_ColorMaterial(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ColorMaterial(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_ColorTable(GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - if (_mesa_is_proxy_texture(target)) { - /* execute immediately */ - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - } -} - - - -static void GLAPIENTRY -save_ColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); - } -} - - - -static void GLAPIENTRY -save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = count; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorSubTable(ctx->Exec, - (target, start, count, format, type, table)); - } -} - - -static void GLAPIENTRY -save_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyColorTable(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); - if (n) { - n[1].e = target; - n[2].e = internalformat; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, - GLenum format, GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, - format, type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].i = height; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - else { - n[4].i = n[5].i = n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - n[5].e = type; - } - if (ctx->ExecuteFlag) { - CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); - } -} - - - -static void GLAPIENTRY -save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, - x, y, width, border)); - } -} - - -static void GLAPIENTRY -save_CopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = height; - n[8].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, - x, y, width, height, border)); - } -} - - - -static void GLAPIENTRY -save_CopyTexSubImage1D(GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = x; - n[5].i = y; - n[6].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage1D(ctx->Exec, - (target, level, xoffset, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = x; - n[6].i = y; - n[7].i = width; - n[8].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = x; - n[7].i = y; - n[8].i = width; - n[9].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CullFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_CullFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DepthFunc(GLenum func) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); - if (n) { - n[1].e = func; - } - if (ctx->ExecuteFlag) { - CALL_DepthFunc(ctx->Exec, (func)); - } -} - - -static void GLAPIENTRY -save_DepthMask(GLboolean mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); - if (n) { - n[1].b = mask; - } - if (ctx->ExecuteFlag) { - CALL_DepthMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); - if (n) { - n[1].f = (GLfloat) nearval; - n[2].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_DepthRange(ctx->Exec, (nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Disable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Disable(ctx->Exec, (cap)); - } -} - - -static void GLAPIENTRY -save_DisableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - -static void GLAPIENTRY -save_DrawBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DrawPixels(GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); - if (n) { - n[1].i = width; - n[2].i = height; - n[3].e = format; - n[4].e = type; - n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); - } -} - - - -static void GLAPIENTRY -save_Enable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Enable(ctx->Exec, (cap)); - } -} - - - -static void GLAPIENTRY -save_EnableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - - -static void GLAPIENTRY -save_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); - } -} - - -static void GLAPIENTRY -save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - n[4].i = j1; - n[5].i = j2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); - } -} - - - - -static void GLAPIENTRY -save_Fogfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FOG, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_Fogfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_Fogf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Fogfv(pname, parray); -} - - -static void GLAPIENTRY -save_Fogiv(GLenum pname, const GLint *params) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - p[0] = (GLfloat) *params; - p[1] = 0.0f; - p[2] = 0.0f; - p[3] = 0.0f; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT(params[0]); - p[1] = INT_TO_FLOAT(params[1]); - p[2] = INT_TO_FLOAT(params[2]); - p[3] = INT_TO_FLOAT(params[3]); - break; - default: - /* Error will be caught later in gl_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_Fogfv(pname, p); -} - - -static void GLAPIENTRY -save_Fogi(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Fogiv(pname, parray); -} - - -static void GLAPIENTRY -save_FrontFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_FrontFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Frustum(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Hint(GLenum target, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HINT, 2); - if (n) { - n[1].e = target; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_Hint(ctx->Exec, (target, mode)); - } -} - - -static void GLAPIENTRY -save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, - GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); - if (n) { - n[1].e = target; - n[2].i = width; - n[3].e = internalFormat; - n[4].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_IndexMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_IndexMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_InitNames(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); - if (ctx->ExecuteFlag) { - CALL_InitNames(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT, 6); - if (n) { - GLint i, nParams; - n[1].e = light; - n[2].e = pname; - switch (pname) { - case GL_AMBIENT: - nParams = 4; - break; - case GL_DIFFUSE: - nParams = 4; - break; - case GL_SPECULAR: - nParams = 4; - break; - case GL_POSITION: - nParams = 4; - break; - case GL_SPOT_DIRECTION: - nParams = 3; - break; - case GL_SPOT_EXPONENT: - nParams = 1; - break; - case GL_SPOT_CUTOFF: - nParams = 1; - break; - case GL_CONSTANT_ATTENUATION: - nParams = 1; - break; - case GL_LINEAR_ATTENUATION: - nParams = 1; - break; - case GL_QUADRATIC_ATTENUATION: - nParams = 1; - break; - default: - nParams = 0; - } - for (i = 0; i < nParams; i++) { - n[3 + i].f = params[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_Lightfv(ctx->Exec, (light, pname, params)); - } -} - - -static void GLAPIENTRY -save_Lightf(GLenum light, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Lightfv(light, pname, parray); -} - - -static void GLAPIENTRY -save_Lightiv(GLenum light, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - save_Lightfv(light, pname, fparam); -} - - -static void GLAPIENTRY -save_Lighti(GLenum light, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Lightiv(light, pname, parray); -} - - -static void GLAPIENTRY -save_LightModelfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_LightModelfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_LightModelf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_LightModelfv(pname, parray); -} - - -static void GLAPIENTRY -save_LightModeliv(GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - fparam[1] = 0.0F; - fparam[2] = 0.0F; - fparam[3] = 0.0F; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_LightModelfv(pname, fparam); -} - - -static void GLAPIENTRY -save_LightModeli(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_LightModeliv(pname, parray); -} - - -static void GLAPIENTRY -save_LineStipple(GLint factor, GLushort pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); - if (n) { - n[1].i = factor; - n[2].us = pattern; - } - if (ctx->ExecuteFlag) { - CALL_LineStipple(ctx->Exec, (factor, pattern)); - } -} - - -static void GLAPIENTRY -save_LineWidth(GLfloat width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); - if (n) { - n[1].f = width; - } - if (ctx->ExecuteFlag) { - CALL_LineWidth(ctx->Exec, (width)); - } -} - - -static void GLAPIENTRY -save_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); - if (n) { - n[1].ui = base; - } - if (ctx->ExecuteFlag) { - CALL_ListBase(ctx->Exec, (base)); - } -} - - -static void GLAPIENTRY -save_LoadIdentity(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); - if (ctx->ExecuteFlag) { - CALL_LoadIdentity(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_LoadMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_LoadMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_LoadMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_LoadMatrixf(f); -} - - -static void GLAPIENTRY -save_LoadName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_LoadName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_LogicOp(GLenum opcode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); - if (n) { - n[1].e = opcode; - } - if (ctx->ExecuteFlag) { - CALL_LogicOp(ctx->Exec, (opcode)); - } -} - - -static void GLAPIENTRY -save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - -static void GLAPIENTRY -save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - - -static void GLAPIENTRY -save_Map2d(GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].f = (GLfloat) v1; - n[5].f = (GLfloat) v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2d(ctx->Exec, (target, - u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_Map2f(GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].f = v1; - n[5].f = v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); - } -} - - -static void GLAPIENTRY -save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) -{ - save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); -} - - -static void GLAPIENTRY -save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - n[4].i = vn; - n[5].f = v1; - n[6].f = v2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); - } -} - - - -static void GLAPIENTRY -save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2) -{ - save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2); -} - - -static void GLAPIENTRY -save_MatrixMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_MatrixMode(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_MultMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_MultMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_MultMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_MultMatrixf(f); -} - - -static void GLAPIENTRY -save_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - /* It's an error to call this function while building a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - (void) name; - (void) mode; -} - - - -static void GLAPIENTRY -save_Ortho(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ORTHO, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); - if (n) { - n[1].e = map; - n[2].i = mapsize; - n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); - memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); - } -} - - -static void GLAPIENTRY -save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelTransferf(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); - if (n) { - n[1].e = pname; - n[2].f = param; - } - if (ctx->ExecuteFlag) { - CALL_PixelTransferf(ctx->Exec, (pname, param)); - } -} - - -static void GLAPIENTRY -save_PixelTransferi(GLenum pname, GLint param) -{ - save_PixelTransferf(pname, (GLfloat) param); -} - - -static void GLAPIENTRY -save_PixelZoom(GLfloat xfactor, GLfloat yfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); - if (n) { - n[1].f = xfactor; - n[2].f = yfactor; - } - if (ctx->ExecuteFlag) { - CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); - } -} - - -static void GLAPIENTRY -save_PointParameterfvEXT(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - } - if (ctx->ExecuteFlag) { - CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_PointParameterfEXT(GLenum pname, GLfloat param) -{ - GLfloat parray[3]; - parray[0] = param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameteriNV(GLenum pname, GLint param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameterivNV(GLenum pname, const GLint * param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param[0]; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - - -static void GLAPIENTRY -save_PointSize(GLfloat size) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); - if (n) { - n[1].f = size; - } - if (ctx->ExecuteFlag) { - CALL_PointSize(ctx->Exec, (size)); - } -} - - -static void GLAPIENTRY -save_PolygonMode(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_PolygonMode(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_PolygonStipple(const GLubyte * pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); - if (n) { - n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - pattern, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); - } -} - - -static void GLAPIENTRY -save_PolygonOffset(GLfloat factor, GLfloat units) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); - if (n) { - n[1].f = factor; - n[2].f = units; - } - if (ctx->ExecuteFlag) { - CALL_PolygonOffset(ctx->Exec, (factor, units)); - } -} - - -static void GLAPIENTRY -save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); -} - - -static void GLAPIENTRY -save_PopAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); - if (ctx->ExecuteFlag) { - CALL_PopAttrib(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PopMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopName(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); - if (ctx->ExecuteFlag) { - CALL_PopName(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PrioritizeTextures(GLsizei num, const GLuint * textures, - const GLclampf * priorities) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < num; i++) { - Node *n; - n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); - if (n) { - n[1].ui = textures[i]; - n[2].f = priorities[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); - } -} - - -static void GLAPIENTRY -save_PushAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_PushAttrib(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_PushMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PushMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PushName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_PushName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_RasterPos2d(GLdouble x, GLdouble y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2f(GLfloat x, GLfloat y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2i(GLint x, GLint y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2s(GLshort x, GLshort y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3i(GLint x, GLint y, GLint z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_RasterPos4f(x, y, z, w); -} - -static void GLAPIENTRY -save_RasterPos2dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_RasterPos4iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_PassThrough(GLfloat token) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); - if (n) { - n[1].f = token; - } - if (ctx->ExecuteFlag) { - CALL_PassThrough(ctx->Exec, (token)); - } -} - - -static void GLAPIENTRY -save_ReadBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ReadBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_ResetHistogram(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetHistogram(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_ResetMinmax(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetMinmax(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ROTATE, 4); - if (n) { - n[1].f = angle; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Rotatef(ctx->Exec, (angle, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) -{ - save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scalef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCALE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Scalef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Scaled(GLdouble x, GLdouble y, GLdouble z) -{ - save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = width; - n[4].i = height; - } - if (ctx->ExecuteFlag) { - CALL_Scissor(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_ShadeModel(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); - - if (ctx->ExecuteFlag) { - CALL_ShadeModel(ctx->Exec, (mode)); - } - - if (ctx->ListState.Current.ShadeModel == mode) - return; - - SAVE_FLUSH_VERTICES(ctx); - - /* Only save the value if we know the statechange will take effect: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) - ctx->ListState.Current.ShadeModel = mode; - - n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); - if (n) { - n[1].e = mode; - } -} - - -static void GLAPIENTRY -save_StencilFunc(GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); - if (n) { - n[1].e = func; - n[2].i = ref; - n[3].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFunc(ctx->Exec, (func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); - if (n) { - n[1].e = fail; - n[2].e = zfail; - n[3].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = func; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, - GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* GL_FRONT */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_FRONT; - n[2].e = frontfunc; - n[3].i = ref; - n[4].ui = mask; - } - /* GL_BACK */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_BACK; - n[2].e = backfunc; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); - CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMaskSeparate(GLenum face, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); - if (n) { - n[1].e = face; - n[2].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); - } -} - - -static void GLAPIENTRY -save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = fail; - n[3].e = zfail; - n[4].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXENV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - if (pname == GL_TEXTURE_ENV_COLOR) { - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[3].f = params[0]; - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_TexEnvfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexEnvf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexEnvfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexEnvi(GLenum target, GLenum pname, GLint param) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexEnviv(GLenum target, GLenum pname, const GLint * param) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; - } - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); - if (n) { - n[1].e = coord; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexGenfv(ctx->Exec, (coord, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGend(GLenum coord, GLenum pname, GLdouble param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGeni(GLenum coord, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_TexGeniv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexParameterfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) params[0]; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexImage1D(GLenum target, - GLint level, GLint components, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = border; - n[6].e = format; - n[7].e = type; - n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage2D(GLenum target, - GLint level, GLint components, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage3D(GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = (GLint) internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].e = format; - n[9].e = type; - n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, - format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - width, height, format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].e = type; - n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - width, height, depth, format, type, - pixels)); - } -} - - -static void GLAPIENTRY -save_Translatef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Translatef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Translated(GLdouble x, GLdouble y, GLdouble z) -{ - save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - - -static void GLAPIENTRY -save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - } - if (ctx->ExecuteFlag) { - CALL_Viewport(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2iMESA(GLint x, GLint y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2sMESA(GLshort x, GLshort y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_WindowPos4fMESA(x, y, z, w); -} - -static void GLAPIENTRY -save_WindowPos2dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_WindowPos4ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - - - -/* GL_ARB_multitexture */ -static void GLAPIENTRY -save_ActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ActiveTextureARB(ctx->Exec, (target)); - } -} - - -/* GL_ARB_transpose_matrix */ - -static void GLAPIENTRY -save_LoadTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_LoadTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_MultMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_MultMatrixf(tm); -} - - -/* GL_ARB_texture_compression */ -static void GLAPIENTRY -save_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, - width, border, imageSize, - data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = border; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage1DARB(ctx->Exec, - (target, level, internalFormat, width, - border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, - width, height, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].i = imageSize; - n[8].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage2DARB(ctx->Exec, - (target, level, internalFormat, width, - height, border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, - width, height, depth, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage3DARB(ctx->Exec, - (target, level, internalFormat, width, - height, depth, border, imageSize, - data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, - width, format, imageSize, - data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage2DARB(ctx->Exec, - (target, level, xoffset, yoffset, width, - height, format, imageSize, data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].i = imageSize; - n[11].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage3DARB(ctx->Exec, - (target, level, xoffset, yoffset, - zoffset, width, height, depth, format, - imageSize, data)); - } -} - - -/* GL_ARB_multisample */ -static void GLAPIENTRY -save_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); - if (n) { - n[1].f = value; - n[2].b = invert; - } - if (ctx->ExecuteFlag) { - CALL_SampleCoverageARB(ctx->Exec, (value, invert)); - } -} - - -/* - * GL_NV_vertex_program - */ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -static void GLAPIENTRY -save_BindProgramNV(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindProgramNV(ctx->Exec, (target, id)); - } -} - -static void GLAPIENTRY -save_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - save_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -static void GLAPIENTRY -save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat * params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) x, - (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) params[0], - (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ - -#if FEATURE_NV_vertex_program -static void GLAPIENTRY -save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); - if (n) { - n[1].e = target; - n[2].ui = id; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4dvNV(GLenum target, GLuint index, - GLsizei num, const GLdouble *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4fvNV(GLenum target, GLuint index, - GLsizei num, const GLfloat *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte * program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programCopy, program, len); - n[1].e = target; - n[2].ui = id; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); - } -} - - -static void GLAPIENTRY -save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); - if (n) { - GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); - if (!idCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); - return; - } - memcpy(idCopy, ids, num * sizeof(GLuint)); - n[1].i = num; - n[2].data = idCopy; - } - if (ctx->ExecuteFlag) { - CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); - } -} - - -static void GLAPIENTRY -save_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); - if (n) { - n[1].e = target; - n[2].ui = address; - n[3].e = matrix; - n[4].e = transform; - } - if (ctx->ExecuteFlag) { - CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); - } -} -#endif /* FEATURE_NV_vertex_program */ - - -/* - * GL_NV_fragment_program - */ -#if FEATURE_NV_fragment_program -static void GLAPIENTRY -save_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) x; - n[4].f = (GLfloat) y; - n[5].f = (GLfloat) z; - n[6].f = (GLfloat) w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) params[0]; - n[4].f = (GLfloat) params[1]; - n[5].f = (GLfloat) params[2]; - n[6].f = (GLfloat) params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); - } -} - -static void GLAPIENTRY -save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); - if (n) { - GLubyte *nameCopy = (GLubyte *) malloc(len); - if (!nameCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); - return; - } - memcpy(nameCopy, name, len); - n[1].ui = id; - n[2].i = len; - n[3].data = nameCopy; - n[4].f = x; - n[5].f = y; - n[6].f = z; - n[7].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, - const float v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, - const double v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], - (GLfloat) v[1], (GLfloat) v[2], - (GLfloat) v[3]); -} - -#endif /* FEATURE_NV_fragment_program */ - - - -/* GL_EXT_stencil_two_side */ -static void GLAPIENTRY -save_ActiveStencilFaceEXT(GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); - if (n) { - n[1].e = face; - } - if (ctx->ExecuteFlag) { - CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); - } -} - - -/* GL_EXT_depth_bounds_test */ -static void GLAPIENTRY -save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); - if (n) { - n[1].f = (GLfloat) zmin; - n[2].f = (GLfloat) zmax; - } - if (ctx->ExecuteFlag) { - CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); - } -} - - - -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - -static void GLAPIENTRY -save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid * string) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return; - } - memcpy(programCopy, string, len); - n[1].e = target; - n[2].e = format; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); - } -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ - - -#if FEATURE_queryobj - -static void GLAPIENTRY -save_BeginQueryARB(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BeginQueryARB(ctx->Exec, (target, id)); - } -} - - -static void GLAPIENTRY -save_EndQueryARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_EndQueryARB(ctx->Exec, (target)); - } -} - -#endif /* FEATURE_queryobj */ - - -static void GLAPIENTRY -save_DrawBuffersARB(GLsizei count, const GLenum * buffers) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); - if (n) { - GLint i; - n[1].i = count; - if (count > MAX_DRAW_BUFFERS) - count = MAX_DRAW_BUFFERS; - for (i = 0; i < count; i++) { - n[2 + i].e = buffers[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); - if (n) { - n[1].ui = pname; - n[2].f = param[0]; - n[3].f = param[1]; - n[4].f = param[2]; - n[5].f = param[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterivATI(GLenum pname, const GLint *param) -{ - GLfloat p[4]; - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - save_TexBumpParameterfvATI(pname, p); -} - -#if FEATURE_ATI_fragment_shader -static void GLAPIENTRY -save_BindFragmentShaderATI(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); - if (n) { - n[1].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindFragmentShaderATI(ctx->Exec, (id)); - } -} - -static void GLAPIENTRY -save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); - if (n) { - n[1].ui = dst; - n[2].f = value[0]; - n[3].f = value[1]; - n[4].f = value[2]; - n[5].f = value[3]; - } - if (ctx->ExecuteFlag) { - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); - } -} -#endif - -static void -save_Attr1fNV(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); - } -} - -static void -save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); - } -} - -static void -save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); - } -} - -static void -save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void -save_Attr1fARB(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); - } -} - -static void -save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); - } -} - -static void -save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); - } -} - -static void -save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_EvalCoord1f(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); - if (n) { - n[1].f = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord1f(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalCoord1fv(const GLfloat * v) -{ - save_EvalCoord1f(v[0]); -} - -static void GLAPIENTRY -save_EvalCoord2f(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); - if (n) { - n[1].f = x; - n[2].f = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord2f(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_EvalCoord2fv(const GLfloat * v) -{ - save_EvalCoord2f(v[0], v[1]); -} - - -static void GLAPIENTRY -save_EvalPoint1(GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); - if (n) { - n[1].i = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint1(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalPoint2(GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); - if (n) { - n[1].i = x; - n[2].i = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint2(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_Indexf(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); -} - -static void GLAPIENTRY -save_Indexfv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); -} - -static void GLAPIENTRY -save_EdgeFlag(GLboolean x) -{ - save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); -} - -static INLINE GLboolean compare4fv( const GLfloat *a, - const GLfloat *b, - GLuint count ) -{ - return memcmp( a, b, count * sizeof(GLfloat) ) == 0; -} - - -static void GLAPIENTRY -save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - int args, i; - GLuint bitmask; - - switch (face) { - case GL_BACK: - case GL_FRONT: - case GL_FRONT_AND_BACK: - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_AMBIENT_AND_DIFFUSE: - args = 4; - break; - case GL_SHININESS: - args = 1; - break; - case GL_COLOR_INDEXES: - args = 3; - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); - return; - } - - if (ctx->ExecuteFlag) { - CALL_Materialfv(ctx->Exec, (face, pname, param)); - } - - bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - - /* Try to eliminate redundant statechanges. Because it is legal to - * call glMaterial even inside begin/end calls, don't need to worry - * about ctx->Driver.CurrentSavePrimitive here. - */ - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - if (bitmask & (1 << i)) { - if (ctx->ListState.ActiveMaterialSize[i] == args && - compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { - bitmask &= ~(1 << i); - } - else { - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); - } - } - } - - /* If this call has effect, return early: - */ - if (bitmask == 0) - return; - - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); - if (n) { - n[1].e = face; - n[2].e = pname; - for (i = 0; i < args; i++) - n[3 + i].f = param[i]; - } -} - -static void GLAPIENTRY -save_Begin(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - GLboolean error = GL_FALSE; - - if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { - _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); - error = GL_TRUE; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { - /* Typically the first begin. This may raise an error on - * playback, depending on whether CallList is issued from inside - * a begin/end or not. - */ - ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentSavePrimitive = mode; - } - else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } - - if (!error) { - /* Give the driver an opportunity to hook in an optimized - * display list compiler. - */ - if (ctx->Driver.NotifySaveBegin(ctx, mode)) - return; - - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN, 1); - if (n) { - n[1].e = mode; - } - } - - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); - } -} - -static void GLAPIENTRY -save_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - (void) alloc_instruction(ctx, OPCODE_END, 0); - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - if (ctx->ExecuteFlag) { - CALL_End(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_RECTF, 4); - if (n) { - n[1].f = a; - n[2].f = b; - n[3].f = c; - n[4].f = d; - } - if (ctx->ExecuteFlag) { - CALL_Rectf(ctx->Exec, (a, b, c, d)); - } -} - - -static void GLAPIENTRY -save_Vertex2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_POS, x, y); -} - -static void GLAPIENTRY -save_Vertex2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); -} - -static void GLAPIENTRY -save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); -} - -static void GLAPIENTRY -save_Vertex3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); -} - -static void GLAPIENTRY -save_Vertex4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_TexCoord1f(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, x); -} - -static void GLAPIENTRY -save_TexCoord1fv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); -} - -static void GLAPIENTRY -save_TexCoord2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); -} - -static void GLAPIENTRY -save_TexCoord2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); -} - -static void GLAPIENTRY -save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); -} - -static void GLAPIENTRY -save_TexCoord3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); -} - -static void GLAPIENTRY -save_TexCoord4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); -} - -static void GLAPIENTRY -save_Normal3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_FogCoordfEXT(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, x); -} - -static void GLAPIENTRY -save_FogCoordfvEXT(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); -} - -static void GLAPIENTRY -save_Color3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); -} - -static void GLAPIENTRY -save_Color3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); -} - -static void GLAPIENTRY -save_Color4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); -} - -static void GLAPIENTRY -save_SecondaryColor3fvEXT(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); -} - - -/* Just call the respective ATTR for texcoord - */ -static void GLAPIENTRY -save_MultiTexCoord1f(GLenum target, GLfloat x) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, x); -} - -static void GLAPIENTRY -save_MultiTexCoord1fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, v[0]); -} - -static void GLAPIENTRY -save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, x, y); -} - -static void GLAPIENTRY -save_MultiTexCoord2fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, v[0], v[1]); -} - -static void GLAPIENTRY -save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, x, y, z); -} - -static void GLAPIENTRY -save_MultiTexCoord3fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, x, y, z, w); -} - -static void GLAPIENTRY -save_MultiTexCoord4fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); -} - - -/** - * Record a GL_INVALID_VALUE error when a invalid vertex attribute - * index is found. - */ -static void -index_error(void) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); -} - - -/* First level for NV_vertex_program: - * - * Check for errors at compile time?. - */ -static void GLAPIENTRY -save_VertexAttrib1fNV(GLuint index, GLfloat x) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - - - -static void GLAPIENTRY -save_VertexAttrib1fARB(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - -/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - -static void GLAPIENTRY -exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); -} - -static GLint GLAPIENTRY -exec_GetAttribLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); -} - -static GLint GLAPIENTRY -exec_GetUniformLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); -} -/* XXX more shader functions needed here */ - - -#if FEATURE_EXT_framebuffer_blit -static void GLAPIENTRY -save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); - if (n) { - n[1].i = srcX0; - n[2].i = srcY0; - n[3].i = srcX1; - n[4].i = srcY1; - n[5].i = dstX0; - n[6].i = dstY0; - n[7].i = dstX1; - n[8].i = dstY1; - n[9].i = mask; - n[10].e = filter; - } - if (ctx->ExecuteFlag) { - CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter)); - } -} -#endif - - -/** GL_EXT_provoking_vertex */ -static void GLAPIENTRY -save_ProvokingVertexEXT(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ - _mesa_ProvokingVertexEXT(mode); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_BeginTransformFeedback(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_EndTransformFeedback(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); - if (ctx->ExecuteFlag) { - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); - } -} - - -/* aka UseProgram() */ -static void GLAPIENTRY -save_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseProgramObjectARB(ctx->Exec, (program)); - } -} - - -static void GLAPIENTRY -save_Uniform1fARB(GLint location, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); - if (n) { - n[1].i = location; - n[2].f = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fARB(ctx->Exec, (location, x)); - } -} - - -static void GLAPIENTRY -save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fARB(ctx->Exec, (location, x, y)); - } -} - - -static void GLAPIENTRY -save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); - } -} - - -/** Return copy of memory */ -static void * -memdup(const void *src, GLsizei bytes) -{ - void *b = bytes >= 0 ? malloc(bytes) : NULL; - if (b) - memcpy(b, src, bytes); - return b; -} - - -static void GLAPIENTRY -save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); - } -} - - -static void GLAPIENTRY -save_Uniform1iARB(GLint location, GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1iARB(ctx->Exec, (location, x)); - } -} - -static void GLAPIENTRY -save_Uniform2iARB(GLint location, GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2iARB(ctx->Exec, (location, x, y)); - } -} - -static void GLAPIENTRY -save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); - } -} - -static void GLAPIENTRY -save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ui(GLint location, GLuint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ - } -} - -static void GLAPIENTRY -save_Uniform2ui(GLint location, GLuint x, GLuint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ - } -} - -static void GLAPIENTRY -save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ - } -} - -static void GLAPIENTRY -save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ - } -} - - - -static void GLAPIENTRY -save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ - } -} - - - -static void GLAPIENTRY -save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UseShaderProgramEXT(GLenum type, GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); - if (n) { - n[1].ui = type; - n[2].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); - } -} - -static void GLAPIENTRY -save_ActiveProgramEXT(GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_ActiveProgramEXT(ctx->Exec, (program)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); - if (n) { - n[1].i = red; - n[2].i = green; - n[3].i = blue; - n[4].i = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); - if (n) { - n[1].ui = red; - n[2].ui = green; - n[3].ui = blue; - n[4].ui = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].ui = params[0]; - n[4].ui = params[1]; - n[5].ui = params[2]; - n[6].ui = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); -} - - -/* GL_ARB_instanced_arrays */ -static void -save_VertexAttribDivisor(GLuint index, GLuint divisor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2); - if (n) { - n[1].ui = index; - n[2].ui = divisor; - } - if (ctx->ExecuteFlag) { - CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor)); - } -} - - - -/** - * Save an error-generating command into display list. - * - * KW: Will appear in the list before the vertex buffer containing the - * command that provoked the error. I don't see this as a problem. - */ -static void -save_error(struct gl_context *ctx, GLenum error, const char *s) -{ - Node *n; - n = alloc_instruction(ctx, OPCODE_ERROR, 2); - if (n) { - n[1].e = error; - n[2].data = (void *) s; - } -} - - -/** - * Compile an error into current display list. - */ -void -_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) -{ - if (ctx->CompileFlag) - save_error(ctx, error, s); - if (ctx->ExecuteFlag) - _mesa_error(ctx, error, "%s", s); -} - - -/** - * Test if ID names a display list. - */ -static GLboolean -islist(struct gl_context *ctx, GLuint list) -{ - if (list > 0 && lookup_list(ctx, list)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/**********************************************************************/ -/* Display list execution */ -/**********************************************************************/ - - -/* - * Execute a display list. Note that the ListBase offset must have already - * been added before calling this function. I.e. the list argument is - * the absolute list number, not relative to ListBase. - * \param list - display list number - */ -static void -execute_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (list == 0 || !islist(ctx, list)) - return; - - if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { - /* raise an error? */ - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - ctx->ListState.CallDepth++; - - if (ctx->Driver.BeginCallList) - ctx->Driver.BeginCallList(ctx, dlist); - - n = dlist->Head; - - done = GL_FALSE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_execute(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ERROR: - _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); - break; - case OPCODE_ACCUM: - CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ALPHA_FUNC: - CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_BIND_TEXTURE: - CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_BITMAP: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, - (const GLubyte *) n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_BLEND_COLOR: - CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_BLEND_EQUATION: - CALL_BlendEquation(ctx->Exec, (n[1].e)); - break; - case OPCODE_BLEND_EQUATION_SEPARATE: - CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_BLEND_FUNC_SEPARATE: - CALL_BlendFuncSeparateEXT(ctx->Exec, - (n[1].e, n[2].e, n[3].e, n[4].e)); - break; - - case OPCODE_BLEND_FUNC_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e)); - break; - case OPCODE_BLEND_FUNC_SEPARATE_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e, - n[4].e, n[5].e)); - break; - case OPCODE_BLEND_EQUATION_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_BLEND_EQUATION_SEPARATE_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendEquationSeparateiARB(ctx->Exec, - (n[1].ui, n[2].e, n[3].e)); - break; - - case OPCODE_CALL_LIST: - /* Generated by glCallList(), don't add ListBase */ - if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - execute_list(ctx, n[1].ui); - } - break; - case OPCODE_CALL_LIST_OFFSET: - /* Generated by glCallLists() so we must add ListBase */ - if (n[2].b) { - /* user specified a bad data type at compile time */ - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - } - else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); - execute_list(ctx, list); - } - break; - case OPCODE_CLEAR: - CALL_Clear(ctx->Exec, (n[1].bf)); - break; - case OPCODE_CLEAR_BUFFER_IV: - { - GLint value[4]; - value[0] = n[3].i; - value[1] = n[4].i; - value[2] = n[5].i; - value[3] = n[6].i; - /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_UIV: - { - GLuint value[4]; - value[0] = n[3].ui; - value[1] = n[4].ui; - value[2] = n[5].ui; - value[3] = n[6].ui; - /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_FV: - { - GLfloat value[4]; - value[0] = n[3].f; - value[1] = n[4].f; - value[2] = n[5].f; - value[3] = n[6].f; - /*CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_FI: - /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/ - break; - case OPCODE_CLEAR_COLOR: - CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_ACCUM: - CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_DEPTH: - CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); - break; - case OPCODE_CLEAR_INDEX: - CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); - break; - case OPCODE_CLEAR_STENCIL: - CALL_ClearStencil(ctx->Exec, (n[1].i)); - break; - case OPCODE_CLIP_PLANE: - { - GLdouble eq[4]; - eq[0] = n[2].f; - eq[1] = n[3].f; - eq[2] = n[4].f; - eq[3] = n[5].f; - CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); - } - break; - case OPCODE_COLOR_MASK: - CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); - break; - case OPCODE_COLOR_MASK_INDEXED: - CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b, - n[4].b, n[5].b)); - break; - case OPCODE_COLOR_MATERIAL: - CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_COLOR_TABLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e, - n[5].e, n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_COLOR_TABLE_PARAMETER_FV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_ColorTableParameterfv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COLOR_TABLE_PARAMETER_IV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_ColorTableParameteriv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COLOR_SUB_TABLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].e, n[5].e, n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_FILTER_1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].e, n[5].e, - n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_FILTER_2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, n[6].e, - n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_PARAMETER_I: - CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i)); - break; - case OPCODE_CONVOLUTION_PARAMETER_IV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_ConvolutionParameteriv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_CONVOLUTION_PARAMETER_F: - CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f)); - break; - case OPCODE_CONVOLUTION_PARAMETER_FV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_ConvolutionParameterfv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COPY_COLOR_SUB_TABLE: - CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, - n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_COPY_COLOR_TABLE: - CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, - n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_COPY_PIXELS: - CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i, - n[5].e)); - break; - case OPCODE_COPY_TEX_IMAGE1D: - CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i)); - break; - case OPCODE_COPY_TEX_IMAGE2D: - CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE1D: - CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE2D: - CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE3D: - CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i, n[9].i)); - break; - case OPCODE_CULL_FACE: - CALL_CullFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_FUNC: - CALL_DepthFunc(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_MASK: - CALL_DepthMask(ctx->Exec, (n[1].b)); - break; - case OPCODE_DEPTH_RANGE: - CALL_DepthRange(ctx->Exec, - ((GLclampd) n[1].f, (GLclampd) n[2].f)); - break; - case OPCODE_DISABLE: - CALL_Disable(ctx->Exec, (n[1].e)); - break; - case OPCODE_DISABLE_INDEXED: - CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_DRAW_BUFFER: - CALL_DrawBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_DRAW_PIXELS: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, - n[5].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_ENABLE: - CALL_Enable(ctx->Exec, (n[1].e)); - break; - case OPCODE_ENABLE_INDEXED: - CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_EVALMESH1: - CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); - break; - case OPCODE_EVALMESH2: - CALL_EvalMesh2(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_FOG: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_Fogfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_FRONT_FACE: - CALL_FrontFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_FRUSTUM: - CALL_Frustum(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_HINT: - CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_HISTOGRAM: - CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b)); - break; - case OPCODE_INDEX_MASK: - CALL_IndexMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_INIT_NAMES: - CALL_InitNames(ctx->Exec, ()); - break; - case OPCODE_LIGHT: - { - GLfloat p[4]; - p[0] = n[3].f; - p[1] = n[4].f; - p[2] = n[5].f; - p[3] = n[6].f; - CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); - } - break; - case OPCODE_LIGHT_MODEL: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_LightModelfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_LINE_STIPPLE: - CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); - break; - case OPCODE_LINE_WIDTH: - CALL_LineWidth(ctx->Exec, (n[1].f)); - break; - case OPCODE_LIST_BASE: - CALL_ListBase(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOAD_IDENTITY: - CALL_LoadIdentity(ctx->Exec, ()); - break; - case OPCODE_LOAD_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_LoadMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_LOAD_NAME: - CALL_LoadName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOGIC_OP: - CALL_LogicOp(ctx->Exec, (n[1].e)); - break; - case OPCODE_MAP1: - { - GLenum target = n[1].e; - GLint ustride = _mesa_evaluator_components(target); - GLint uorder = n[5].i; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, - (GLfloat *) n[6].data)); - } - break; - case OPCODE_MAP2: - { - GLenum target = n[1].e; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - GLfloat v1 = n[4].f; - GLfloat v2 = n[5].f; - GLint ustride = n[6].i; - GLint vstride = n[7].i; - GLint uorder = n[8].i; - GLint vorder = n[9].i; - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, - (GLfloat *) n[10].data)); - } - break; - case OPCODE_MAPGRID1: - CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_MAPGRID2: - CALL_MapGrid2f(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); - break; - case OPCODE_MATRIX_MODE: - CALL_MatrixMode(ctx->Exec, (n[1].e)); - break; - case OPCODE_MIN_MAX: - CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b)); - break; - case OPCODE_MULT_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_MultMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_MultMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_ORTHO: - CALL_Ortho(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_PASSTHROUGH: - CALL_PassThrough(ctx->Exec, (n[1].f)); - break; - case OPCODE_PIXEL_MAP: - CALL_PixelMapfv(ctx->Exec, - (n[1].e, n[2].i, (GLfloat *) n[3].data)); - break; - case OPCODE_PIXEL_TRANSFER: - CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_PIXEL_ZOOM: - CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POINT_SIZE: - CALL_PointSize(ctx->Exec, (n[1].f)); - break; - case OPCODE_POINT_PARAMETERS: - { - GLfloat params[3]; - params[0] = n[2].f; - params[1] = n[3].f; - params[2] = n[4].f; - CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); - } - break; - case OPCODE_POLYGON_MODE: - CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_POLYGON_STIPPLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_POLYGON_OFFSET: - CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POP_ATTRIB: - CALL_PopAttrib(ctx->Exec, ()); - break; - case OPCODE_POP_MATRIX: - CALL_PopMatrix(ctx->Exec, ()); - break; - case OPCODE_POP_NAME: - CALL_PopName(ctx->Exec, ()); - break; - case OPCODE_PRIORITIZE_TEXTURE: - CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); - break; - case OPCODE_PUSH_ATTRIB: - CALL_PushAttrib(ctx->Exec, (n[1].bf)); - break; - case OPCODE_PUSH_MATRIX: - CALL_PushMatrix(ctx->Exec, ()); - break; - case OPCODE_PUSH_NAME: - CALL_PushName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_RASTER_POS: - CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_READ_BUFFER: - CALL_ReadBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_RESET_HISTOGRAM: - CALL_ResetHistogram(ctx->Exec, (n[1].e)); - break; - case OPCODE_RESET_MIN_MAX: - CALL_ResetMinmax(ctx->Exec, (n[1].e)); - break; - case OPCODE_ROTATE: - CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_SCALE: - CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_SCISSOR: - CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_SHADE_MODEL: - CALL_ShadeModel(ctx->Exec, (n[1].e)); - break; - case OPCODE_PROVOKING_VERTEX: - CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_BEGIN_TRANSFORM_FEEDBACK: - CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_END_TRANSFORM_FEEDBACK: - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); - break; - case OPCODE_STENCIL_FUNC: - CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); - break; - case OPCODE_STENCIL_MASK: - CALL_StencilMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_STENCIL_OP: - CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); - break; - case OPCODE_STENCIL_FUNC_SEPARATE: - CALL_StencilFuncSeparate(ctx->Exec, - (n[1].e, n[2].e, n[3].i, n[4].ui)); - break; - case OPCODE_STENCIL_MASK_SEPARATE: - CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_STENCIL_OP_SEPARATE: - CALL_StencilOpSeparate(ctx->Exec, - (n[1].e, n[2].e, n[3].e, n[4].e)); - break; - case OPCODE_TEXENV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXGEN: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEX_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].e, /* border */ - n[6].e, /* format */ - n[7].e, /* type */ - n[8].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].e, /* border */ - n[7].e, /* format */ - n[8].e, /* type */ - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_IMAGE3D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].i, /* depth */ - n[7].e, /* border */ - n[8].e, /* format */ - n[9].e, /* type */ - n[10].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].e, n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].i, n[7].e, n[8].e, - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE3D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i, n[9].e, n[10].e, - n[11].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TRANSLATE: - CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_VIEWPORT: - CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i)); - break; - case OPCODE_WINDOW_POS: - CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ - CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].data)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].i, n[8].data)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].i, n[8].i, - n[9].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage1DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].e, n[6].i, n[7].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage2DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].e, n[8].i, - n[9].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage3DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i, - n[9].e, n[10].i, n[11].data)); - break; - case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ - CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); - break; - case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ - CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ - CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); - break; -#endif -#if FEATURE_NV_vertex_program - case OPCODE_EXECUTE_PROGRAM_NV: - { - GLfloat v[4]; - v[0] = n[3].f; - v[1] = n[4].f; - v[2] = n[5].f; - v[3] = n[6].f; - CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v)); - } - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui, - (GLuint *) n[2].data)); - break; - case OPCODE_LOAD_PROGRAM_NV: - CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, - (const GLubyte *) n[4].data)); - break; - case OPCODE_TRACK_MATRIX_NV: - CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); - break; -#endif - -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: - CALL_ProgramLocalParameter4fARB(ctx->Exec, - (n[1].e, n[2].ui, n[3].f, n[4].f, - n[5].f, n[6].f)); - break; - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, - (const GLubyte *) n[3]. - data, n[4].f, n[5].f, - n[6].f, n[7].f)); - break; -#endif - - case OPCODE_ACTIVE_STENCIL_FACE_EXT: - CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_BOUNDS_EXT: - CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); - break; -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - CALL_ProgramStringARB(ctx->Exec, - (n[1].e, n[2].e, n[3].i, n[4].data)); - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program - case OPCODE_PROGRAM_ENV_PARAMETER_ARB: - CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, - n[4].f, n[5].f, - n[6].f)); - break; -#endif -#if FEATURE_queryobj - case OPCODE_BEGIN_QUERY_ARB: - CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_END_QUERY_ARB: - CALL_EndQueryARB(ctx->Exec, (n[1].e)); - break; -#endif - case OPCODE_DRAW_BUFFERS_ARB: - { - GLenum buffers[MAX_DRAW_BUFFERS]; - GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); - for (i = 0; i < count; i++) - buffers[i] = n[2 + i].e; - CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers)); - } - break; -#if FEATURE_EXT_framebuffer_blit - case OPCODE_BLIT_FRAMEBUFFER: - CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i, - n[9].i, n[10].e)); - break; -#endif - - case OPCODE_USE_PROGRAM: - CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); - break; - case OPCODE_USE_SHADER_PROGRAM_EXT: - CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); - break; - case OPCODE_ACTIVE_PROGRAM_EXT: - CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); - break; - case OPCODE_UNIFORM_1F: - CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); - break; - case OPCODE_UNIFORM_2F: - CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_UNIFORM_3F: - CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_UNIFORM_4F: - CALL_Uniform4fARB(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); - break; - case OPCODE_UNIFORM_1FV: - CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2FV: - CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3FV: - CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4FV: - CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1I: - CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); - break; - case OPCODE_UNIFORM_2I: - CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); - break; - case OPCODE_UNIFORM_3I: - CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_UNIFORM_4I: - CALL_Uniform4iARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_UNIFORM_1IV: - CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2IV: - CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3IV: - CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4IV: - CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1UI: - /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ - break; - case OPCODE_UNIFORM_2UI: - /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ - break; - case OPCODE_UNIFORM_3UI: - /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ - break; - case OPCODE_UNIFORM_4UI: - /*CALL_Uniform4uiARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - */ - break; - case OPCODE_UNIFORM_1UIV: - /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_2UIV: - /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_3UIV: - /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_4UIV: - /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_MATRIX22: - CALL_UniformMatrix2fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX33: - CALL_UniformMatrix3fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX44: - CALL_UniformMatrix4fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX23: - CALL_UniformMatrix2x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX32: - CALL_UniformMatrix3x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX24: - CALL_UniformMatrix2x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX42: - CALL_UniformMatrix4x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX34: - CALL_UniformMatrix3x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX43: - CALL_UniformMatrix4x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - - case OPCODE_TEX_BUMP_PARAMETER_ATI: - { - GLfloat values[4]; - GLuint i, pname = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); - } - break; -#if FEATURE_ATI_fragment_shader - case OPCODE_BIND_FRAGMENT_SHADER_ATI: - CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); - break; - case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: - { - GLfloat values[4]; - GLuint i, dst = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); - } - break; -#endif - case OPCODE_ATTR_1F_NV: - CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_NV: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_ATTR_1F_ARB: - CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_ARB: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_MATERIAL: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); - else { - GLfloat f[4]; - f[0] = n[3].f; - f[1] = n[4].f; - f[2] = n[5].f; - f[3] = n[6].f; - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); - } - break; - case OPCODE_BEGIN: - CALL_Begin(ctx->Exec, (n[1].e)); - break; - case OPCODE_END: - CALL_End(ctx->Exec, ()); - break; - case OPCODE_RECTF: - CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_EVAL_C1: - CALL_EvalCoord1f(ctx->Exec, (n[1].f)); - break; - case OPCODE_EVAL_C2: - CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_EVAL_P1: - CALL_EvalPoint1(ctx->Exec, (n[1].i)); - break; - case OPCODE_EVAL_P2: - CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); - break; - - /* GL_EXT_texture_integer */ - case OPCODE_CLEARCOLOR_I: - CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_CLEARCOLOR_UI: - CALL_ClearColorIuiEXT(ctx->Exec, - (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); - break; - case OPCODE_TEXPARAMETER_I: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER_UI: - { - GLuint params[4]; - params[0] = n[3].ui; - params[1] = n[4].ui; - params[2] = n[5].ui; - params[3] = n[6].ui; - CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - - case OPCODE_VERTEX_ATTRIB_DIVISOR: - /* GL_ARB_instanced_arrays */ - CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui)); - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - done = GL_TRUE; - break; - default: - { - char msg[1000]; - _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", - (int) opcode); - _mesa_problem(ctx, "%s", msg); - } - done = GL_TRUE; - } - - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } - - if (ctx->Driver.EndCallList) - ctx->Driver.EndCallList(ctx); - - ctx->ListState.CallDepth--; -} - - - -/**********************************************************************/ -/* GL functions */ -/**********************************************************************/ - -/** - * Test if a display list number is valid. - */ -static GLboolean GLAPIENTRY -_mesa_IsList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - return islist(ctx, list); -} - - -/** - * Delete a sequence of consecutive display lists. - */ -static void GLAPIENTRY -_mesa_DeleteLists(GLuint list, GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint i; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); - return; - } - for (i = list; i < list + range; i++) { - destroy_list(ctx, i); - } -} - - -/** - * Return a display list number, n, such that lists n through n+range-1 - * are free. - */ -static GLuint GLAPIENTRY -_mesa_GenLists(GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint base; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); - return 0; - } - if (range == 0) { - return 0; - } - - /* - * Make this an atomic operation - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); - if (base) { - /* reserve the list IDs by with empty/dummy lists */ - GLint i; - for (i = 0; i < range; i++) { - _mesa_HashInsert(ctx->Shared->DisplayList, base + i, - make_list(base + i, 1)); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return base; -} - - -/** - * Begin a new display list. - */ -static void GLAPIENTRY -_mesa_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - - FLUSH_CURRENT(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glNewList %u %s\n", name, - _mesa_lookup_enum_by_nr(mode)); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); - return; - } - - if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); - return; - } - - if (ctx->ListState.CurrentList) { - /* already compiling a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - return; - } - - ctx->CompileFlag = GL_TRUE; - ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); - - /* Reset acumulated list state: - */ - invalidate_saved_current_state( ctx ); - - /* Allocate new display list */ - ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); - ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; - ctx->ListState.CurrentPos = 0; - - ctx->Driver.NewList(ctx, name, mode); - - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -/** - * End definition of current display list. - */ -static void GLAPIENTRY -_mesa_EndList(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEndList\n"); - - /* Check that a list is under construction */ - if (!ctx->ListState.CurrentList) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); - return; - } - - /* Call before emitting END_OF_LIST, in case the driver wants to - * emit opcodes itself. - */ - ctx->Driver.EndList(ctx); - - (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); - - /* Destroy old list, if any */ - destroy_list(ctx, ctx->ListState.CurrentList->Name); - - /* Install the new list */ - _mesa_HashInsert(ctx->Shared->DisplayList, - ctx->ListState.CurrentList->Name, - ctx->ListState.CurrentList); - - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - mesa_print_display_list(ctx->ListState.CurrentList->Name); - - ctx->ListState.CurrentList = NULL; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - - ctx->CurrentDispatch = ctx->Exec; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -void GLAPIENTRY -_mesa_CallList(GLuint list) -{ - GLboolean save_compile_flag; - GET_CURRENT_CONTEXT(ctx); - FLUSH_CURRENT(ctx, 0); - /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ - /* execute the display list, and restore the CompileFlag. */ - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallList %d\n", list); - - if (list == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); - return; - } - -/* mesa_print_display_list( list ); */ - - save_compile_flag = ctx->CompileFlag; - if (save_compile_flag) { - ctx->CompileFlag = GL_FALSE; - } - - execute_list(ctx, list); - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Execute glCallLists: call multiple display lists. - */ -void GLAPIENTRY -_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean save_compile_flag; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallLists %d\n", n); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - return; - } - - /* Save the CompileFlag status, turn it off, execute display list, - * and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - ctx->CompileFlag = GL_FALSE; - - for (i = 0; i < n; i++) { - GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); - execute_list(ctx, list); - } - - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Set the offset added to list numbers in glCallLists. - */ -static void GLAPIENTRY -_mesa_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - ctx->List.ListBase = base; -} - - -/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. - */ -static void GLAPIENTRY -exec_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Finish(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Flush(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetBooleanv(GLenum pname, GLboolean *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetBooleanv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetClipPlane(GLenum plane, GLdouble * equation) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetClipPlane(ctx->Exec, (plane, equation)); -} - -static void GLAPIENTRY -exec_GetDoublev(GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetDoublev(ctx->Exec, (pname, params)); -} - -static GLenum GLAPIENTRY -exec_GetError(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetError(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetFloatv(GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetFloatv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetIntegerv(GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetIntegerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightfv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetLightiv(GLenum light, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightiv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapdv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapfv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapiv(GLenum target, GLenum query, GLint * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapiv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetPixelMapfv(GLenum map, GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapfv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapuiv(GLenum map, GLuint *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapuiv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapusv(GLenum map, GLushort *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapusv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPolygonStipple(GLubyte * dest) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPolygonStipple(ctx->Exec, (dest)); -} - -static const GLubyte *GLAPIENTRY -exec_GetString(GLenum name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetString(ctx->Exec, (name)); -} - -static void GLAPIENTRY -exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexImage(GLenum target, GLint level, GLenum format, - GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameterfv(GLenum target, GLint level, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameteriv(GLenum target, GLint level, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); -} - -static GLboolean GLAPIENTRY -exec_IsEnabled(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsEnabled(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_PixelStoref(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStoref(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_PixelStorei(GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStorei(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); -} - -static GLint GLAPIENTRY -exec_RenderMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_RenderMode(ctx->Exec, (mode)); -} - -static void GLAPIENTRY -exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); -} - -static void GLAPIENTRY -exec_SelectBuffer(GLsizei size, GLuint * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SelectBuffer(ctx->Exec, (size, buffer)); -} - -static GLboolean GLAPIENTRY -exec_AreTexturesResident(GLsizei n, const GLuint * texName, - GLboolean * residences) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); -} - -static void GLAPIENTRY -exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_DeleteTextures(GLsizei n, const GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DeleteTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_DisableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DisableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); -} - -static void GLAPIENTRY -exec_EnableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EnableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_GenTextures(GLsizei n, GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GenTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_GetPointerv(GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPointerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); -} - -static GLboolean GLAPIENTRY -exec_IsTexture(GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsTexture(ctx->Exec, (texture)); -} - -static void GLAPIENTRY -exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_PopClientAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PopClientAttrib(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_PushClientAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PushClientAttrib(ctx->Exec, (mask)); -} - -static void GLAPIENTRY -exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); -} - -static void GLAPIENTRY -exec_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter1D(ctx->Exec, - (target, internalFormat, x, y, width)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter2D(ctx->Exec, - (target, internalFormat, x, y, width, - height)); -} - -static void GLAPIENTRY -exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTable(ctx->Exec, (target, format, type, data)); -} - -static void GLAPIENTRY -exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid * image) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid *row, GLvoid *column, GLvoid *span) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetSeparableFilter(ctx->Exec, - (target, format, type, row, column, span)); -} - -static void GLAPIENTRY -exec_SeparableFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid *row, const GLvoid *column) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SeparableFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, row, column)); -} - -static void GLAPIENTRY -exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); -} - -static void GLAPIENTRY -exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_LockArraysEXT(ctx->Exec, (first, count)); -} - -static void GLAPIENTRY -exec_UnlockArraysEXT(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_UnlockArraysEXT(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_ClientActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ClientActiveTextureARB(ctx->Exec, (target)); -} - -static void GLAPIENTRY -exec_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); -} - -/* GL_EXT_multi_draw_arrays */ -static void GLAPIENTRY -exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, - const GLsizei * count, GLsizei primcount, - GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawArraysIBM(ctx->Exec, - (mode, first, count, primcount, modestride)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawElementsIBM(const GLenum * mode, - const GLsizei * count, - GLenum type, - const GLvoid * const *indices, - GLsizei primcount, GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawElementsIBM(ctx->Exec, - (mode, count, type, indices, primcount, - modestride)); -} - - - -/** - * Setup the given dispatch table to point to Mesa's display list - * building functions. - * - * This does not include any of the tnl functions - they are - * initialized from _mesa_init_api_defaults and from the active vtxfmt - * struct. - */ -struct _glapi_table * -_mesa_create_save_table(void) -{ - struct _glapi_table *table; - - table = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (table == NULL) - return NULL; - - _mesa_loopback_init_api_table(table); - - /* GL 1.0 */ - SET_Accum(table, save_Accum); - SET_AlphaFunc(table, save_AlphaFunc); - SET_Bitmap(table, save_Bitmap); - SET_BlendFunc(table, save_BlendFunc); - SET_CallList(table, save_CallList); - SET_CallLists(table, save_CallLists); - SET_Clear(table, save_Clear); - SET_ClearAccum(table, save_ClearAccum); - SET_ClearColor(table, save_ClearColor); - SET_ClearDepth(table, save_ClearDepth); - SET_ClearIndex(table, save_ClearIndex); - SET_ClearStencil(table, save_ClearStencil); - SET_ClipPlane(table, save_ClipPlane); - SET_ColorMask(table, save_ColorMask); - SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); - SET_ColorMaterial(table, save_ColorMaterial); - SET_CopyPixels(table, save_CopyPixels); - SET_CullFace(table, save_CullFace); - SET_DeleteLists(table, _mesa_DeleteLists); - SET_DepthFunc(table, save_DepthFunc); - SET_DepthMask(table, save_DepthMask); - SET_DepthRange(table, save_DepthRange); - SET_Disable(table, save_Disable); - SET_DisableIndexedEXT(table, save_DisableIndexed); - SET_DrawBuffer(table, save_DrawBuffer); - SET_DrawPixels(table, save_DrawPixels); - SET_Enable(table, save_Enable); - SET_EnableIndexedEXT(table, save_EnableIndexed); - SET_EndList(table, _mesa_EndList); - SET_EvalMesh1(table, save_EvalMesh1); - SET_EvalMesh2(table, save_EvalMesh2); - SET_Finish(table, exec_Finish); - SET_Flush(table, exec_Flush); - SET_Fogf(table, save_Fogf); - SET_Fogfv(table, save_Fogfv); - SET_Fogi(table, save_Fogi); - SET_Fogiv(table, save_Fogiv); - SET_FrontFace(table, save_FrontFace); - SET_Frustum(table, save_Frustum); - SET_GenLists(table, _mesa_GenLists); - SET_GetBooleanv(table, exec_GetBooleanv); - SET_GetClipPlane(table, exec_GetClipPlane); - SET_GetDoublev(table, exec_GetDoublev); - SET_GetError(table, exec_GetError); - SET_GetFloatv(table, exec_GetFloatv); - SET_GetIntegerv(table, exec_GetIntegerv); - SET_GetLightfv(table, exec_GetLightfv); - SET_GetLightiv(table, exec_GetLightiv); - SET_GetMapdv(table, exec_GetMapdv); - SET_GetMapfv(table, exec_GetMapfv); - SET_GetMapiv(table, exec_GetMapiv); - SET_GetMaterialfv(table, exec_GetMaterialfv); - SET_GetMaterialiv(table, exec_GetMaterialiv); - SET_GetPixelMapfv(table, exec_GetPixelMapfv); - SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); - SET_GetPixelMapusv(table, exec_GetPixelMapusv); - SET_GetPolygonStipple(table, exec_GetPolygonStipple); - SET_GetString(table, exec_GetString); - SET_GetTexEnvfv(table, exec_GetTexEnvfv); - SET_GetTexEnviv(table, exec_GetTexEnviv); - SET_GetTexGendv(table, exec_GetTexGendv); - SET_GetTexGenfv(table, exec_GetTexGenfv); - SET_GetTexGeniv(table, exec_GetTexGeniv); - SET_GetTexImage(table, exec_GetTexImage); - SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); - SET_GetTexParameterfv(table, exec_GetTexParameterfv); - SET_GetTexParameteriv(table, exec_GetTexParameteriv); - SET_Hint(table, save_Hint); - SET_IndexMask(table, save_IndexMask); - SET_InitNames(table, save_InitNames); - SET_IsEnabled(table, exec_IsEnabled); - SET_IsList(table, _mesa_IsList); - SET_LightModelf(table, save_LightModelf); - SET_LightModelfv(table, save_LightModelfv); - SET_LightModeli(table, save_LightModeli); - SET_LightModeliv(table, save_LightModeliv); - SET_Lightf(table, save_Lightf); - SET_Lightfv(table, save_Lightfv); - SET_Lighti(table, save_Lighti); - SET_Lightiv(table, save_Lightiv); - SET_LineStipple(table, save_LineStipple); - SET_LineWidth(table, save_LineWidth); - SET_ListBase(table, save_ListBase); - SET_LoadIdentity(table, save_LoadIdentity); - SET_LoadMatrixd(table, save_LoadMatrixd); - SET_LoadMatrixf(table, save_LoadMatrixf); - SET_LoadName(table, save_LoadName); - SET_LogicOp(table, save_LogicOp); - SET_Map1d(table, save_Map1d); - SET_Map1f(table, save_Map1f); - SET_Map2d(table, save_Map2d); - SET_Map2f(table, save_Map2f); - SET_MapGrid1d(table, save_MapGrid1d); - SET_MapGrid1f(table, save_MapGrid1f); - SET_MapGrid2d(table, save_MapGrid2d); - SET_MapGrid2f(table, save_MapGrid2f); - SET_MatrixMode(table, save_MatrixMode); - SET_MultMatrixd(table, save_MultMatrixd); - SET_MultMatrixf(table, save_MultMatrixf); - SET_NewList(table, save_NewList); - SET_Ortho(table, save_Ortho); - SET_PassThrough(table, save_PassThrough); - SET_PixelMapfv(table, save_PixelMapfv); - SET_PixelMapuiv(table, save_PixelMapuiv); - SET_PixelMapusv(table, save_PixelMapusv); - SET_PixelStoref(table, exec_PixelStoref); - SET_PixelStorei(table, exec_PixelStorei); - SET_PixelTransferf(table, save_PixelTransferf); - SET_PixelTransferi(table, save_PixelTransferi); - SET_PixelZoom(table, save_PixelZoom); - SET_PointSize(table, save_PointSize); - SET_PolygonMode(table, save_PolygonMode); - SET_PolygonOffset(table, save_PolygonOffset); - SET_PolygonStipple(table, save_PolygonStipple); - SET_PopAttrib(table, save_PopAttrib); - SET_PopMatrix(table, save_PopMatrix); - SET_PopName(table, save_PopName); - SET_PushAttrib(table, save_PushAttrib); - SET_PushMatrix(table, save_PushMatrix); - SET_PushName(table, save_PushName); - SET_RasterPos2d(table, save_RasterPos2d); - SET_RasterPos2dv(table, save_RasterPos2dv); - SET_RasterPos2f(table, save_RasterPos2f); - SET_RasterPos2fv(table, save_RasterPos2fv); - SET_RasterPos2i(table, save_RasterPos2i); - SET_RasterPos2iv(table, save_RasterPos2iv); - SET_RasterPos2s(table, save_RasterPos2s); - SET_RasterPos2sv(table, save_RasterPos2sv); - SET_RasterPos3d(table, save_RasterPos3d); - SET_RasterPos3dv(table, save_RasterPos3dv); - SET_RasterPos3f(table, save_RasterPos3f); - SET_RasterPos3fv(table, save_RasterPos3fv); - SET_RasterPos3i(table, save_RasterPos3i); - SET_RasterPos3iv(table, save_RasterPos3iv); - SET_RasterPos3s(table, save_RasterPos3s); - SET_RasterPos3sv(table, save_RasterPos3sv); - SET_RasterPos4d(table, save_RasterPos4d); - SET_RasterPos4dv(table, save_RasterPos4dv); - SET_RasterPos4f(table, save_RasterPos4f); - SET_RasterPos4fv(table, save_RasterPos4fv); - SET_RasterPos4i(table, save_RasterPos4i); - SET_RasterPos4iv(table, save_RasterPos4iv); - SET_RasterPos4s(table, save_RasterPos4s); - SET_RasterPos4sv(table, save_RasterPos4sv); - SET_ReadBuffer(table, save_ReadBuffer); - SET_ReadPixels(table, exec_ReadPixels); - SET_RenderMode(table, exec_RenderMode); - SET_Rotated(table, save_Rotated); - SET_Rotatef(table, save_Rotatef); - SET_Scaled(table, save_Scaled); - SET_Scalef(table, save_Scalef); - SET_Scissor(table, save_Scissor); - SET_FeedbackBuffer(table, exec_FeedbackBuffer); - SET_SelectBuffer(table, exec_SelectBuffer); - SET_ShadeModel(table, save_ShadeModel); - SET_StencilFunc(table, save_StencilFunc); - SET_StencilMask(table, save_StencilMask); - SET_StencilOp(table, save_StencilOp); - SET_TexEnvf(table, save_TexEnvf); - SET_TexEnvfv(table, save_TexEnvfv); - SET_TexEnvi(table, save_TexEnvi); - SET_TexEnviv(table, save_TexEnviv); - SET_TexGend(table, save_TexGend); - SET_TexGendv(table, save_TexGendv); - SET_TexGenf(table, save_TexGenf); - SET_TexGenfv(table, save_TexGenfv); - SET_TexGeni(table, save_TexGeni); - SET_TexGeniv(table, save_TexGeniv); - SET_TexImage1D(table, save_TexImage1D); - SET_TexImage2D(table, save_TexImage2D); - SET_TexParameterf(table, save_TexParameterf); - SET_TexParameterfv(table, save_TexParameterfv); - SET_TexParameteri(table, save_TexParameteri); - SET_TexParameteriv(table, save_TexParameteriv); - SET_Translated(table, save_Translated); - SET_Translatef(table, save_Translatef); - SET_Viewport(table, save_Viewport); - - /* GL 1.1 */ - SET_AreTexturesResident(table, exec_AreTexturesResident); - SET_BindTexture(table, save_BindTexture); - SET_ColorPointer(table, exec_ColorPointer); - SET_CopyTexImage1D(table, save_CopyTexImage1D); - SET_CopyTexImage2D(table, save_CopyTexImage2D); - SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); - SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); - SET_DeleteTextures(table, exec_DeleteTextures); - SET_DisableClientState(table, exec_DisableClientState); - SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); - SET_EnableClientState(table, exec_EnableClientState); - SET_GenTextures(table, exec_GenTextures); - SET_GetPointerv(table, exec_GetPointerv); - SET_IndexPointer(table, exec_IndexPointer); - SET_InterleavedArrays(table, exec_InterleavedArrays); - SET_IsTexture(table, exec_IsTexture); - SET_NormalPointer(table, exec_NormalPointer); - SET_PopClientAttrib(table, exec_PopClientAttrib); - SET_PrioritizeTextures(table, save_PrioritizeTextures); - SET_PushClientAttrib(table, exec_PushClientAttrib); - SET_TexCoordPointer(table, exec_TexCoordPointer); - SET_TexSubImage1D(table, save_TexSubImage1D); - SET_TexSubImage2D(table, save_TexSubImage2D); - SET_VertexPointer(table, exec_VertexPointer); - - /* GL 1.2 */ - SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); - SET_TexImage3D(table, save_TexImage3D); - SET_TexSubImage3D(table, save_TexSubImage3D); - - /* GL 2.0 */ - SET_StencilFuncSeparate(table, save_StencilFuncSeparate); - SET_StencilMaskSeparate(table, save_StencilMaskSeparate); - SET_StencilOpSeparate(table, save_StencilOpSeparate); - - /* ATI_separate_stencil */ - SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); - - /* GL_ARB_imaging */ - /* Not all are supported */ - SET_BlendColor(table, save_BlendColor); - SET_BlendEquation(table, save_BlendEquation); - SET_ColorSubTable(table, save_ColorSubTable); - SET_ColorTable(table, save_ColorTable); - SET_ColorTableParameterfv(table, save_ColorTableParameterfv); - SET_ColorTableParameteriv(table, save_ColorTableParameteriv); - SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); - SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); - SET_ConvolutionParameterf(table, save_ConvolutionParameterf); - SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); - SET_ConvolutionParameteri(table, save_ConvolutionParameteri); - SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); - SET_CopyColorSubTable(table, save_CopyColorSubTable); - SET_CopyColorTable(table, save_CopyColorTable); - SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); - SET_GetColorTable(table, exec_GetColorTable); - SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); - SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); - SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); - SET_GetHistogram(table, exec_GetHistogram); - SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); - SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); - SET_GetMinmax(table, exec_GetMinmax); - SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); - SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); - SET_GetSeparableFilter(table, exec_GetSeparableFilter); - SET_Histogram(table, save_Histogram); - SET_Minmax(table, save_Minmax); - SET_ResetHistogram(table, save_ResetHistogram); - SET_ResetMinmax(table, save_ResetMinmax); - SET_SeparableFilter2D(table, exec_SeparableFilter2D); - - /* 2. GL_EXT_blend_color */ -#if 0 - SET_BlendColorEXT(table, save_BlendColorEXT); -#endif - - /* 3. GL_EXT_polygon_offset */ - SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); - - /* 6. GL_EXT_texture3d */ -#if 0 - SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); - SET_TexImage3DEXT(table, save_TexImage3DEXT); - SET_TexSubImage3DEXT(table, save_TexSubImage3D); -#endif - - /* 14. GL_SGI_color_table */ -#if 0 - SET_ColorTableSGI(table, save_ColorTable); - SET_ColorSubTableSGI(table, save_ColorSubTable); - SET_GetColorTableSGI(table, exec_GetColorTable); - SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); -#endif - - /* 30. GL_EXT_vertex_array */ - SET_ColorPointerEXT(table, exec_ColorPointerEXT); - SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); - SET_IndexPointerEXT(table, exec_IndexPointerEXT); - SET_NormalPointerEXT(table, exec_NormalPointerEXT); - SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); - SET_VertexPointerEXT(table, exec_VertexPointerEXT); - - /* 37. GL_EXT_blend_minmax */ -#if 0 - SET_BlendEquationEXT(table, save_BlendEquationEXT); -#endif - - /* 54. GL_EXT_point_parameters */ - SET_PointParameterfEXT(table, save_PointParameterfEXT); - SET_PointParameterfvEXT(table, save_PointParameterfvEXT); - - /* 97. GL_EXT_compiled_vertex_array */ - SET_LockArraysEXT(table, exec_LockArraysEXT); - SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); - - /* 145. GL_EXT_secondary_color */ - SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); - - /* 148. GL_EXT_multi_draw_arrays */ - SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); - - /* 149. GL_EXT_fog_coord */ - SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); - - /* 173. GL_EXT_blend_func_separate */ - SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); - - /* 196. GL_MESA_resize_buffers */ - SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(table, save_WindowPos2dMESA); - SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); - SET_WindowPos2fMESA(table, save_WindowPos2fMESA); - SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); - SET_WindowPos2iMESA(table, save_WindowPos2iMESA); - SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); - SET_WindowPos2sMESA(table, save_WindowPos2sMESA); - SET_WindowPos2svMESA(table, save_WindowPos2svMESA); - SET_WindowPos3dMESA(table, save_WindowPos3dMESA); - SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); - SET_WindowPos3fMESA(table, save_WindowPos3fMESA); - SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); - SET_WindowPos3iMESA(table, save_WindowPos3iMESA); - SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); - SET_WindowPos3sMESA(table, save_WindowPos3sMESA); - SET_WindowPos3svMESA(table, save_WindowPos3svMESA); - SET_WindowPos4dMESA(table, save_WindowPos4dMESA); - SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); - SET_WindowPos4fMESA(table, save_WindowPos4fMESA); - SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); - SET_WindowPos4iMESA(table, save_WindowPos4iMESA); - SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); - SET_WindowPos4sMESA(table, save_WindowPos4sMESA); - SET_WindowPos4svMESA(table, save_WindowPos4svMESA); - - /* 200. GL_IBM_multimode_draw_arrays */ - SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); - -#if FEATURE_NV_vertex_program - /* 233. GL_NV_vertex_program */ - /* The following commands DO NOT go into display lists: - * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, - * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* - */ - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_ExecuteProgramNV(table, save_ExecuteProgramNV); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(table, _mesa_GetProgramivNV); - SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_LoadProgramNV(table, save_LoadProgramNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); - SET_TrackMatrixNV(table, save_TrackMatrixNV); - SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); -#endif - - /* 244. GL_ATI_envmap_bumpmap */ - SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); - - /* 245. GL_ATI_fragment_shader */ -#if FEATURE_ATI_fragment_shader - SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); - SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); -#endif - - /* 282. GL_NV_fragment_program */ -#if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(table, - _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(table, - _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); -#endif - - /* 262. GL_NV_point_sprite */ - SET_PointParameteriNV(table, save_PointParameteriNV); - SET_PointParameterivNV(table, save_PointParameterivNV); - - /* 268. GL_EXT_stencil_two_side */ - SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); - - /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); - SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); - SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(table, save_DepthBoundsEXT); - - /* ARB 1. GL_ARB_multitexture */ - SET_ActiveTextureARB(table, save_ActiveTextureARB); - SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); - - /* ARB 3. GL_ARB_transpose_matrix */ - SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); - - /* ARB 5. GL_ARB_multisample */ - SET_SampleCoverageARB(table, save_SampleCoverageARB); - - /* ARB 12. GL_ARB_texture_compression */ - SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); - SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); - SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); - SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); - SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); - SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); - SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); - - /* ARB 14. GL_ARB_point_parameters */ - /* aliased with EXT_point_parameters functions */ - - /* ARB 25. GL_ARB_window_pos */ - /* aliased with MESA_window_pos functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ - SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(table, save_ProgramStringARB); - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(table, _mesa_GetProgramivARB); - SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); -#endif - - /* ARB 28. GL_ARB_vertex_buffer_object */ -#if FEATURE_ARB_vertex_buffer_object - /* None of the extension's functions get compiled */ - SET_BindBufferARB(table, _mesa_BindBufferARB); - SET_BufferDataARB(table, _mesa_BufferDataARB); - SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(table, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(table, _mesa_IsBufferARB); - SET_MapBufferARB(table, _mesa_MapBufferARB); - SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); -#endif - -#if FEATURE_queryobj - SET_BeginQueryARB(table, save_BeginQueryARB); - SET_EndQueryARB(table, save_EndQueryARB); - SET_GenQueriesARB(table, _mesa_GenQueriesARB); - SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB); - SET_IsQueryARB(table, _mesa_IsQueryARB); - SET_GetQueryivARB(table, _mesa_GetQueryivARB); - SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB); - SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB); -#endif - SET_DrawBuffersARB(table, save_DrawBuffersARB); - -#if FEATURE_EXT_framebuffer_blit - SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); -#endif - - /* GL_ARB_shader_objects */ - SET_UseProgramObjectARB(table, save_UseProgramObjectARB); - SET_Uniform1fARB(table, save_Uniform1fARB); - SET_Uniform2fARB(table, save_Uniform2fARB); - SET_Uniform3fARB(table, save_Uniform3fARB); - SET_Uniform4fARB(table, save_Uniform4fARB); - SET_Uniform1fvARB(table, save_Uniform1fvARB); - SET_Uniform2fvARB(table, save_Uniform2fvARB); - SET_Uniform3fvARB(table, save_Uniform3fvARB); - SET_Uniform4fvARB(table, save_Uniform4fvARB); - SET_Uniform1iARB(table, save_Uniform1iARB); - SET_Uniform2iARB(table, save_Uniform2iARB); - SET_Uniform3iARB(table, save_Uniform3iARB); - SET_Uniform4iARB(table, save_Uniform4iARB); - SET_Uniform1ivARB(table, save_Uniform1ivARB); - SET_Uniform2ivARB(table, save_Uniform2ivARB); - SET_Uniform3ivARB(table, save_Uniform3ivARB); - SET_Uniform4ivARB(table, save_Uniform4ivARB); - SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); - SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); - - /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); - SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); - SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); - /* XXX additional functions need to be implemented here! */ - - /* 299. GL_EXT_blend_equation_separate */ - SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); -#endif - - /* ARB 50. GL_ARB_map_buffer_range */ -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ - SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ -#endif - - /* ARB 59. GL_ARB_copy_buffer */ - SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ - - /* 352. GL_EXT_transform_feedback */ -#if FEATURE_EXT_transform_feedback - SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); - SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); -#endif - - /* 364. GL_EXT_provoking_vertex */ - SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); - - /* 371. GL_APPLE_object_purgeable */ -#if FEATURE_APPLE_object_purgeable - SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); - SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); -#endif - - /* GL_EXT_texture_integer */ - SET_ClearColorIiEXT(table, save_ClearColorIi); - SET_ClearColorIuiEXT(table, save_ClearColorIui); - SET_TexParameterIivEXT(table, save_TexParameterIiv); - SET_TexParameterIuivEXT(table, save_TexParameterIuiv); - SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); - SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); - - /* 377. GL_EXT_separate_shader_objects */ - SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); - SET_ActiveProgramEXT(table, save_ActiveProgramEXT); - - /* GL 3.0 */ -#if 0 - SET_ClearBufferiv(table, save_ClearBufferiv); - SET_ClearBufferuiv(table, save_ClearBufferuiv); - SET_ClearBufferfv(table, save_ClearBufferfv); - SET_ClearBufferfi(table, save_ClearBufferfi); - SET_Uniform1ui(table, save_Uniform1ui); - SET_Uniform2ui(table, save_Uniform2ui); - SET_Uniform3ui(table, save_Uniform3ui); - SET_Uniform4ui(table, save_Uniform4ui); - SET_Uniform1uiv(table, save_Uniform1uiv); - SET_Uniform2uiv(table, save_Uniform2uiv); - SET_Uniform3uiv(table, save_Uniform3uiv); - SET_Uniform4uiv(table, save_Uniform4uiv); -#else - (void) save_ClearBufferiv; - (void) save_ClearBufferuiv; - (void) save_ClearBufferfv; - (void) save_ClearBufferfi; - (void) save_Uniform1ui; - (void) save_Uniform2ui; - (void) save_Uniform3ui; - (void) save_Uniform4ui; - (void) save_Uniform1uiv; - (void) save_Uniform2uiv; - (void) save_Uniform3uiv; - (void) save_Uniform4uiv; -#endif - - /* GL_ARB_instanced_arrays */ - SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor); - - /* GL_ARB_draw_buffer_blend */ - SET_BlendFunciARB(table, save_BlendFunci); - SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei); - SET_BlendEquationiARB(table, save_BlendEquationi); - SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei); - - return table; -} - - - -static const char * -enum_string(GLenum k) -{ - return _mesa_lookup_enum_by_nr(k); -} - - -/** - * Print the commands in a display list. For debugging only. - * TODO: many commands aren't handled yet. - */ -static void GLAPIENTRY -print_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (!islist(ctx, list)) { - printf("%u is not a display list ID\n", list); - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - n = dlist->Head; - - printf("START-LIST %u, address %p\n", list, (void *) n); - - done = n ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_print(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ACCUM: - printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); - break; - case OPCODE_BITMAP: - printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); - break; - case OPCODE_CALL_LIST: - printf("CallList %d\n", (int) n[1].ui); - break; - case OPCODE_CALL_LIST_OFFSET: - printf("CallList %d + offset %u = %u\n", (int) n[1].ui, - ctx->List.ListBase, ctx->List.ListBase + n[1].ui); - break; - case OPCODE_COLOR_TABLE_PARAMETER_FV: - printf("ColorTableParameterfv %s %s %f %f %f %f\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_COLOR_TABLE_PARAMETER_IV: - printf("ColorTableParameteriv %s %s %d %d %d %d\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].i, n[4].i, n[5].i, n[6].i); - break; - case OPCODE_DISABLE: - printf("Disable %s\n", enum_string(n[1].e)); - break; - case OPCODE_ENABLE: - printf("Enable %s\n", enum_string(n[1].e)); - break; - case OPCODE_FRUSTUM: - printf("Frustum %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_LINE_STIPPLE: - printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); - break; - case OPCODE_LOAD_IDENTITY: - printf("LoadIdentity\n"); - break; - case OPCODE_LOAD_MATRIX: - printf("LoadMatrix\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_MULT_MATRIX: - printf("MultMatrix (or Rotate)\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_ORTHO: - printf("Ortho %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_POP_ATTRIB: - printf("PopAttrib\n"); - break; - case OPCODE_POP_MATRIX: - printf("PopMatrix\n"); - break; - case OPCODE_POP_NAME: - printf("PopName\n"); - break; - case OPCODE_PUSH_ATTRIB: - printf("PushAttrib %x\n", n[1].bf); - break; - case OPCODE_PUSH_MATRIX: - printf("PushMatrix\n"); - break; - case OPCODE_PUSH_NAME: - printf("PushName %d\n", (int) n[1].ui); - break; - case OPCODE_RASTER_POS: - printf("RasterPos %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ROTATE: - printf("Rotate %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_SCALE: - printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_TRANSLATE: - printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_BIND_TEXTURE: - printf("BindTexture %s %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); - break; - case OPCODE_SHADE_MODEL: - printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); - break; - case OPCODE_MAP1: - printf("Map1 %s %.3f %.3f %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].i, n[5].i); - break; - case OPCODE_MAP2: - printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].f, n[5].f, - n[6].i, n[7].i, n[8].i, n[9].i); - break; - case OPCODE_MAPGRID1: - printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); - break; - case OPCODE_MAPGRID2: - printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", - n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); - break; - case OPCODE_EVALMESH1: - printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); - break; - case OPCODE_EVALMESH2: - printf("EvalMesh2 %d %d %d %d\n", - n[1].i, n[2].i, n[3].i, n[4].i); - break; - - case OPCODE_ATTR_1F_NV: - printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_NV: - printf("ATTR_2F_NV attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_NV: - printf("ATTR_3F_NV attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_NV: - printf("ATTR_4F_NV attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - case OPCODE_ATTR_1F_ARB: - printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_ARB: - printf("ATTR_2F_ARB attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_ARB: - printf("ATTR_3F_ARB attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_ARB: - printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - - case OPCODE_MATERIAL: - printf("MATERIAL %x %x: %f %f %f %f\n", - n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_BEGIN: - printf("BEGIN %x\n", n[1].i); - break; - case OPCODE_END: - printf("END\n"); - break; - case OPCODE_RECTF: - printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, - n[4].f); - break; - case OPCODE_EVAL_C1: - printf("EVAL_C1 %f\n", n[1].f); - break; - case OPCODE_EVAL_C2: - printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); - break; - case OPCODE_EVAL_P1: - printf("EVAL_P1 %d\n", n[1].i); - break; - case OPCODE_EVAL_P2: - printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); - break; - - case OPCODE_PROVOKING_VERTEX: - printf("ProvokingVertex %s\n", - _mesa_lookup_enum_by_nr(n[1].ui)); - break; - - /* - * meta opcodes/commands - */ - case OPCODE_ERROR: - printf("Error: %s %s\n", - enum_string(n[1].e), (const char *) n[2].data); - break; - case OPCODE_CONTINUE: - printf("DISPLAY-LIST-CONTINUE\n"); - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - printf("END-LIST %u\n", list); - done = GL_TRUE; - break; - default: - if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { - printf - ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", - opcode, (void *) n); - return; - } - else { - printf("command %d, %u operands\n", opcode, - InstSize[opcode]); - } - } - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } -} - - - -/** - * Clients may call this function to help debug display list problems. - * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, - * changed, or break in the future without notice. - */ -void -mesa_print_display_list(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - print_list(ctx, list); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void -_mesa_save_vtxfmt_init(GLvertexformat * vfmt) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = save_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, save_); - - vfmt->Color3f = save_Color3f; - vfmt->Color3fv = save_Color3fv; - vfmt->Color4f = save_Color4f; - vfmt->Color4fv = save_Color4fv; - vfmt->EdgeFlag = save_EdgeFlag; - vfmt->End = save_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, save_); - - vfmt->FogCoordfEXT = save_FogCoordfEXT; - vfmt->FogCoordfvEXT = save_FogCoordfvEXT; - vfmt->Indexf = save_Indexf; - vfmt->Indexfv = save_Indexfv; - vfmt->Materialfv = save_Materialfv; - vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; - vfmt->Normal3f = save_Normal3f; - vfmt->Normal3fv = save_Normal3fv; - vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; - vfmt->TexCoord1f = save_TexCoord1f; - vfmt->TexCoord1fv = save_TexCoord1fv; - vfmt->TexCoord2f = save_TexCoord2f; - vfmt->TexCoord2fv = save_TexCoord2fv; - vfmt->TexCoord3f = save_TexCoord3f; - vfmt->TexCoord3fv = save_TexCoord3fv; - vfmt->TexCoord4f = save_TexCoord4f; - vfmt->TexCoord4fv = save_TexCoord4fv; - vfmt->Vertex2f = save_Vertex2f; - vfmt->Vertex2fv = save_Vertex2fv; - vfmt->Vertex3f = save_Vertex3f; - vfmt->Vertex3fv = save_Vertex3fv; - vfmt->Vertex4f = save_Vertex4f; - vfmt->Vertex4fv = save_Vertex4fv; - vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; - - vfmt->Rectf = save_Rectf; - - /* The driver is required to implement these as - * 1) They can probably do a better job. - * 2) A lot of new mechanisms would have to be added to this module - * to support it. That code would probably never get used, - * because of (1). - */ -#if 0 - vfmt->DrawArrays = 0; - vfmt->DrawElements = 0; - vfmt->DrawRangeElements = 0; - vfmt->MultiDrawElemementsEXT = 0; - vfmt->DrawElementsBaseVertex = 0; - vfmt->DrawRangeElementsBaseVertex = 0; - vfmt->MultiDrawElemementsBaseVertex = 0; -#endif -} - - -void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_CallList(disp, vfmt->CallList); - SET_CallLists(disp, vfmt->CallLists); -} - - -void _mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ - SET_CallList(disp, _mesa_CallList); - SET_CallLists(disp, _mesa_CallLists); - - SET_DeleteLists(disp, _mesa_DeleteLists); - SET_EndList(disp, _mesa_EndList); - SET_GenLists(disp, _mesa_GenLists); - SET_IsList(disp, _mesa_IsList); - SET_ListBase(disp, _mesa_ListBase); - SET_NewList(disp, _mesa_NewList); -} - - -#endif /* FEATURE_dlist */ - - -/** - * Initialize display list state for given context. - */ -void -_mesa_init_display_list(struct gl_context *ctx) -{ - static GLboolean tableInitialized = GL_FALSE; - - /* zero-out the instruction size table, just once */ - if (!tableInitialized) { - memset(InstSize, 0, sizeof(InstSize)); - tableInitialized = GL_TRUE; - } - - /* extension info */ - ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); - - /* Display list */ - ctx->ListState.CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->ListState.CurrentBlock = NULL; - ctx->ListState.CurrentPos = 0; - - /* Display List group */ - ctx->List.ListBase = 0; - -#if FEATURE_dlist - _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); -#endif -} - - -void -_mesa_free_display_list_data(struct gl_context *ctx) -{ - free(ctx->ListExt); - ctx->ListExt = NULL; -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file dlist.c + * Display lists management functions. + */ + +#include "glheader.h" +#include "imports.h" +#include "api_arrayelt.h" +#include "api_exec.h" +#include "api_loopback.h" +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif +#include "config.h" +#include "mfeatures.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#include "context.h" +#include "dlist.h" +#include "enums.h" +#include "eval.h" +#include "framebuffer.h" +#include "glapi/glapi.h" +#include "hash.h" +#include "image.h" +#include "light.h" +#include "macros.h" +#include "pack.h" +#include "queryobj.h" +#include "teximage.h" +#include "mtypes.h" +#include "varray.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "arbprogram.h" +#endif +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "nvprogram.h" +#endif + +#include "math/m_matrix.h" + +#include "main/dispatch.h" + + + +/** + * Other parts of Mesa (such as the VBO module) can plug into the display + * list system. This structure describes new display list instructions. + */ +struct gl_list_instruction +{ + GLuint Size; + void (*Execute)( struct gl_context *ctx, void *data ); + void (*Destroy)( struct gl_context *ctx, void *data ); + void (*Print)( struct gl_context *ctx, void *data ); +}; + + +#define MAX_DLIST_EXT_OPCODES 16 + +/** + * Used by device drivers to hook new commands into display lists. + */ +struct gl_list_extensions +{ + struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; + GLuint NumOpcodes; +}; + + + +/** + * Flush vertices. + * + * \param ctx GL context. + * + * Checks if dd_function_table::SaveNeedFlush is marked to flush + * stored (save) vertices, and calls + * dd_function_table::SaveFlushVertices if so. + */ +#define SAVE_FLUSH_VERTICES(ctx) \ +do { \ + if (ctx->Driver.SaveNeedFlush) \ + ctx->Driver.SaveFlushVertices(ctx); \ +} while (0) + + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + + + +/** + * Display list opcodes. + * + * The fact that these identifiers are assigned consecutive + * integer values starting at 0 is very important, see InstSize array usage) + */ +typedef enum +{ + OPCODE_INVALID = -1, /* Force signed enum */ + OPCODE_ACCUM, + OPCODE_ALPHA_FUNC, + OPCODE_BIND_TEXTURE, + OPCODE_BITMAP, + OPCODE_BLEND_COLOR, + OPCODE_BLEND_EQUATION, + OPCODE_BLEND_EQUATION_SEPARATE, + OPCODE_BLEND_FUNC_SEPARATE, + + OPCODE_BLEND_EQUATION_I, + OPCODE_BLEND_EQUATION_SEPARATE_I, + OPCODE_BLEND_FUNC_I, + OPCODE_BLEND_FUNC_SEPARATE_I, + + OPCODE_CALL_LIST, + OPCODE_CALL_LIST_OFFSET, + OPCODE_CLEAR, + OPCODE_CLEAR_ACCUM, + OPCODE_CLEAR_COLOR, + OPCODE_CLEAR_DEPTH, + OPCODE_CLEAR_INDEX, + OPCODE_CLEAR_STENCIL, + OPCODE_CLEAR_BUFFER_IV, + OPCODE_CLEAR_BUFFER_UIV, + OPCODE_CLEAR_BUFFER_FV, + OPCODE_CLEAR_BUFFER_FI, + OPCODE_CLIP_PLANE, + OPCODE_COLOR_MASK, + OPCODE_COLOR_MASK_INDEXED, + OPCODE_COLOR_MATERIAL, + OPCODE_COLOR_TABLE, + OPCODE_COLOR_TABLE_PARAMETER_FV, + OPCODE_COLOR_TABLE_PARAMETER_IV, + OPCODE_COLOR_SUB_TABLE, + OPCODE_CONVOLUTION_FILTER_1D, + OPCODE_CONVOLUTION_FILTER_2D, + OPCODE_CONVOLUTION_PARAMETER_I, + OPCODE_CONVOLUTION_PARAMETER_IV, + OPCODE_CONVOLUTION_PARAMETER_F, + OPCODE_CONVOLUTION_PARAMETER_FV, + OPCODE_COPY_COLOR_SUB_TABLE, + OPCODE_COPY_COLOR_TABLE, + OPCODE_COPY_PIXELS, + OPCODE_COPY_TEX_IMAGE1D, + OPCODE_COPY_TEX_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE1D, + OPCODE_COPY_TEX_SUB_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE3D, + OPCODE_CULL_FACE, + OPCODE_DEPTH_FUNC, + OPCODE_DEPTH_MASK, + OPCODE_DEPTH_RANGE, + OPCODE_DISABLE, + OPCODE_DISABLE_INDEXED, + OPCODE_DRAW_BUFFER, + OPCODE_DRAW_PIXELS, + OPCODE_ENABLE, + OPCODE_ENABLE_INDEXED, + OPCODE_EVALMESH1, + OPCODE_EVALMESH2, + OPCODE_FOG, + OPCODE_FRONT_FACE, + OPCODE_FRUSTUM, + OPCODE_HINT, + OPCODE_HISTOGRAM, + OPCODE_INDEX_MASK, + OPCODE_INIT_NAMES, + OPCODE_LIGHT, + OPCODE_LIGHT_MODEL, + OPCODE_LINE_STIPPLE, + OPCODE_LINE_WIDTH, + OPCODE_LIST_BASE, + OPCODE_LOAD_IDENTITY, + OPCODE_LOAD_MATRIX, + OPCODE_LOAD_NAME, + OPCODE_LOGIC_OP, + OPCODE_MAP1, + OPCODE_MAP2, + OPCODE_MAPGRID1, + OPCODE_MAPGRID2, + OPCODE_MATRIX_MODE, + OPCODE_MIN_MAX, + OPCODE_MULT_MATRIX, + OPCODE_ORTHO, + OPCODE_PASSTHROUGH, + OPCODE_PIXEL_MAP, + OPCODE_PIXEL_TRANSFER, + OPCODE_PIXEL_ZOOM, + OPCODE_POINT_SIZE, + OPCODE_POINT_PARAMETERS, + OPCODE_POLYGON_MODE, + OPCODE_POLYGON_STIPPLE, + OPCODE_POLYGON_OFFSET, + OPCODE_POP_ATTRIB, + OPCODE_POP_MATRIX, + OPCODE_POP_NAME, + OPCODE_PRIORITIZE_TEXTURE, + OPCODE_PUSH_ATTRIB, + OPCODE_PUSH_MATRIX, + OPCODE_PUSH_NAME, + OPCODE_RASTER_POS, + OPCODE_READ_BUFFER, + OPCODE_RESET_HISTOGRAM, + OPCODE_RESET_MIN_MAX, + OPCODE_ROTATE, + OPCODE_SCALE, + OPCODE_SCISSOR, + OPCODE_SELECT_TEXTURE_SGIS, + OPCODE_SELECT_TEXTURE_COORD_SET, + OPCODE_SHADE_MODEL, + OPCODE_STENCIL_FUNC, + OPCODE_STENCIL_MASK, + OPCODE_STENCIL_OP, + OPCODE_TEXENV, + OPCODE_TEXGEN, + OPCODE_TEXPARAMETER, + OPCODE_TEX_IMAGE1D, + OPCODE_TEX_IMAGE2D, + OPCODE_TEX_IMAGE3D, + OPCODE_TEX_SUB_IMAGE1D, + OPCODE_TEX_SUB_IMAGE2D, + OPCODE_TEX_SUB_IMAGE3D, + OPCODE_TRANSLATE, + OPCODE_VIEWPORT, + OPCODE_WINDOW_POS, + /* GL_ARB_multitexture */ + OPCODE_ACTIVE_TEXTURE, + /* GL_ARB_texture_compression */ + OPCODE_COMPRESSED_TEX_IMAGE_1D, + OPCODE_COMPRESSED_TEX_IMAGE_2D, + OPCODE_COMPRESSED_TEX_IMAGE_3D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, + /* GL_ARB_multisample */ + OPCODE_SAMPLE_COVERAGE, + /* GL_ARB_window_pos */ + OPCODE_WINDOW_POS_ARB, + /* GL_NV_vertex_program */ + OPCODE_BIND_PROGRAM_NV, + OPCODE_EXECUTE_PROGRAM_NV, + OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, + OPCODE_LOAD_PROGRAM_NV, + OPCODE_TRACK_MATRIX_NV, + /* GL_NV_fragment_program */ + OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, + OPCODE_PROGRAM_NAMED_PARAMETER_NV, + /* GL_EXT_stencil_two_side */ + OPCODE_ACTIVE_STENCIL_FACE_EXT, + /* GL_EXT_depth_bounds_test */ + OPCODE_DEPTH_BOUNDS_EXT, + /* GL_ARB_vertex/fragment_program */ + OPCODE_PROGRAM_STRING_ARB, + OPCODE_PROGRAM_ENV_PARAMETER_ARB, + /* GL_ARB_occlusion_query */ + OPCODE_BEGIN_QUERY_ARB, + OPCODE_END_QUERY_ARB, + /* GL_ARB_draw_buffers */ + OPCODE_DRAW_BUFFERS_ARB, + /* GL_ATI_fragment_shader */ + OPCODE_TEX_BUMP_PARAMETER_ATI, + /* GL_ATI_fragment_shader */ + OPCODE_BIND_FRAGMENT_SHADER_ATI, + OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, + /* OpenGL 2.0 */ + OPCODE_STENCIL_FUNC_SEPARATE, + OPCODE_STENCIL_OP_SEPARATE, + OPCODE_STENCIL_MASK_SEPARATE, + + /* GL_ARB_shader_objects */ + OPCODE_USE_PROGRAM, + OPCODE_UNIFORM_1F, + OPCODE_UNIFORM_2F, + OPCODE_UNIFORM_3F, + OPCODE_UNIFORM_4F, + OPCODE_UNIFORM_1FV, + OPCODE_UNIFORM_2FV, + OPCODE_UNIFORM_3FV, + OPCODE_UNIFORM_4FV, + OPCODE_UNIFORM_1I, + OPCODE_UNIFORM_2I, + OPCODE_UNIFORM_3I, + OPCODE_UNIFORM_4I, + OPCODE_UNIFORM_1IV, + OPCODE_UNIFORM_2IV, + OPCODE_UNIFORM_3IV, + OPCODE_UNIFORM_4IV, + OPCODE_UNIFORM_MATRIX22, + OPCODE_UNIFORM_MATRIX33, + OPCODE_UNIFORM_MATRIX44, + OPCODE_UNIFORM_MATRIX23, + OPCODE_UNIFORM_MATRIX32, + OPCODE_UNIFORM_MATRIX24, + OPCODE_UNIFORM_MATRIX42, + OPCODE_UNIFORM_MATRIX34, + OPCODE_UNIFORM_MATRIX43, + + /* OpenGL 3.0 */ + OPCODE_UNIFORM_1UI, + OPCODE_UNIFORM_2UI, + OPCODE_UNIFORM_3UI, + OPCODE_UNIFORM_4UI, + OPCODE_UNIFORM_1UIV, + OPCODE_UNIFORM_2UIV, + OPCODE_UNIFORM_3UIV, + OPCODE_UNIFORM_4UIV, + + /* GL_EXT_framebuffer_blit */ + OPCODE_BLIT_FRAMEBUFFER, + + /* Vertex attributes -- fallback for when optimized display + * list build isn't active. + */ + OPCODE_ATTR_1F_NV, + OPCODE_ATTR_2F_NV, + OPCODE_ATTR_3F_NV, + OPCODE_ATTR_4F_NV, + OPCODE_ATTR_1F_ARB, + OPCODE_ATTR_2F_ARB, + OPCODE_ATTR_3F_ARB, + OPCODE_ATTR_4F_ARB, + OPCODE_MATERIAL, + OPCODE_BEGIN, + OPCODE_END, + OPCODE_RECTF, + OPCODE_EVAL_C1, + OPCODE_EVAL_C2, + OPCODE_EVAL_P1, + OPCODE_EVAL_P2, + + /* GL_EXT_provoking_vertex */ + OPCODE_PROVOKING_VERTEX, + + /* GL_EXT_transform_feedback */ + OPCODE_BEGIN_TRANSFORM_FEEDBACK, + OPCODE_END_TRANSFORM_FEEDBACK, + + /* GL_EXT_texture_integer */ + OPCODE_CLEARCOLOR_I, + OPCODE_CLEARCOLOR_UI, + OPCODE_TEXPARAMETER_I, + OPCODE_TEXPARAMETER_UI, + + /* GL_EXT_separate_shader_objects */ + OPCODE_ACTIVE_PROGRAM_EXT, + OPCODE_USE_SHADER_PROGRAM_EXT, + + /* GL_ARB_instanced_arrays */ + OPCODE_VERTEX_ATTRIB_DIVISOR, + + /* The following three are meta instructions */ + OPCODE_ERROR, /* raise compiled-in error */ + OPCODE_CONTINUE, + OPCODE_END_OF_LIST, + OPCODE_EXT_0 +} OpCode; + + + +/** + * Display list node. + * + * Display list instructions are stored as sequences of "nodes". Nodes + * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks + * are linked together with a pointer. + * + * Each instruction in the display list is stored as a sequence of + * contiguous nodes in memory. + * Each node is the union of a variety of data types. + */ +union gl_dlist_node +{ + OpCode opcode; + GLboolean b; + GLbitfield bf; + GLubyte ub; + GLshort s; + GLushort us; + GLint i; + GLuint ui; + GLenum e; + GLfloat f; + GLvoid *data; + void *next; /* If prev node's opcode==OPCODE_CONTINUE */ +}; + + +typedef union gl_dlist_node Node; + + +/** + * How many nodes to allocate at a time. + * + * \note Reduced now that we hold vertices etc. elsewhere. + */ +#define BLOCK_SIZE 256 + + + +/** + * Number of nodes of storage needed for each instruction. + * Sizes for dynamically allocated opcodes are stored in the context struct. + */ +static GLuint InstSize[OPCODE_END_OF_LIST + 1]; + + +#if FEATURE_dlist + + +void mesa_print_display_list(GLuint list); + + +/**********************************************************************/ +/***** Private *****/ +/**********************************************************************/ + + +/** + * Make an empty display list. This is used by glGenLists() to + * reserve display list IDs. + */ +static struct gl_display_list * +make_list(GLuint name, GLuint count) +{ + struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); + dlist->Name = name; + dlist->Head = (Node *) malloc(sizeof(Node) * count); + dlist->Head[0].opcode = OPCODE_END_OF_LIST; + return dlist; +} + + +/** + * Lookup function to just encapsulate casting. + */ +static INLINE struct gl_display_list * +lookup_list(struct gl_context *ctx, GLuint list) +{ + return (struct gl_display_list *) + _mesa_HashLookup(ctx->Shared->DisplayList, list); +} + + +/** Is the given opcode an extension code? */ +static INLINE GLboolean +is_ext_opcode(OpCode opcode) +{ + return (opcode >= OPCODE_EXT_0); +} + + +/** Destroy an extended opcode instruction */ +static GLint +ext_opcode_destroy(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Execute an extended opcode instruction */ +static GLint +ext_opcode_execute(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Print an extended opcode instruction */ +static GLint +ext_opcode_print(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Print(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** + * Delete the named display list, but don't remove from hash table. + * \param dlist - display list pointer + */ +void +_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) +{ + Node *n, *block; + GLboolean done; + + n = block = dlist->Head; + + done = block ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + /* check for extension opcodes first */ + if (is_ext_opcode(opcode)) { + n += ext_opcode_destroy(ctx, n); + } + else { + switch (opcode) { + /* for some commands, we need to free malloc'd memory */ + case OPCODE_MAP1: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_MAP2: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_DRAW_PIXELS: + free(n[5].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_BITMAP: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_SUB_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_1D: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_2D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_POLYGON_STIPPLE: + free(n[1].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE1D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE3D: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; +#if FEATURE_NV_vertex_program + case OPCODE_LOAD_PROGRAM_NV: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + free(n[2].data); /* array of program ids */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + free(n[3].data); /* parameter name */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; +#endif + case OPCODE_UNIFORM_1FV: + case OPCODE_UNIFORM_2FV: + case OPCODE_UNIFORM_3FV: + case OPCODE_UNIFORM_4FV: + case OPCODE_UNIFORM_1IV: + case OPCODE_UNIFORM_2IV: + case OPCODE_UNIFORM_3IV: + case OPCODE_UNIFORM_4IV: + case OPCODE_UNIFORM_1UIV: + case OPCODE_UNIFORM_2UIV: + case OPCODE_UNIFORM_3UIV: + case OPCODE_UNIFORM_4UIV: + free(n[3].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_UNIFORM_MATRIX22: + case OPCODE_UNIFORM_MATRIX33: + case OPCODE_UNIFORM_MATRIX44: + case OPCODE_UNIFORM_MATRIX24: + case OPCODE_UNIFORM_MATRIX42: + case OPCODE_UNIFORM_MATRIX23: + case OPCODE_UNIFORM_MATRIX32: + case OPCODE_UNIFORM_MATRIX34: + case OPCODE_UNIFORM_MATRIX43: + free(n[4].data); + n += InstSize[n[0].opcode]; + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + free(block); + block = n; + break; + case OPCODE_END_OF_LIST: + free(block); + done = GL_TRUE; + break; + default: + /* Most frequent case */ + n += InstSize[n[0].opcode]; + break; + } + } + } + + free(dlist); +} + + +/** + * Destroy a display list and remove from hash table. + * \param list - display list number + */ +static void +destroy_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + + if (list == 0) + return; + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + _mesa_delete_list(ctx, dlist); + _mesa_HashRemove(ctx->Shared->DisplayList, list); +} + + +/* + * Translate the nth element of list from to GLint. + */ +static GLint +translate_id(GLsizei n, GLenum type, const GLvoid * list) +{ + GLbyte *bptr; + GLubyte *ubptr; + GLshort *sptr; + GLushort *usptr; + GLint *iptr; + GLuint *uiptr; + GLfloat *fptr; + + switch (type) { + case GL_BYTE: + bptr = (GLbyte *) list; + return (GLint) bptr[n]; + case GL_UNSIGNED_BYTE: + ubptr = (GLubyte *) list; + return (GLint) ubptr[n]; + case GL_SHORT: + sptr = (GLshort *) list; + return (GLint) sptr[n]; + case GL_UNSIGNED_SHORT: + usptr = (GLushort *) list; + return (GLint) usptr[n]; + case GL_INT: + iptr = (GLint *) list; + return iptr[n]; + case GL_UNSIGNED_INT: + uiptr = (GLuint *) list; + return (GLint) uiptr[n]; + case GL_FLOAT: + fptr = (GLfloat *) list; + return (GLint) FLOORF(fptr[n]); + case GL_2_BYTES: + ubptr = ((GLubyte *) list) + 2 * n; + return (GLint) ubptr[0] * 256 + + (GLint) ubptr[1]; + case GL_3_BYTES: + ubptr = ((GLubyte *) list) + 3 * n; + return (GLint) ubptr[0] * 65536 + + (GLint) ubptr[1] * 256 + + (GLint) ubptr[2]; + case GL_4_BYTES: + ubptr = ((GLubyte *) list) + 4 * n; + return (GLint) ubptr[0] * 16777216 + + (GLint) ubptr[1] * 65536 + + (GLint) ubptr[2] * 256 + + (GLint) ubptr[3]; + default: + return 0; + } +} + + + + +/**********************************************************************/ +/***** Public *****/ +/**********************************************************************/ + +/** + * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. + * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. + */ +static GLvoid * +unpack_image(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels, + const struct gl_pixelstore_attrib *unpack) +{ + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, pixels, unpack); + if (pixels && !image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { + const GLubyte *map, *src; + GLvoid *image; + + map = (GLubyte *) + ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); + if (!map) { + /* unable to map src buffer! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); + return NULL; + } + + src = ADD_POINTERS(map, pixels); + image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, src, unpack); + + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + /* bad access! */ + return NULL; +} + + +/** + * Allocate space for a display list instruction (opcode + payload space). + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction payload size (not counting opcode) + * \return pointer to allocated memory (the opcode space) + */ +static Node * +dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) +{ + const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); + Node *n; + + if (opcode < (GLuint) OPCODE_EXT_0) { + if (InstSize[opcode] == 0) { + /* save instruction size now */ + InstSize[opcode] = numNodes; + } + else { + /* make sure instruction size agrees */ + ASSERT(numNodes == InstSize[opcode]); + } + } + + if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { + /* This block is full. Allocate a new block and chain to it */ + Node *newblock; + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + n[0].opcode = OPCODE_CONTINUE; + newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); + if (!newblock) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); + return NULL; + } + n[1].next = (Node *) newblock; + ctx->ListState.CurrentBlock = newblock; + ctx->ListState.CurrentPos = 0; + } + + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + ctx->ListState.CurrentPos += numNodes; + + n[0].opcode = opcode; + + return n; +} + + + +/** + * Allocate space for a display list instruction. Used by callers outside + * this file for things like VBO vertex data. + * + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction size in bytes, not counting opcode. + * \return pointer to the usable data area (not including the internal + * opcode). + */ +void * +_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) +{ + Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); + if (n) + return n + 1; /* return pointer to payload area, after opcode */ + else + return NULL; +} + + +/** + * This function allows modules and drivers to get their own opcodes + * for extending display list functionality. + * \param ctx the rendering context + * \param size number of bytes for storing the new display list command + * \param execute function to execute the new display list command + * \param destroy function to destroy the new display list command + * \param print function to print the new display list command + * \return the new opcode number or -1 if error + */ +GLint +_mesa_dlist_alloc_opcode(struct gl_context *ctx, + GLuint size, + void (*execute) (struct gl_context *, void *), + void (*destroy) (struct gl_context *, void *), + void (*print) (struct gl_context *, void *)) +{ + if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { + const GLuint i = ctx->ListExt->NumOpcodes++; + ctx->ListExt->Opcode[i].Size = + 1 + (size + sizeof(Node) - 1) / sizeof(Node); + ctx->ListExt->Opcode[i].Execute = execute; + ctx->ListExt->Opcode[i].Destroy = destroy; + ctx->ListExt->Opcode[i].Print = print; + return i + OPCODE_EXT_0; + } + return -1; +} + + +/** + * Allocate space for a display list instruction. The space is basically + * an array of Nodes where node[0] holds the opcode, node[1] is the first + * function parameter, node[2] is the second parameter, etc. + * + * \param opcode one of OPCODE_x + * \param nparams number of function parameters + * \return pointer to start of instruction space + */ +static INLINE Node * +alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) +{ + return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); +} + + + +/* + * Display List compilation functions + */ +static void GLAPIENTRY +save_Accum(GLenum op, GLfloat value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACCUM, 2); + if (n) { + n[1].e = op; + n[2].f = value; + } + if (ctx->ExecuteFlag) { + CALL_Accum(ctx->Exec, (op, value)); + } +} + + +static void GLAPIENTRY +save_AlphaFunc(GLenum func, GLclampf ref) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); + if (n) { + n[1].e = func; + n[2].f = (GLfloat) ref; + } + if (ctx->ExecuteFlag) { + CALL_AlphaFunc(ctx->Exec, (func, ref)); + } +} + + +static void GLAPIENTRY +save_BindTexture(GLenum target, GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); + if (n) { + n[1].e = target; + n[2].ui = texture; + } + if (ctx->ExecuteFlag) { + CALL_BindTexture(ctx->Exec, (target, texture)); + } +} + + +static void GLAPIENTRY +save_Bitmap(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, const GLubyte * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BITMAP, 7); + if (n) { + n[1].i = (GLint) width; + n[2].i = (GLint) height; + n[3].f = xorig; + n[4].f = yorig; + n[5].f = xmove; + n[6].f = ymove; + n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_Bitmap(ctx->Exec, (width, height, + xorig, yorig, xmove, ymove, pixels)); + } +} + + +static void GLAPIENTRY +save_BlendEquation(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquation(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); + if (n) { + n[1].e = modeRGB; + n[2].e = modeA; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); + } +} + + +static void GLAPIENTRY +save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); + if (n) { + n[1].e = sfactorRGB; + n[2].e = dfactorRGB; + n[3].e = sfactorA; + n[4].e = dfactorA; + } + if (ctx->ExecuteFlag) { + CALL_BlendFuncSeparateEXT(ctx->Exec, + (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); + } +} + + +static void GLAPIENTRY +save_BlendFunc(GLenum srcfactor, GLenum dstfactor) +{ + save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); +} + + +static void GLAPIENTRY +save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5); + if (n) { + n[1].ui = buf; + n[2].e = sfactorRGB; + n[3].e = dfactorRGB; + n[4].e = sfactorA; + n[5].e = dfactorA; + } + if (ctx->ExecuteFlag) { + CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB, + sfactorA, dfactorA)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3); + if (n) { + n[1].ui = buf; + n[2].e = sfactor; + n[3].e = dfactor; + } + if (ctx->ExecuteFlag) { + CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendEquationi(GLuint buf, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2); + if (n) { + n[1].ui = buf; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationiARB(ctx->Exec, (buf, mode)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3); + if (n) { + n[1].ui = buf; + n[2].e = modeRGB; + n[3].e = modeA; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA)); + } +} + + +static void invalidate_saved_current_state( struct gl_context *ctx ) +{ + GLint i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + ctx->ListState.ActiveAttribSize[i] = 0; + + for (i = 0; i < MAT_ATTRIB_MAX; i++) + ctx->ListState.ActiveMaterialSize[i] = 0; + + memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); + + ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; +} + +static void GLAPIENTRY +save_CallList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); + if (n) { + n[1].ui = list; + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + _mesa_CallList(list); + } +} + + +static void GLAPIENTRY +save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean typeErrorFlag; + + SAVE_FLUSH_VERTICES(ctx); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + typeErrorFlag = GL_FALSE; + break; + default: + typeErrorFlag = GL_TRUE; + } + + for (i = 0; i < num; i++) { + GLint list = translate_id(i, type, lists); + Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); + if (n) { + n[1].i = list; + n[2].b = typeErrorFlag; + } + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + CALL_CallLists(ctx->Exec, (num, type, lists)); + } +} + + +static void GLAPIENTRY +save_Clear(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_Clear(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].i = value[0]; + if (buffer == GL_COLOR) { + n[4].i = value[1]; + n[5].i = value[2]; + n[6].i = value[3]; + } + else { + n[4].i = 0; + n[5].i = 0; + n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].ui = value[0]; + if (buffer == GL_COLOR) { + n[4].ui = value[1]; + n[5].ui = value[2]; + n[6].ui = value[3]; + } + else { + n[4].ui = 0; + n[5].ui = 0; + n[6].ui = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = value[0]; + if (buffer == GL_COLOR) { + n[4].f = value[1]; + n[5].f = value[2]; + n[6].f = value[3]; + } + else { + n[4].f = 0.0F; + n[5].f = 0.0F; + n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = depth; + n[4].i = stencil; + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ + } +} + + +static void GLAPIENTRY +save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearDepth(GLclampd depth) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); + if (n) { + n[1].f = (GLfloat) depth; + } + if (ctx->ExecuteFlag) { + CALL_ClearDepth(ctx->Exec, (depth)); + } +} + + +static void GLAPIENTRY +save_ClearIndex(GLfloat c) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); + if (n) { + n[1].f = c; + } + if (ctx->ExecuteFlag) { + CALL_ClearIndex(ctx->Exec, (c)); + } +} + + +static void GLAPIENTRY +save_ClearStencil(GLint s) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); + if (n) { + n[1].i = s; + } + if (ctx->ExecuteFlag) { + CALL_ClearStencil(ctx->Exec, (s)); + } +} + + +static void GLAPIENTRY +save_ClipPlane(GLenum plane, const GLdouble * equ) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); + if (n) { + n[1].e = plane; + n[2].f = (GLfloat) equ[0]; + n[3].f = (GLfloat) equ[1]; + n[4].f = (GLfloat) equ[2]; + n[5].f = (GLfloat) equ[3]; + } + if (ctx->ExecuteFlag) { + CALL_ClipPlane(ctx->Exec, (plane, equ)); + } +} + + + +static void GLAPIENTRY +save_ColorMask(GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); + if (n) { + n[1].b = red; + n[2].b = green; + n[3].b = blue; + n[4].b = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); + if (n) { + n[1].ui = buf; + n[2].b = red; + n[3].b = green; + n[4].b = blue; + n[5].b = alpha; + } + if (ctx->ExecuteFlag) { + /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ + } +} + + +static void GLAPIENTRY +save_ColorMaterial(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ColorMaterial(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_ColorTable(GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + if (_mesa_is_proxy_texture(target)) { + /* execute immediately */ + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + } +} + + + +static void GLAPIENTRY +save_ColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); + } +} + + + +static void GLAPIENTRY +save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = count; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorSubTable(ctx->Exec, + (target, start, count, format, type, table)); + } +} + + +static void GLAPIENTRY +save_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); + if (n) { + n[1].e = target; + n[2].e = internalformat; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, + GLenum format, GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, + format, type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].i = height; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + n[5].e = type; + } + if (ctx->ExecuteFlag) { + CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); + } +} + + + +static void GLAPIENTRY +save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, + x, y, width, border)); + } +} + + +static void GLAPIENTRY +save_CopyTexImage2D(GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = height; + n[8].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, + x, y, width, height, border)); + } +} + + + +static void GLAPIENTRY +save_CopyTexSubImage1D(GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = x; + n[5].i = y; + n[6].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage1D(ctx->Exec, + (target, level, xoffset, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = x; + n[7].i = y; + n[8].i = width; + n[9].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CullFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_CullFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DepthFunc(GLenum func) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); + if (n) { + n[1].e = func; + } + if (ctx->ExecuteFlag) { + CALL_DepthFunc(ctx->Exec, (func)); + } +} + + +static void GLAPIENTRY +save_DepthMask(GLboolean mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); + if (n) { + n[1].b = mask; + } + if (ctx->ExecuteFlag) { + CALL_DepthMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_DepthRange(GLclampd nearval, GLclampd farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); + if (n) { + n[1].f = (GLfloat) nearval; + n[2].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_DepthRange(ctx->Exec, (nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Disable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Disable(ctx->Exec, (cap)); + } +} + + +static void GLAPIENTRY +save_DisableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + +static void GLAPIENTRY +save_DrawBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DrawPixels(GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); + if (n) { + n[1].i = width; + n[2].i = height; + n[3].e = format; + n[4].e = type; + n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); + } +} + + + +static void GLAPIENTRY +save_Enable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Enable(ctx->Exec, (cap)); + } +} + + + +static void GLAPIENTRY +save_EnableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + + +static void GLAPIENTRY +save_EvalMesh1(GLenum mode, GLint i1, GLint i2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); + } +} + + +static void GLAPIENTRY +save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + n[4].i = j1; + n[5].i = j2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); + } +} + + + + +static void GLAPIENTRY +save_Fogfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FOG, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_Fogfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_Fogf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Fogfv(pname, parray); +} + + +static void GLAPIENTRY +save_Fogiv(GLenum pname, const GLint *params) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + p[1] = 0.0f; + p[2] = 0.0f; + p[3] = 0.0f; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT(params[0]); + p[1] = INT_TO_FLOAT(params[1]); + p[2] = INT_TO_FLOAT(params[2]); + p[3] = INT_TO_FLOAT(params[3]); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_Fogfv(pname, p); +} + + +static void GLAPIENTRY +save_Fogi(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Fogiv(pname, parray); +} + + +static void GLAPIENTRY +save_FrontFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_FrontFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Frustum(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Hint(GLenum target, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HINT, 2); + if (n) { + n[1].e = target; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_Hint(ctx->Exec, (target, mode)); + } +} + + +static void GLAPIENTRY +save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, + GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); + if (n) { + n[1].e = target; + n[2].i = width; + n[3].e = internalFormat; + n[4].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_IndexMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_IndexMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_InitNames(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); + if (ctx->ExecuteFlag) { + CALL_InitNames(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT, 6); + if (n) { + GLint i, nParams; + n[1].e = light; + n[2].e = pname; + switch (pname) { + case GL_AMBIENT: + nParams = 4; + break; + case GL_DIFFUSE: + nParams = 4; + break; + case GL_SPECULAR: + nParams = 4; + break; + case GL_POSITION: + nParams = 4; + break; + case GL_SPOT_DIRECTION: + nParams = 3; + break; + case GL_SPOT_EXPONENT: + nParams = 1; + break; + case GL_SPOT_CUTOFF: + nParams = 1; + break; + case GL_CONSTANT_ATTENUATION: + nParams = 1; + break; + case GL_LINEAR_ATTENUATION: + nParams = 1; + break; + case GL_QUADRATIC_ATTENUATION: + nParams = 1; + break; + default: + nParams = 0; + } + for (i = 0; i < nParams; i++) { + n[3 + i].f = params[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_Lightfv(ctx->Exec, (light, pname, params)); + } +} + + +static void GLAPIENTRY +save_Lightf(GLenum light, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Lightfv(light, pname, parray); +} + + +static void GLAPIENTRY +save_Lightiv(GLenum light, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + save_Lightfv(light, pname, fparam); +} + + +static void GLAPIENTRY +save_Lighti(GLenum light, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Lightiv(light, pname, parray); +} + + +static void GLAPIENTRY +save_LightModelfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_LightModelfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_LightModelf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_LightModelfv(pname, parray); +} + + +static void GLAPIENTRY +save_LightModeliv(GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + fparam[1] = 0.0F; + fparam[2] = 0.0F; + fparam[3] = 0.0F; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_LightModelfv(pname, fparam); +} + + +static void GLAPIENTRY +save_LightModeli(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_LightModeliv(pname, parray); +} + + +static void GLAPIENTRY +save_LineStipple(GLint factor, GLushort pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); + if (n) { + n[1].i = factor; + n[2].us = pattern; + } + if (ctx->ExecuteFlag) { + CALL_LineStipple(ctx->Exec, (factor, pattern)); + } +} + + +static void GLAPIENTRY +save_LineWidth(GLfloat width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); + if (n) { + n[1].f = width; + } + if (ctx->ExecuteFlag) { + CALL_LineWidth(ctx->Exec, (width)); + } +} + + +static void GLAPIENTRY +save_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); + if (n) { + n[1].ui = base; + } + if (ctx->ExecuteFlag) { + CALL_ListBase(ctx->Exec, (base)); + } +} + + +static void GLAPIENTRY +save_LoadIdentity(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); + if (ctx->ExecuteFlag) { + CALL_LoadIdentity(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_LoadMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_LoadMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_LoadMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_LoadMatrixf(f); +} + + +static void GLAPIENTRY +save_LoadName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_LoadName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_LogicOp(GLenum opcode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); + if (n) { + n[1].e = opcode; + } + if (ctx->ExecuteFlag) { + CALL_LogicOp(ctx->Exec, (opcode)); + } +} + + +static void GLAPIENTRY +save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + +static void GLAPIENTRY +save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + + +static void GLAPIENTRY +save_Map2d(GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].f = (GLfloat) v1; + n[5].f = (GLfloat) v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2d(ctx->Exec, (target, + u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_Map2f(GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].f = v1; + n[5].f = v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); + } +} + + +static void GLAPIENTRY +save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) +{ + save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); +} + + +static void GLAPIENTRY +save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + n[4].i = vn; + n[5].f = v1; + n[6].f = v2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); + } +} + + + +static void GLAPIENTRY +save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2) +{ + save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2); +} + + +static void GLAPIENTRY +save_MatrixMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_MatrixMode(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_MultMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_MultMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_MultMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_MultMatrixf(f); +} + + +static void GLAPIENTRY +save_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + /* It's an error to call this function while building a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + (void) name; + (void) mode; +} + + + +static void GLAPIENTRY +save_Ortho(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ORTHO, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); + if (n) { + n[1].e = map; + n[2].i = mapsize; + n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); + memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); + } +} + + +static void GLAPIENTRY +save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = UINT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = USHORT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelTransferf(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); + if (n) { + n[1].e = pname; + n[2].f = param; + } + if (ctx->ExecuteFlag) { + CALL_PixelTransferf(ctx->Exec, (pname, param)); + } +} + + +static void GLAPIENTRY +save_PixelTransferi(GLenum pname, GLint param) +{ + save_PixelTransferf(pname, (GLfloat) param); +} + + +static void GLAPIENTRY +save_PixelZoom(GLfloat xfactor, GLfloat yfactor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); + if (n) { + n[1].f = xfactor; + n[2].f = yfactor; + } + if (ctx->ExecuteFlag) { + CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); + } +} + + +static void GLAPIENTRY +save_PointParameterfvEXT(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + } + if (ctx->ExecuteFlag) { + CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_PointParameterfEXT(GLenum pname, GLfloat param) +{ + GLfloat parray[3]; + parray[0] = param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameteriNV(GLenum pname, GLint param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameterivNV(GLenum pname, const GLint * param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param[0]; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + + +static void GLAPIENTRY +save_PointSize(GLfloat size) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); + if (n) { + n[1].f = size; + } + if (ctx->ExecuteFlag) { + CALL_PointSize(ctx->Exec, (size)); + } +} + + +static void GLAPIENTRY +save_PolygonMode(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_PolygonMode(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_PolygonStipple(const GLubyte * pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); + if (n) { + n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + pattern, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); + } +} + + +static void GLAPIENTRY +save_PolygonOffset(GLfloat factor, GLfloat units) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); + if (n) { + n[1].f = factor; + n[2].f = units; + } + if (ctx->ExecuteFlag) { + CALL_PolygonOffset(ctx->Exec, (factor, units)); + } +} + + +static void GLAPIENTRY +save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) +{ + GET_CURRENT_CONTEXT(ctx); + /* XXX mult by DepthMaxF here??? */ + save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); +} + + +static void GLAPIENTRY +save_PopAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); + if (ctx->ExecuteFlag) { + CALL_PopAttrib(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PopMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopName(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); + if (ctx->ExecuteFlag) { + CALL_PopName(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PrioritizeTextures(GLsizei num, const GLuint * textures, + const GLclampf * priorities) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < num; i++) { + Node *n; + n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); + if (n) { + n[1].ui = textures[i]; + n[2].f = priorities[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); + } +} + + +static void GLAPIENTRY +save_PushAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_PushAttrib(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_PushMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PushMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PushName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_PushName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_RasterPos2d(GLdouble x, GLdouble y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2f(GLfloat x, GLfloat y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2i(GLint x, GLint y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2s(GLshort x, GLshort y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3i(GLint x, GLint y, GLint z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_RasterPos4f(x, y, z, w); +} + +static void GLAPIENTRY +save_RasterPos2dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_RasterPos4iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_PassThrough(GLfloat token) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); + if (n) { + n[1].f = token; + } + if (ctx->ExecuteFlag) { + CALL_PassThrough(ctx->Exec, (token)); + } +} + + +static void GLAPIENTRY +save_ReadBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ReadBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetHistogram(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetMinmax(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ROTATE, 4); + if (n) { + n[1].f = angle; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Rotatef(ctx->Exec, (angle, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) +{ + save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scalef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCALE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Scalef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Scaled(GLdouble x, GLdouble y, GLdouble z) +{ + save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = width; + n[4].i = height; + } + if (ctx->ExecuteFlag) { + CALL_Scissor(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_ShadeModel(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); + + if (ctx->ExecuteFlag) { + CALL_ShadeModel(ctx->Exec, (mode)); + } + + if (ctx->ListState.Current.ShadeModel == mode) + return; + + SAVE_FLUSH_VERTICES(ctx); + + /* Only save the value if we know the statechange will take effect: + */ + if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) + ctx->ListState.Current.ShadeModel = mode; + + n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); + if (n) { + n[1].e = mode; + } +} + + +static void GLAPIENTRY +save_StencilFunc(GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); + if (n) { + n[1].e = func; + n[2].i = ref; + n[3].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFunc(ctx->Exec, (func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); + if (n) { + n[1].e = fail; + n[2].e = zfail; + n[3].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = func; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, + GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* GL_FRONT */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_FRONT; + n[2].e = frontfunc; + n[3].i = ref; + n[4].ui = mask; + } + /* GL_BACK */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_BACK; + n[2].e = backfunc; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); + CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); + if (n) { + n[1].e = face; + n[2].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); + } +} + + +static void GLAPIENTRY +save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = fail; + n[3].e = zfail; + n[4].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXENV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + if (pname == GL_TEXTURE_ENV_COLOR) { + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[3].f = params[0]; + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_TexEnvfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexEnvfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexEnvi(GLenum target, GLenum pname, GLint param) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0F; + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexEnviv(GLenum target, GLenum pname, const GLint * param) +{ + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0.0F; + } + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); + if (n) { + n[1].e = coord; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexGenfv(ctx->Exec, (coord, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGend(GLenum coord, GLenum pname, GLdouble param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGeni(GLenum coord, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_TexGeniv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexParameterfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) params[0]; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexImage1D(GLenum target, + GLint level, GLint components, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = border; + n[6].e = format; + n[7].e = type; + n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage2D(GLenum target, + GLint level, GLint components, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage3D(GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = (GLint) internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].e = format; + n[9].e = type; + n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, + format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + width, height, format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].e = type; + n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + width, height, depth, format, type, + pixels)); + } +} + + +static void GLAPIENTRY +save_Translatef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Translatef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Translated(GLdouble x, GLdouble y, GLdouble z) +{ + save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + + +static void GLAPIENTRY +save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + } + if (ctx->ExecuteFlag) { + CALL_Viewport(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_WindowPos2dMESA(GLdouble x, GLdouble y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fMESA(GLfloat x, GLfloat y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2iMESA(GLint x, GLint y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2sMESA(GLshort x, GLshort y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3iMESA(GLint x, GLint y, GLint z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_WindowPos4fMESA(x, y, z, w); +} + +static void GLAPIENTRY +save_WindowPos2dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_WindowPos4ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + + + +/* GL_ARB_multitexture */ +static void GLAPIENTRY +save_ActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ActiveTextureARB(ctx->Exec, (target)); + } +} + + +/* GL_ARB_transpose_matrix */ + +static void GLAPIENTRY +save_LoadTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_LoadTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_MultMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_MultMatrixf(tm); +} + + +/* GL_ARB_texture_compression */ +static void GLAPIENTRY +save_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, + width, border, imageSize, + data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = border; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage1DARB(ctx->Exec, + (target, level, internalFormat, width, + border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, + width, height, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].i = imageSize; + n[8].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage2DARB(ctx->Exec, + (target, level, internalFormat, width, + height, border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, + width, height, depth, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage3DARB(ctx->Exec, + (target, level, internalFormat, width, + height, depth, border, imageSize, + data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, + width, format, imageSize, + data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (target, level, xoffset, yoffset, width, + height, format, imageSize, data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].i = imageSize; + n[11].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (target, level, xoffset, yoffset, + zoffset, width, height, depth, format, + imageSize, data)); + } +} + + +/* GL_ARB_multisample */ +static void GLAPIENTRY +save_SampleCoverageARB(GLclampf value, GLboolean invert) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); + if (n) { + n[1].f = value; + n[2].b = invert; + } + if (ctx->ExecuteFlag) { + CALL_SampleCoverageARB(ctx->Exec, (value, invert)); + } +} + + +/* + * GL_NV_vertex_program + */ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +static void GLAPIENTRY +save_BindProgramNV(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindProgramNV(ctx->Exec, (target, id)); + } +} + +static void GLAPIENTRY +save_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + save_ProgramEnvParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +static void GLAPIENTRY +save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat * params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) x, + (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) params[0], + (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ + +#if FEATURE_NV_vertex_program +static void GLAPIENTRY +save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); + if (n) { + n[1].e = target; + n[2].ui = id; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4dvNV(GLenum target, GLuint index, + GLsizei num, const GLdouble *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4fvNV(GLenum target, GLuint index, + GLsizei num, const GLfloat *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte * program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + memcpy(programCopy, program, len); + n[1].e = target; + n[2].ui = id; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); + } +} + + +static void GLAPIENTRY +save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); + if (n) { + GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); + if (!idCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); + return; + } + memcpy(idCopy, ids, num * sizeof(GLuint)); + n[1].i = num; + n[2].data = idCopy; + } + if (ctx->ExecuteFlag) { + CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); + } +} + + +static void GLAPIENTRY +save_TrackMatrixNV(GLenum target, GLuint address, + GLenum matrix, GLenum transform) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); + if (n) { + n[1].e = target; + n[2].ui = address; + n[3].e = matrix; + n[4].e = transform; + } + if (ctx->ExecuteFlag) { + CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); + } +} +#endif /* FEATURE_NV_vertex_program */ + + +/* + * GL_NV_fragment_program + */ +#if FEATURE_NV_fragment_program +static void GLAPIENTRY +save_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) x; + n[4].f = (GLfloat) y; + n[5].f = (GLfloat) z; + n[6].f = (GLfloat) w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) params[0]; + n[4].f = (GLfloat) params[1]; + n[5].f = (GLfloat) params[2]; + n[6].f = (GLfloat) params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); + } +} + +static void GLAPIENTRY +save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); + if (n) { + GLubyte *nameCopy = (GLubyte *) malloc(len); + if (!nameCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); + return; + } + memcpy(nameCopy, name, len); + n[1].ui = id; + n[2].i = len; + n[3].data = nameCopy; + n[4].f = x; + n[5].f = y; + n[6].f = z; + n[7].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, + const float v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, + const double v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], + (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +#endif /* FEATURE_NV_fragment_program */ + + + +/* GL_EXT_stencil_two_side */ +static void GLAPIENTRY +save_ActiveStencilFaceEXT(GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); + if (n) { + n[1].e = face; + } + if (ctx->ExecuteFlag) { + CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); + } +} + + +/* GL_EXT_depth_bounds_test */ +static void GLAPIENTRY +save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); + if (n) { + n[1].f = (GLfloat) zmin; + n[2].f = (GLfloat) zmax; + } + if (ctx->ExecuteFlag) { + CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); + } +} + + + +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + +static void GLAPIENTRY +save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid * string) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); + return; + } + memcpy(programCopy, string, len); + n[1].e = target; + n[2].e = format; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); + } +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ + + +#if FEATURE_queryobj + +static void GLAPIENTRY +save_BeginQueryARB(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BeginQueryARB(ctx->Exec, (target, id)); + } +} + + +static void GLAPIENTRY +save_EndQueryARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_EndQueryARB(ctx->Exec, (target)); + } +} + +#endif /* FEATURE_queryobj */ + + +static void GLAPIENTRY +save_DrawBuffersARB(GLsizei count, const GLenum * buffers) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); + if (n) { + GLint i; + n[1].i = count; + if (count > MAX_DRAW_BUFFERS) + count = MAX_DRAW_BUFFERS; + for (i = 0; i < count; i++) { + n[2 + i].e = buffers[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); + if (n) { + n[1].ui = pname; + n[2].f = param[0]; + n[3].f = param[1]; + n[4].f = param[2]; + n[5].f = param[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterivATI(GLenum pname, const GLint *param) +{ + GLfloat p[4]; + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + save_TexBumpParameterfvATI(pname, p); +} + +#if FEATURE_ATI_fragment_shader +static void GLAPIENTRY +save_BindFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); + if (n) { + n[1].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindFragmentShaderATI(ctx->Exec, (id)); + } +} + +static void GLAPIENTRY +save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); + if (n) { + n[1].ui = dst; + n[2].f = value[0]; + n[3].f = value[1]; + n[4].f = value[2]; + n[5].f = value[3]; + } + if (ctx->ExecuteFlag) { + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); + } +} +#endif + +static void +save_Attr1fNV(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); + } +} + +static void +save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); + } +} + +static void +save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); + } +} + +static void +save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void +save_Attr1fARB(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); + } +} + +static void +save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); + } +} + +static void +save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); + } +} + +static void +save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_EvalCoord1f(GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); + if (n) { + n[1].f = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord1f(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalCoord1fv(const GLfloat * v) +{ + save_EvalCoord1f(v[0]); +} + +static void GLAPIENTRY +save_EvalCoord2f(GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); + if (n) { + n[1].f = x; + n[2].f = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord2f(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_EvalCoord2fv(const GLfloat * v) +{ + save_EvalCoord2f(v[0], v[1]); +} + + +static void GLAPIENTRY +save_EvalPoint1(GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); + if (n) { + n[1].i = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint1(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalPoint2(GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); + if (n) { + n[1].i = x; + n[2].i = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint2(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_Indexf(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); +} + +static void GLAPIENTRY +save_Indexfv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); +} + +static void GLAPIENTRY +save_EdgeFlag(GLboolean x) +{ + save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); +} + +static INLINE GLboolean compare4fv( const GLfloat *a, + const GLfloat *b, + GLuint count ) +{ + return memcmp( a, b, count * sizeof(GLfloat) ) == 0; +} + + +static void GLAPIENTRY +save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + int args, i; + GLuint bitmask; + + switch (face) { + case GL_BACK: + case GL_FRONT: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); + return; + } + + switch (pname) { + case GL_EMISSION: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_AMBIENT_AND_DIFFUSE: + args = 4; + break; + case GL_SHININESS: + args = 1; + break; + case GL_COLOR_INDEXES: + args = 3; + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); + return; + } + + if (ctx->ExecuteFlag) { + CALL_Materialfv(ctx->Exec, (face, pname, param)); + } + + bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); + + /* Try to eliminate redundant statechanges. Because it is legal to + * call glMaterial even inside begin/end calls, don't need to worry + * about ctx->Driver.CurrentSavePrimitive here. + */ + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + if (bitmask & (1 << i)) { + if (ctx->ListState.ActiveMaterialSize[i] == args && + compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { + bitmask &= ~(1 << i); + } + else { + ctx->ListState.ActiveMaterialSize[i] = args; + COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + } + } + } + + /* If this call has effect, return early: + */ + if (bitmask == 0) + return; + + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); + if (n) { + n[1].e = face; + n[2].e = pname; + for (i = 0; i < args; i++) + n[3 + i].f = param[i]; + } +} + +static void GLAPIENTRY +save_Begin(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + GLboolean error = GL_FALSE; + + if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { + _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); + error = GL_TRUE; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { + /* Typically the first begin. This may raise an error on + * playback, depending on whether CallList is issued from inside + * a begin/end or not. + */ + ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { + ctx->Driver.CurrentSavePrimitive = mode; + } + else { + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); + error = GL_TRUE; + } + + if (!error) { + /* Give the driver an opportunity to hook in an optimized + * display list compiler. + */ + if (ctx->Driver.NotifySaveBegin(ctx, mode)) + return; + + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN, 1); + if (n) { + n[1].e = mode; + } + } + + if (ctx->ExecuteFlag) { + CALL_Begin(ctx->Exec, (mode)); + } +} + +static void GLAPIENTRY +save_End(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + (void) alloc_instruction(ctx, OPCODE_END, 0); + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + if (ctx->ExecuteFlag) { + CALL_End(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_RECTF, 4); + if (n) { + n[1].f = a; + n[2].f = b; + n[3].f = c; + n[4].f = d; + } + if (ctx->ExecuteFlag) { + CALL_Rectf(ctx->Exec, (a, b, c, d)); + } +} + + +static void GLAPIENTRY +save_Vertex2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_POS, x, y); +} + +static void GLAPIENTRY +save_Vertex2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); +} + +static void GLAPIENTRY +save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); +} + +static void GLAPIENTRY +save_Vertex3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); +} + +static void GLAPIENTRY +save_Vertex4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_TexCoord1f(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, x); +} + +static void GLAPIENTRY +save_TexCoord1fv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); +} + +static void GLAPIENTRY +save_TexCoord2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); +} + +static void GLAPIENTRY +save_TexCoord2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); +} + +static void GLAPIENTRY +save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); +} + +static void GLAPIENTRY +save_TexCoord3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); +} + +static void GLAPIENTRY +save_TexCoord4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_Normal3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); +} + +static void GLAPIENTRY +save_Normal3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_FogCoordfEXT(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, x); +} + +static void GLAPIENTRY +save_FogCoordfvEXT(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); +} + +static void GLAPIENTRY +save_Color3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); +} + +static void GLAPIENTRY +save_Color3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); +} + +static void GLAPIENTRY +save_Color4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); +} + +static void GLAPIENTRY +save_SecondaryColor3fvEXT(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); +} + + +/* Just call the respective ATTR for texcoord + */ +static void GLAPIENTRY +save_MultiTexCoord1f(GLenum target, GLfloat x) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, x); +} + +static void GLAPIENTRY +save_MultiTexCoord1fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, v[0]); +} + +static void GLAPIENTRY +save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, x, y); +} + +static void GLAPIENTRY +save_MultiTexCoord2fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, v[0], v[1]); +} + +static void GLAPIENTRY +save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, x, y, z); +} + +static void GLAPIENTRY +save_MultiTexCoord3fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, x, y, z, w); +} + +static void GLAPIENTRY +save_MultiTexCoord4fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); +} + + +/** + * Record a GL_INVALID_VALUE error when a invalid vertex attribute + * index is found. + */ +static void +index_error(void) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); +} + + +/* First level for NV_vertex_program: + * + * Check for errors at compile time?. + */ +static void GLAPIENTRY +save_VertexAttrib1fNV(GLuint index, GLfloat x) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + + + +static void GLAPIENTRY +save_VertexAttrib1fARB(GLuint index, GLfloat x) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + +/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + +static void GLAPIENTRY +exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); +} + +static GLint GLAPIENTRY +exec_GetAttribLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); +} + +static GLint GLAPIENTRY +exec_GetUniformLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); +} +/* XXX more shader functions needed here */ + + +#if FEATURE_EXT_framebuffer_blit +static void GLAPIENTRY +save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); + if (n) { + n[1].i = srcX0; + n[2].i = srcY0; + n[3].i = srcX1; + n[4].i = srcY1; + n[5].i = dstX0; + n[6].i = dstY0; + n[7].i = dstX1; + n[8].i = dstY1; + n[9].i = mask; + n[10].e = filter; + } + if (ctx->ExecuteFlag) { + CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter)); + } +} +#endif + + +/** GL_EXT_provoking_vertex */ +static void GLAPIENTRY +save_ProvokingVertexEXT(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ + _mesa_ProvokingVertexEXT(mode); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_BeginTransformFeedback(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_EndTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + } +} + + +/* aka UseProgram() */ +static void GLAPIENTRY +save_UseProgramObjectARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseProgramObjectARB(ctx->Exec, (program)); + } +} + + +static void GLAPIENTRY +save_Uniform1fARB(GLint location, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); + if (n) { + n[1].i = location; + n[2].f = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fARB(ctx->Exec, (location, x)); + } +} + + +static void GLAPIENTRY +save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fARB(ctx->Exec, (location, x, y)); + } +} + + +static void GLAPIENTRY +save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); + } +} + + +/** Return copy of memory */ +static void * +memdup(const void *src, GLsizei bytes) +{ + void *b = bytes >= 0 ? malloc(bytes) : NULL; + if (b) + memcpy(b, src, bytes); + return b; +} + + +static void GLAPIENTRY +save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); + } +} + + +static void GLAPIENTRY +save_Uniform1iARB(GLint location, GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1iARB(ctx->Exec, (location, x)); + } +} + +static void GLAPIENTRY +save_Uniform2iARB(GLint location, GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2iARB(ctx->Exec, (location, x, y)); + } +} + +static void GLAPIENTRY +save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); + } +} + +static void GLAPIENTRY +save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ui(GLint location, GLuint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ + } +} + +static void GLAPIENTRY +save_Uniform2ui(GLint location, GLuint x, GLuint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ + } +} + +static void GLAPIENTRY +save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ + } +} + +static void GLAPIENTRY +save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ + } +} + + + +static void GLAPIENTRY +save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ + } +} + + + +static void GLAPIENTRY +save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UseShaderProgramEXT(GLenum type, GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); + if (n) { + n[1].ui = type; + n[2].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); + } +} + +static void GLAPIENTRY +save_ActiveProgramEXT(GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_ActiveProgramEXT(ctx->Exec, (program)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); + if (n) { + n[1].i = red; + n[2].i = green; + n[3].i = blue; + n[4].i = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); + if (n) { + n[1].ui = red; + n[2].ui = green; + n[3].ui = blue; + n[4].ui = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].ui = params[0]; + n[4].ui = params[1]; + n[5].ui = params[2]; + n[6].ui = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); +} + + +/* GL_ARB_instanced_arrays */ +static void +save_VertexAttribDivisor(GLuint index, GLuint divisor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2); + if (n) { + n[1].ui = index; + n[2].ui = divisor; + } + if (ctx->ExecuteFlag) { + CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor)); + } +} + + + +/** + * Save an error-generating command into display list. + * + * KW: Will appear in the list before the vertex buffer containing the + * command that provoked the error. I don't see this as a problem. + */ +static void +save_error(struct gl_context *ctx, GLenum error, const char *s) +{ + Node *n; + n = alloc_instruction(ctx, OPCODE_ERROR, 2); + if (n) { + n[1].e = error; + n[2].data = (void *) s; + } +} + + +/** + * Compile an error into current display list. + */ +void +_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) +{ + if (ctx->CompileFlag) + save_error(ctx, error, s); + if (ctx->ExecuteFlag) + _mesa_error(ctx, error, "%s", s); +} + + +/** + * Test if ID names a display list. + */ +static GLboolean +islist(struct gl_context *ctx, GLuint list) +{ + if (list > 0 && lookup_list(ctx, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/**********************************************************************/ +/* Display list execution */ +/**********************************************************************/ + + +/* + * Execute a display list. Note that the ListBase offset must have already + * been added before calling this function. I.e. the list argument is + * the absolute list number, not relative to ListBase. + * \param list - display list number + */ +static void +execute_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (list == 0 || !islist(ctx, list)) + return; + + if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { + /* raise an error? */ + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + ctx->ListState.CallDepth++; + + if (ctx->Driver.BeginCallList) + ctx->Driver.BeginCallList(ctx, dlist); + + n = dlist->Head; + + done = GL_FALSE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_execute(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ERROR: + _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); + break; + case OPCODE_ACCUM: + CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ALPHA_FUNC: + CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_BIND_TEXTURE: + CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_BITMAP: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, + (const GLubyte *) n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_BLEND_COLOR: + CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_BLEND_EQUATION: + CALL_BlendEquation(ctx->Exec, (n[1].e)); + break; + case OPCODE_BLEND_EQUATION_SEPARATE: + CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE: + CALL_BlendFuncSeparateEXT(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + + case OPCODE_BLEND_FUNC_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e, + n[4].e, n[5].e)); + break; + case OPCODE_BLEND_EQUATION_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_BLEND_EQUATION_SEPARATE_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendEquationSeparateiARB(ctx->Exec, + (n[1].ui, n[2].e, n[3].e)); + break; + + case OPCODE_CALL_LIST: + /* Generated by glCallList(), don't add ListBase */ + if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + execute_list(ctx, n[1].ui); + } + break; + case OPCODE_CALL_LIST_OFFSET: + /* Generated by glCallLists() so we must add ListBase */ + if (n[2].b) { + /* user specified a bad data type at compile time */ + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + } + else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); + execute_list(ctx, list); + } + break; + case OPCODE_CLEAR: + CALL_Clear(ctx->Exec, (n[1].bf)); + break; + case OPCODE_CLEAR_BUFFER_IV: + { + GLint value[4]; + value[0] = n[3].i; + value[1] = n[4].i; + value[2] = n[5].i; + value[3] = n[6].i; + /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_UIV: + { + GLuint value[4]; + value[0] = n[3].ui; + value[1] = n[4].ui; + value[2] = n[5].ui; + value[3] = n[6].ui; + /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FV: + { + GLfloat value[4]; + value[0] = n[3].f; + value[1] = n[4].f; + value[2] = n[5].f; + value[3] = n[6].f; + /*CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FI: + /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/ + break; + case OPCODE_CLEAR_COLOR: + CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_ACCUM: + CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_DEPTH: + CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); + break; + case OPCODE_CLEAR_INDEX: + CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); + break; + case OPCODE_CLEAR_STENCIL: + CALL_ClearStencil(ctx->Exec, (n[1].i)); + break; + case OPCODE_CLIP_PLANE: + { + GLdouble eq[4]; + eq[0] = n[2].f; + eq[1] = n[3].f; + eq[2] = n[4].f; + eq[3] = n[5].f; + CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); + } + break; + case OPCODE_COLOR_MASK: + CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); + break; + case OPCODE_COLOR_MASK_INDEXED: + CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b, + n[4].b, n[5].b)); + break; + case OPCODE_COLOR_MATERIAL: + CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_COLOR_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e, + n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ColorTableParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ColorTableParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_SUB_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, + n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, n[6].e, + n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_PARAMETER_I: + CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i)); + break; + case OPCODE_CONVOLUTION_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ConvolutionParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_CONVOLUTION_PARAMETER_F: + CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f)); + break; + case OPCODE_CONVOLUTION_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ConvolutionParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COPY_COLOR_SUB_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_COLOR_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_PIXELS: + CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i, + n[5].e)); + break; + case OPCODE_COPY_TEX_IMAGE1D: + CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i)); + break; + case OPCODE_COPY_TEX_IMAGE2D: + CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE1D: + CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE2D: + CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE3D: + CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].i)); + break; + case OPCODE_CULL_FACE: + CALL_CullFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_FUNC: + CALL_DepthFunc(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_MASK: + CALL_DepthMask(ctx->Exec, (n[1].b)); + break; + case OPCODE_DEPTH_RANGE: + CALL_DepthRange(ctx->Exec, + ((GLclampd) n[1].f, (GLclampd) n[2].f)); + break; + case OPCODE_DISABLE: + CALL_Disable(ctx->Exec, (n[1].e)); + break; + case OPCODE_DISABLE_INDEXED: + CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_DRAW_BUFFER: + CALL_DrawBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_DRAW_PIXELS: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, + n[5].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_ENABLE: + CALL_Enable(ctx->Exec, (n[1].e)); + break; + case OPCODE_ENABLE_INDEXED: + CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_EVALMESH1: + CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); + break; + case OPCODE_EVALMESH2: + CALL_EvalMesh2(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_FOG: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_Fogfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_FRONT_FACE: + CALL_FrontFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_FRUSTUM: + CALL_Frustum(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_HINT: + CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_HISTOGRAM: + CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b)); + break; + case OPCODE_INDEX_MASK: + CALL_IndexMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_INIT_NAMES: + CALL_InitNames(ctx->Exec, ()); + break; + case OPCODE_LIGHT: + { + GLfloat p[4]; + p[0] = n[3].f; + p[1] = n[4].f; + p[2] = n[5].f; + p[3] = n[6].f; + CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); + } + break; + case OPCODE_LIGHT_MODEL: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_LightModelfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_LINE_STIPPLE: + CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); + break; + case OPCODE_LINE_WIDTH: + CALL_LineWidth(ctx->Exec, (n[1].f)); + break; + case OPCODE_LIST_BASE: + CALL_ListBase(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOAD_IDENTITY: + CALL_LoadIdentity(ctx->Exec, ()); + break; + case OPCODE_LOAD_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_LoadMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_LOAD_NAME: + CALL_LoadName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOGIC_OP: + CALL_LogicOp(ctx->Exec, (n[1].e)); + break; + case OPCODE_MAP1: + { + GLenum target = n[1].e; + GLint ustride = _mesa_evaluator_components(target); + GLint uorder = n[5].i; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, + (GLfloat *) n[6].data)); + } + break; + case OPCODE_MAP2: + { + GLenum target = n[1].e; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + GLfloat v1 = n[4].f; + GLfloat v2 = n[5].f; + GLint ustride = n[6].i; + GLint vstride = n[7].i; + GLint uorder = n[8].i; + GLint vorder = n[9].i; + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, + (GLfloat *) n[10].data)); + } + break; + case OPCODE_MAPGRID1: + CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_MAPGRID2: + CALL_MapGrid2f(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); + break; + case OPCODE_MATRIX_MODE: + CALL_MatrixMode(ctx->Exec, (n[1].e)); + break; + case OPCODE_MIN_MAX: + CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b)); + break; + case OPCODE_MULT_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_MultMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_MultMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_ORTHO: + CALL_Ortho(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_PASSTHROUGH: + CALL_PassThrough(ctx->Exec, (n[1].f)); + break; + case OPCODE_PIXEL_MAP: + CALL_PixelMapfv(ctx->Exec, + (n[1].e, n[2].i, (GLfloat *) n[3].data)); + break; + case OPCODE_PIXEL_TRANSFER: + CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_PIXEL_ZOOM: + CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POINT_SIZE: + CALL_PointSize(ctx->Exec, (n[1].f)); + break; + case OPCODE_POINT_PARAMETERS: + { + GLfloat params[3]; + params[0] = n[2].f; + params[1] = n[3].f; + params[2] = n[4].f; + CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); + } + break; + case OPCODE_POLYGON_MODE: + CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_POLYGON_STIPPLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_POLYGON_OFFSET: + CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POP_ATTRIB: + CALL_PopAttrib(ctx->Exec, ()); + break; + case OPCODE_POP_MATRIX: + CALL_PopMatrix(ctx->Exec, ()); + break; + case OPCODE_POP_NAME: + CALL_PopName(ctx->Exec, ()); + break; + case OPCODE_PRIORITIZE_TEXTURE: + CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); + break; + case OPCODE_PUSH_ATTRIB: + CALL_PushAttrib(ctx->Exec, (n[1].bf)); + break; + case OPCODE_PUSH_MATRIX: + CALL_PushMatrix(ctx->Exec, ()); + break; + case OPCODE_PUSH_NAME: + CALL_PushName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_RASTER_POS: + CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_READ_BUFFER: + CALL_ReadBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_HISTOGRAM: + CALL_ResetHistogram(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_MIN_MAX: + CALL_ResetMinmax(ctx->Exec, (n[1].e)); + break; + case OPCODE_ROTATE: + CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_SCALE: + CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_SCISSOR: + CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_SHADE_MODEL: + CALL_ShadeModel(ctx->Exec, (n[1].e)); + break; + case OPCODE_PROVOKING_VERTEX: + CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_BEGIN_TRANSFORM_FEEDBACK: + CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_END_TRANSFORM_FEEDBACK: + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + break; + case OPCODE_STENCIL_FUNC: + CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); + break; + case OPCODE_STENCIL_MASK: + CALL_StencilMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_STENCIL_OP: + CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); + break; + case OPCODE_STENCIL_FUNC_SEPARATE: + CALL_StencilFuncSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].ui)); + break; + case OPCODE_STENCIL_MASK_SEPARATE: + CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_STENCIL_OP_SEPARATE: + CALL_StencilOpSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + case OPCODE_TEXENV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXGEN: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEX_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].e, /* border */ + n[6].e, /* format */ + n[7].e, /* type */ + n[8].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].e, /* border */ + n[7].e, /* format */ + n[8].e, /* type */ + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].i, /* depth */ + n[7].e, /* border */ + n[8].e, /* format */ + n[9].e, /* type */ + n[10].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].e, n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].i, n[7].e, n[8].e, + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].e, n[10].e, + n[11].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TRANSLATE: + CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_VIEWPORT: + CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i)); + break; + case OPCODE_WINDOW_POS: + CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ + CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage1DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].e, n[6].i, n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].e, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].e, n[10].i, n[11].data)); + break; + case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ + CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); + break; + case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ + CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ + CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); + break; +#endif +#if FEATURE_NV_vertex_program + case OPCODE_EXECUTE_PROGRAM_NV: + { + GLfloat v[4]; + v[0] = n[3].f; + v[1] = n[4].f; + v[2] = n[5].f; + v[3] = n[6].f; + CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v)); + } + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui, + (GLuint *) n[2].data)); + break; + case OPCODE_LOAD_PROGRAM_NV: + CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, + (const GLubyte *) n[4].data)); + break; + case OPCODE_TRACK_MATRIX_NV: + CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); + break; +#endif + +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: + CALL_ProgramLocalParameter4fARB(ctx->Exec, + (n[1].e, n[2].ui, n[3].f, n[4].f, + n[5].f, n[6].f)); + break; + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, + (const GLubyte *) n[3]. + data, n[4].f, n[5].f, + n[6].f, n[7].f)); + break; +#endif + + case OPCODE_ACTIVE_STENCIL_FACE_EXT: + CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_BOUNDS_EXT: + CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); + break; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + CALL_ProgramStringARB(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].data)); + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program + case OPCODE_PROGRAM_ENV_PARAMETER_ARB: + CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, + n[4].f, n[5].f, + n[6].f)); + break; +#endif +#if FEATURE_queryobj + case OPCODE_BEGIN_QUERY_ARB: + CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_END_QUERY_ARB: + CALL_EndQueryARB(ctx->Exec, (n[1].e)); + break; +#endif + case OPCODE_DRAW_BUFFERS_ARB: + { + GLenum buffers[MAX_DRAW_BUFFERS]; + GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); + for (i = 0; i < count; i++) + buffers[i] = n[2 + i].e; + CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers)); + } + break; +#if FEATURE_EXT_framebuffer_blit + case OPCODE_BLIT_FRAMEBUFFER: + CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].i, n[10].e)); + break; +#endif + + case OPCODE_USE_PROGRAM: + CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); + break; + case OPCODE_USE_SHADER_PROGRAM_EXT: + CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); + break; + case OPCODE_ACTIVE_PROGRAM_EXT: + CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); + break; + case OPCODE_UNIFORM_1F: + CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); + break; + case OPCODE_UNIFORM_2F: + CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_UNIFORM_3F: + CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_UNIFORM_4F: + CALL_Uniform4fARB(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); + break; + case OPCODE_UNIFORM_1FV: + CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2FV: + CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3FV: + CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4FV: + CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1I: + CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); + break; + case OPCODE_UNIFORM_2I: + CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); + break; + case OPCODE_UNIFORM_3I: + CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_UNIFORM_4I: + CALL_Uniform4iARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_UNIFORM_1IV: + CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2IV: + CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3IV: + CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4IV: + CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1UI: + /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ + break; + case OPCODE_UNIFORM_2UI: + /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ + break; + case OPCODE_UNIFORM_3UI: + /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ + break; + case OPCODE_UNIFORM_4UI: + /*CALL_Uniform4uiARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + */ + break; + case OPCODE_UNIFORM_1UIV: + /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_2UIV: + /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_3UIV: + /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_4UIV: + /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_MATRIX22: + CALL_UniformMatrix2fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX33: + CALL_UniformMatrix3fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX44: + CALL_UniformMatrix4fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX23: + CALL_UniformMatrix2x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX32: + CALL_UniformMatrix3x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX24: + CALL_UniformMatrix2x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX42: + CALL_UniformMatrix4x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX34: + CALL_UniformMatrix3x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX43: + CALL_UniformMatrix4x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + + case OPCODE_TEX_BUMP_PARAMETER_ATI: + { + GLfloat values[4]; + GLuint i, pname = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); + } + break; +#if FEATURE_ATI_fragment_shader + case OPCODE_BIND_FRAGMENT_SHADER_ATI: + CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); + break; + case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: + { + GLfloat values[4]; + GLuint i, dst = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); + } + break; +#endif + case OPCODE_ATTR_1F_NV: + CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_NV: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_ATTR_1F_ARB: + CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_ARB: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_MATERIAL: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); + else { + GLfloat f[4]; + f[0] = n[3].f; + f[1] = n[4].f; + f[2] = n[5].f; + f[3] = n[6].f; + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); + } + break; + case OPCODE_BEGIN: + CALL_Begin(ctx->Exec, (n[1].e)); + break; + case OPCODE_END: + CALL_End(ctx->Exec, ()); + break; + case OPCODE_RECTF: + CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_EVAL_C1: + CALL_EvalCoord1f(ctx->Exec, (n[1].f)); + break; + case OPCODE_EVAL_C2: + CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_EVAL_P1: + CALL_EvalPoint1(ctx->Exec, (n[1].i)); + break; + case OPCODE_EVAL_P2: + CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); + break; + + /* GL_EXT_texture_integer */ + case OPCODE_CLEARCOLOR_I: + CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_CLEARCOLOR_UI: + CALL_ClearColorIuiEXT(ctx->Exec, + (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); + break; + case OPCODE_TEXPARAMETER_I: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER_UI: + { + GLuint params[4]; + params[0] = n[3].ui; + params[1] = n[4].ui; + params[2] = n[5].ui; + params[3] = n[6].ui; + CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + + case OPCODE_VERTEX_ATTRIB_DIVISOR: + /* GL_ARB_instanced_arrays */ + CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui)); + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + done = GL_TRUE; + break; + default: + { + char msg[1000]; + _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", + (int) opcode); + _mesa_problem(ctx, "%s", msg); + } + done = GL_TRUE; + } + + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } + + if (ctx->Driver.EndCallList) + ctx->Driver.EndCallList(ctx); + + ctx->ListState.CallDepth--; +} + + + +/**********************************************************************/ +/* GL functions */ +/**********************************************************************/ + +/** + * Test if a display list number is valid. + */ +static GLboolean GLAPIENTRY +_mesa_IsList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + return islist(ctx, list); +} + + +/** + * Delete a sequence of consecutive display lists. + */ +static void GLAPIENTRY +_mesa_DeleteLists(GLuint list, GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint i; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); + return; + } + for (i = list; i < list + range; i++) { + destroy_list(ctx, i); + } +} + + +/** + * Return a display list number, n, such that lists n through n+range-1 + * are free. + */ +static GLuint GLAPIENTRY +_mesa_GenLists(GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint base; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); + return 0; + } + if (range == 0) { + return 0; + } + + /* + * Make this an atomic operation + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); + if (base) { + /* reserve the list IDs by with empty/dummy lists */ + GLint i; + for (i = 0; i < range; i++) { + _mesa_HashInsert(ctx->Shared->DisplayList, base + i, + make_list(base + i, 1)); + } + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + return base; +} + + +/** + * Begin a new display list. + */ +static void GLAPIENTRY +_mesa_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + + FLUSH_CURRENT(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glNewList %u %s\n", name, + _mesa_lookup_enum_by_nr(mode)); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); + return; + } + + if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); + return; + } + + if (ctx->ListState.CurrentList) { + /* already compiling a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + return; + } + + ctx->CompileFlag = GL_TRUE; + ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); + + /* Reset acumulated list state: + */ + invalidate_saved_current_state( ctx ); + + /* Allocate new display list */ + ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); + ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; + ctx->ListState.CurrentPos = 0; + + ctx->Driver.NewList(ctx, name, mode); + + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +/** + * End definition of current display list. + */ +static void GLAPIENTRY +_mesa_EndList(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndList\n"); + + /* Check that a list is under construction */ + if (!ctx->ListState.CurrentList) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); + return; + } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); + + (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); + + /* Destroy old list, if any */ + destroy_list(ctx, ctx->ListState.CurrentList->Name); + + /* Install the new list */ + _mesa_HashInsert(ctx->Shared->DisplayList, + ctx->ListState.CurrentList->Name, + ctx->ListState.CurrentList); + + + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) + mesa_print_display_list(ctx->ListState.CurrentList->Name); + + ctx->ListState.CurrentList = NULL; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + + ctx->CurrentDispatch = ctx->Exec; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +void GLAPIENTRY +_mesa_CallList(GLuint list) +{ + GLboolean save_compile_flag; + GET_CURRENT_CONTEXT(ctx); + FLUSH_CURRENT(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallList %d\n", list); + + if (list == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); + return; + } + + if (0) + mesa_print_display_list( list ); + + /* VERY IMPORTANT: Save the CompileFlag status, turn it off, + * execute the display list, and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + if (save_compile_flag) { + ctx->CompileFlag = GL_FALSE; + } + + execute_list(ctx, list); + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Execute glCallLists: call multiple display lists. + */ +void GLAPIENTRY +_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean save_compile_flag; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallLists %d\n", n); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + return; + } + + /* Save the CompileFlag status, turn it off, execute display list, + * and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; + + for (i = 0; i < n; i++) { + GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); + execute_list(ctx, list); + } + + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Set the offset added to list numbers in glCallLists. + */ +static void GLAPIENTRY +_mesa_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + ctx->List.ListBase = base; +} + + +/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. + */ +static void GLAPIENTRY +exec_Finish(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Finish(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_Flush(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Flush(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetBooleanv(GLenum pname, GLboolean *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetBooleanv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetClipPlane(GLenum plane, GLdouble * equation) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetClipPlane(ctx->Exec, (plane, equation)); +} + +static void GLAPIENTRY +exec_GetDoublev(GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetDoublev(ctx->Exec, (pname, params)); +} + +static GLenum GLAPIENTRY +exec_GetError(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetError(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetFloatv(GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetFloatv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetIntegerv(GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetIntegerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightfv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetLightiv(GLenum light, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightiv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapdv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapfv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapiv(GLenum target, GLenum query, GLint * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapiv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetPixelMapfv(GLenum map, GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapfv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapuiv(GLenum map, GLuint *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapuiv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapusv(GLenum map, GLushort *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapusv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPolygonStipple(GLubyte * dest) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPolygonStipple(ctx->Exec, (dest)); +} + +static const GLubyte *GLAPIENTRY +exec_GetString(GLenum name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetString(ctx->Exec, (name)); +} + +static void GLAPIENTRY +exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexImage(GLenum target, GLint level, GLenum format, + GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameterfv(GLenum target, GLint level, + GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameteriv(GLenum target, GLint level, + GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); +} + +static GLboolean GLAPIENTRY +exec_IsEnabled(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsEnabled(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_PixelStoref(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStoref(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_PixelStorei(GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStorei(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); +} + +static GLint GLAPIENTRY +exec_RenderMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_RenderMode(ctx->Exec, (mode)); +} + +static void GLAPIENTRY +exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); +} + +static void GLAPIENTRY +exec_SelectBuffer(GLsizei size, GLuint * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SelectBuffer(ctx->Exec, (size, buffer)); +} + +static GLboolean GLAPIENTRY +exec_AreTexturesResident(GLsizei n, const GLuint * texName, + GLboolean * residences) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); +} + +static void GLAPIENTRY +exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_DeleteTextures(GLsizei n, const GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DeleteTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_DisableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DisableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); +} + +static void GLAPIENTRY +exec_EnableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EnableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_GenTextures(GLsizei n, GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GenTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_GetPointerv(GLenum pname, GLvoid **params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPointerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); +} + +static GLboolean GLAPIENTRY +exec_IsTexture(GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsTexture(ctx->Exec, (texture)); +} + +static void GLAPIENTRY +exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_PopClientAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PopClientAttrib(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_PushClientAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PushClientAttrib(ctx->Exec, (mask)); +} + +static void GLAPIENTRY +exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); +} + +static void GLAPIENTRY +exec_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter1D(ctx->Exec, + (target, internalFormat, x, y, width)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter2D(ctx->Exec, + (target, internalFormat, x, y, width, + height)); +} + +static void GLAPIENTRY +exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTable(ctx->Exec, (target, format, type, data)); +} + +static void GLAPIENTRY +exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid * image) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid *row, GLvoid *column, GLvoid *span) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetSeparableFilter(ctx->Exec, + (target, format, type, row, column, span)); +} + +static void GLAPIENTRY +exec_SeparableFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SeparableFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, row, column)); +} + +static void GLAPIENTRY +exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); +} + +static void GLAPIENTRY +exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_LockArraysEXT(GLint first, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_LockArraysEXT(ctx->Exec, (first, count)); +} + +static void GLAPIENTRY +exec_UnlockArraysEXT(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_UnlockArraysEXT(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_ClientActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ClientActiveTextureARB(ctx->Exec, (target)); +} + +static void GLAPIENTRY +exec_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); +} + +/* GL_EXT_multi_draw_arrays */ +static void GLAPIENTRY +exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, + const GLsizei * count, GLsizei primcount, + GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawArraysIBM(ctx->Exec, + (mode, first, count, primcount, modestride)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawElementsIBM(const GLenum * mode, + const GLsizei * count, + GLenum type, + const GLvoid * const *indices, + GLsizei primcount, GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawElementsIBM(ctx->Exec, + (mode, count, type, indices, primcount, + modestride)); +} + + + +/** + * Setup the given dispatch table to point to Mesa's display list + * building functions. + * + * This does not include any of the tnl functions - they are + * initialized from _mesa_init_api_defaults and from the active vtxfmt + * struct. + */ +struct _glapi_table * +_mesa_create_save_table(void) +{ + struct _glapi_table *table; + + table = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (table == NULL) + return NULL; + + _mesa_loopback_init_api_table(table); + + /* GL 1.0 */ + SET_Accum(table, save_Accum); + SET_AlphaFunc(table, save_AlphaFunc); + SET_Bitmap(table, save_Bitmap); + SET_BlendFunc(table, save_BlendFunc); + SET_CallList(table, save_CallList); + SET_CallLists(table, save_CallLists); + SET_Clear(table, save_Clear); + SET_ClearAccum(table, save_ClearAccum); + SET_ClearColor(table, save_ClearColor); + SET_ClearDepth(table, save_ClearDepth); + SET_ClearIndex(table, save_ClearIndex); + SET_ClearStencil(table, save_ClearStencil); + SET_ClipPlane(table, save_ClipPlane); + SET_ColorMask(table, save_ColorMask); + SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); + SET_ColorMaterial(table, save_ColorMaterial); + SET_CopyPixels(table, save_CopyPixels); + SET_CullFace(table, save_CullFace); + SET_DeleteLists(table, _mesa_DeleteLists); + SET_DepthFunc(table, save_DepthFunc); + SET_DepthMask(table, save_DepthMask); + SET_DepthRange(table, save_DepthRange); + SET_Disable(table, save_Disable); + SET_DisableIndexedEXT(table, save_DisableIndexed); + SET_DrawBuffer(table, save_DrawBuffer); + SET_DrawPixels(table, save_DrawPixels); + SET_Enable(table, save_Enable); + SET_EnableIndexedEXT(table, save_EnableIndexed); + SET_EndList(table, _mesa_EndList); + SET_EvalMesh1(table, save_EvalMesh1); + SET_EvalMesh2(table, save_EvalMesh2); + SET_Finish(table, exec_Finish); + SET_Flush(table, exec_Flush); + SET_Fogf(table, save_Fogf); + SET_Fogfv(table, save_Fogfv); + SET_Fogi(table, save_Fogi); + SET_Fogiv(table, save_Fogiv); + SET_FrontFace(table, save_FrontFace); + SET_Frustum(table, save_Frustum); + SET_GenLists(table, _mesa_GenLists); + SET_GetBooleanv(table, exec_GetBooleanv); + SET_GetClipPlane(table, exec_GetClipPlane); + SET_GetDoublev(table, exec_GetDoublev); + SET_GetError(table, exec_GetError); + SET_GetFloatv(table, exec_GetFloatv); + SET_GetIntegerv(table, exec_GetIntegerv); + SET_GetLightfv(table, exec_GetLightfv); + SET_GetLightiv(table, exec_GetLightiv); + SET_GetMapdv(table, exec_GetMapdv); + SET_GetMapfv(table, exec_GetMapfv); + SET_GetMapiv(table, exec_GetMapiv); + SET_GetMaterialfv(table, exec_GetMaterialfv); + SET_GetMaterialiv(table, exec_GetMaterialiv); + SET_GetPixelMapfv(table, exec_GetPixelMapfv); + SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); + SET_GetPixelMapusv(table, exec_GetPixelMapusv); + SET_GetPolygonStipple(table, exec_GetPolygonStipple); + SET_GetString(table, exec_GetString); + SET_GetTexEnvfv(table, exec_GetTexEnvfv); + SET_GetTexEnviv(table, exec_GetTexEnviv); + SET_GetTexGendv(table, exec_GetTexGendv); + SET_GetTexGenfv(table, exec_GetTexGenfv); + SET_GetTexGeniv(table, exec_GetTexGeniv); + SET_GetTexImage(table, exec_GetTexImage); + SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); + SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); + SET_GetTexParameterfv(table, exec_GetTexParameterfv); + SET_GetTexParameteriv(table, exec_GetTexParameteriv); + SET_Hint(table, save_Hint); + SET_IndexMask(table, save_IndexMask); + SET_InitNames(table, save_InitNames); + SET_IsEnabled(table, exec_IsEnabled); + SET_IsList(table, _mesa_IsList); + SET_LightModelf(table, save_LightModelf); + SET_LightModelfv(table, save_LightModelfv); + SET_LightModeli(table, save_LightModeli); + SET_LightModeliv(table, save_LightModeliv); + SET_Lightf(table, save_Lightf); + SET_Lightfv(table, save_Lightfv); + SET_Lighti(table, save_Lighti); + SET_Lightiv(table, save_Lightiv); + SET_LineStipple(table, save_LineStipple); + SET_LineWidth(table, save_LineWidth); + SET_ListBase(table, save_ListBase); + SET_LoadIdentity(table, save_LoadIdentity); + SET_LoadMatrixd(table, save_LoadMatrixd); + SET_LoadMatrixf(table, save_LoadMatrixf); + SET_LoadName(table, save_LoadName); + SET_LogicOp(table, save_LogicOp); + SET_Map1d(table, save_Map1d); + SET_Map1f(table, save_Map1f); + SET_Map2d(table, save_Map2d); + SET_Map2f(table, save_Map2f); + SET_MapGrid1d(table, save_MapGrid1d); + SET_MapGrid1f(table, save_MapGrid1f); + SET_MapGrid2d(table, save_MapGrid2d); + SET_MapGrid2f(table, save_MapGrid2f); + SET_MatrixMode(table, save_MatrixMode); + SET_MultMatrixd(table, save_MultMatrixd); + SET_MultMatrixf(table, save_MultMatrixf); + SET_NewList(table, save_NewList); + SET_Ortho(table, save_Ortho); + SET_PassThrough(table, save_PassThrough); + SET_PixelMapfv(table, save_PixelMapfv); + SET_PixelMapuiv(table, save_PixelMapuiv); + SET_PixelMapusv(table, save_PixelMapusv); + SET_PixelStoref(table, exec_PixelStoref); + SET_PixelStorei(table, exec_PixelStorei); + SET_PixelTransferf(table, save_PixelTransferf); + SET_PixelTransferi(table, save_PixelTransferi); + SET_PixelZoom(table, save_PixelZoom); + SET_PointSize(table, save_PointSize); + SET_PolygonMode(table, save_PolygonMode); + SET_PolygonOffset(table, save_PolygonOffset); + SET_PolygonStipple(table, save_PolygonStipple); + SET_PopAttrib(table, save_PopAttrib); + SET_PopMatrix(table, save_PopMatrix); + SET_PopName(table, save_PopName); + SET_PushAttrib(table, save_PushAttrib); + SET_PushMatrix(table, save_PushMatrix); + SET_PushName(table, save_PushName); + SET_RasterPos2d(table, save_RasterPos2d); + SET_RasterPos2dv(table, save_RasterPos2dv); + SET_RasterPos2f(table, save_RasterPos2f); + SET_RasterPos2fv(table, save_RasterPos2fv); + SET_RasterPos2i(table, save_RasterPos2i); + SET_RasterPos2iv(table, save_RasterPos2iv); + SET_RasterPos2s(table, save_RasterPos2s); + SET_RasterPos2sv(table, save_RasterPos2sv); + SET_RasterPos3d(table, save_RasterPos3d); + SET_RasterPos3dv(table, save_RasterPos3dv); + SET_RasterPos3f(table, save_RasterPos3f); + SET_RasterPos3fv(table, save_RasterPos3fv); + SET_RasterPos3i(table, save_RasterPos3i); + SET_RasterPos3iv(table, save_RasterPos3iv); + SET_RasterPos3s(table, save_RasterPos3s); + SET_RasterPos3sv(table, save_RasterPos3sv); + SET_RasterPos4d(table, save_RasterPos4d); + SET_RasterPos4dv(table, save_RasterPos4dv); + SET_RasterPos4f(table, save_RasterPos4f); + SET_RasterPos4fv(table, save_RasterPos4fv); + SET_RasterPos4i(table, save_RasterPos4i); + SET_RasterPos4iv(table, save_RasterPos4iv); + SET_RasterPos4s(table, save_RasterPos4s); + SET_RasterPos4sv(table, save_RasterPos4sv); + SET_ReadBuffer(table, save_ReadBuffer); + SET_ReadPixels(table, exec_ReadPixels); + SET_RenderMode(table, exec_RenderMode); + SET_Rotated(table, save_Rotated); + SET_Rotatef(table, save_Rotatef); + SET_Scaled(table, save_Scaled); + SET_Scalef(table, save_Scalef); + SET_Scissor(table, save_Scissor); + SET_FeedbackBuffer(table, exec_FeedbackBuffer); + SET_SelectBuffer(table, exec_SelectBuffer); + SET_ShadeModel(table, save_ShadeModel); + SET_StencilFunc(table, save_StencilFunc); + SET_StencilMask(table, save_StencilMask); + SET_StencilOp(table, save_StencilOp); + SET_TexEnvf(table, save_TexEnvf); + SET_TexEnvfv(table, save_TexEnvfv); + SET_TexEnvi(table, save_TexEnvi); + SET_TexEnviv(table, save_TexEnviv); + SET_TexGend(table, save_TexGend); + SET_TexGendv(table, save_TexGendv); + SET_TexGenf(table, save_TexGenf); + SET_TexGenfv(table, save_TexGenfv); + SET_TexGeni(table, save_TexGeni); + SET_TexGeniv(table, save_TexGeniv); + SET_TexImage1D(table, save_TexImage1D); + SET_TexImage2D(table, save_TexImage2D); + SET_TexParameterf(table, save_TexParameterf); + SET_TexParameterfv(table, save_TexParameterfv); + SET_TexParameteri(table, save_TexParameteri); + SET_TexParameteriv(table, save_TexParameteriv); + SET_Translated(table, save_Translated); + SET_Translatef(table, save_Translatef); + SET_Viewport(table, save_Viewport); + + /* GL 1.1 */ + SET_AreTexturesResident(table, exec_AreTexturesResident); + SET_BindTexture(table, save_BindTexture); + SET_ColorPointer(table, exec_ColorPointer); + SET_CopyTexImage1D(table, save_CopyTexImage1D); + SET_CopyTexImage2D(table, save_CopyTexImage2D); + SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); + SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); + SET_DeleteTextures(table, exec_DeleteTextures); + SET_DisableClientState(table, exec_DisableClientState); + SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); + SET_EnableClientState(table, exec_EnableClientState); + SET_GenTextures(table, exec_GenTextures); + SET_GetPointerv(table, exec_GetPointerv); + SET_IndexPointer(table, exec_IndexPointer); + SET_InterleavedArrays(table, exec_InterleavedArrays); + SET_IsTexture(table, exec_IsTexture); + SET_NormalPointer(table, exec_NormalPointer); + SET_PopClientAttrib(table, exec_PopClientAttrib); + SET_PrioritizeTextures(table, save_PrioritizeTextures); + SET_PushClientAttrib(table, exec_PushClientAttrib); + SET_TexCoordPointer(table, exec_TexCoordPointer); + SET_TexSubImage1D(table, save_TexSubImage1D); + SET_TexSubImage2D(table, save_TexSubImage2D); + SET_VertexPointer(table, exec_VertexPointer); + + /* GL 1.2 */ + SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); + SET_TexImage3D(table, save_TexImage3D); + SET_TexSubImage3D(table, save_TexSubImage3D); + + /* GL 2.0 */ + SET_StencilFuncSeparate(table, save_StencilFuncSeparate); + SET_StencilMaskSeparate(table, save_StencilMaskSeparate); + SET_StencilOpSeparate(table, save_StencilOpSeparate); + + /* ATI_separate_stencil */ + SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); + + /* GL_ARB_imaging */ + /* Not all are supported */ + SET_BlendColor(table, save_BlendColor); + SET_BlendEquation(table, save_BlendEquation); + SET_ColorSubTable(table, save_ColorSubTable); + SET_ColorTable(table, save_ColorTable); + SET_ColorTableParameterfv(table, save_ColorTableParameterfv); + SET_ColorTableParameteriv(table, save_ColorTableParameteriv); + SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); + SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); + SET_ConvolutionParameterf(table, save_ConvolutionParameterf); + SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); + SET_ConvolutionParameteri(table, save_ConvolutionParameteri); + SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); + SET_CopyColorSubTable(table, save_CopyColorSubTable); + SET_CopyColorTable(table, save_CopyColorTable); + SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); + SET_GetColorTable(table, exec_GetColorTable); + SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); + SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); + SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); + SET_GetHistogram(table, exec_GetHistogram); + SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); + SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); + SET_GetMinmax(table, exec_GetMinmax); + SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); + SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); + SET_GetSeparableFilter(table, exec_GetSeparableFilter); + SET_Histogram(table, save_Histogram); + SET_Minmax(table, save_Minmax); + SET_ResetHistogram(table, save_ResetHistogram); + SET_ResetMinmax(table, save_ResetMinmax); + SET_SeparableFilter2D(table, exec_SeparableFilter2D); + + /* 2. GL_EXT_blend_color */ +#if 0 + SET_BlendColorEXT(table, save_BlendColorEXT); +#endif + + /* 3. GL_EXT_polygon_offset */ + SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); + + /* 6. GL_EXT_texture3d */ +#if 0 + SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); + SET_TexImage3DEXT(table, save_TexImage3DEXT); + SET_TexSubImage3DEXT(table, save_TexSubImage3D); +#endif + + /* 14. GL_SGI_color_table */ +#if 0 + SET_ColorTableSGI(table, save_ColorTable); + SET_ColorSubTableSGI(table, save_ColorSubTable); + SET_GetColorTableSGI(table, exec_GetColorTable); + SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); +#endif + + /* 30. GL_EXT_vertex_array */ + SET_ColorPointerEXT(table, exec_ColorPointerEXT); + SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); + SET_IndexPointerEXT(table, exec_IndexPointerEXT); + SET_NormalPointerEXT(table, exec_NormalPointerEXT); + SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); + SET_VertexPointerEXT(table, exec_VertexPointerEXT); + + /* 37. GL_EXT_blend_minmax */ +#if 0 + SET_BlendEquationEXT(table, save_BlendEquationEXT); +#endif + + /* 54. GL_EXT_point_parameters */ + SET_PointParameterfEXT(table, save_PointParameterfEXT); + SET_PointParameterfvEXT(table, save_PointParameterfvEXT); + + /* 97. GL_EXT_compiled_vertex_array */ + SET_LockArraysEXT(table, exec_LockArraysEXT); + SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); + + /* 145. GL_EXT_secondary_color */ + SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); + + /* 148. GL_EXT_multi_draw_arrays */ + SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); + + /* 149. GL_EXT_fog_coord */ + SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); + + /* 173. GL_EXT_blend_func_separate */ + SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); + + /* 196. GL_MESA_resize_buffers */ + SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); + + /* 197. GL_MESA_window_pos */ + SET_WindowPos2dMESA(table, save_WindowPos2dMESA); + SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); + SET_WindowPos2fMESA(table, save_WindowPos2fMESA); + SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); + SET_WindowPos2iMESA(table, save_WindowPos2iMESA); + SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); + SET_WindowPos2sMESA(table, save_WindowPos2sMESA); + SET_WindowPos2svMESA(table, save_WindowPos2svMESA); + SET_WindowPos3dMESA(table, save_WindowPos3dMESA); + SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); + SET_WindowPos3fMESA(table, save_WindowPos3fMESA); + SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); + SET_WindowPos3iMESA(table, save_WindowPos3iMESA); + SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); + SET_WindowPos3sMESA(table, save_WindowPos3sMESA); + SET_WindowPos3svMESA(table, save_WindowPos3svMESA); + SET_WindowPos4dMESA(table, save_WindowPos4dMESA); + SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); + SET_WindowPos4fMESA(table, save_WindowPos4fMESA); + SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); + SET_WindowPos4iMESA(table, save_WindowPos4iMESA); + SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); + SET_WindowPos4sMESA(table, save_WindowPos4sMESA); + SET_WindowPos4svMESA(table, save_WindowPos4svMESA); + + /* 200. GL_IBM_multimode_draw_arrays */ + SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); + +#if FEATURE_NV_vertex_program + /* 233. GL_NV_vertex_program */ + /* The following commands DO NOT go into display lists: + * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, + * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* + */ + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_ExecuteProgramNV(table, save_ExecuteProgramNV); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(table, _mesa_GetProgramivNV); + SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_LoadProgramNV(table, save_LoadProgramNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); + SET_TrackMatrixNV(table, save_TrackMatrixNV); + SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); +#endif + + /* 244. GL_ATI_envmap_bumpmap */ + SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); + + /* 245. GL_ATI_fragment_shader */ +#if FEATURE_ATI_fragment_shader + SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); + SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); +#endif + + /* 282. GL_NV_fragment_program */ +#if FEATURE_NV_fragment_program + SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(table, + _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(table, + _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); +#endif + + /* 262. GL_NV_point_sprite */ + SET_PointParameteriNV(table, save_PointParameteriNV); + SET_PointParameterivNV(table, save_PointParameterivNV); + + /* 268. GL_EXT_stencil_two_side */ + SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); + + /* 273. GL_APPLE_vertex_array_object */ + SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); + + /* ???. GL_EXT_depth_bounds_test */ + SET_DepthBoundsEXT(table, save_DepthBoundsEXT); + + /* ARB 1. GL_ARB_multitexture */ + SET_ActiveTextureARB(table, save_ActiveTextureARB); + SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); + + /* ARB 3. GL_ARB_transpose_matrix */ + SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); + + /* ARB 5. GL_ARB_multisample */ + SET_SampleCoverageARB(table, save_SampleCoverageARB); + + /* ARB 12. GL_ARB_texture_compression */ + SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); + SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); + SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); + + /* ARB 14. GL_ARB_point_parameters */ + /* aliased with EXT_point_parameters functions */ + + /* ARB 25. GL_ARB_window_pos */ + /* aliased with MESA_window_pos functions */ + + /* ARB 26. GL_ARB_vertex_program */ + /* ARB 27. GL_ARB_fragment_program */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ + SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); + SET_ProgramStringARB(table, save_ProgramStringARB); + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramivARB(table, _mesa_GetProgramivARB); + SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); +#endif + + /* ARB 28. GL_ARB_vertex_buffer_object */ +#if FEATURE_ARB_vertex_buffer_object + /* None of the extension's functions get compiled */ + SET_BindBufferARB(table, _mesa_BindBufferARB); + SET_BufferDataARB(table, _mesa_BufferDataARB); + SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); + SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); + SET_GenBuffersARB(table, _mesa_GenBuffersARB); + SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); + SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); + SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); + SET_IsBufferARB(table, _mesa_IsBufferARB); + SET_MapBufferARB(table, _mesa_MapBufferARB); + SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); +#endif + +#if FEATURE_queryobj + SET_BeginQueryARB(table, save_BeginQueryARB); + SET_EndQueryARB(table, save_EndQueryARB); + SET_GenQueriesARB(table, _mesa_GenQueriesARB); + SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB); + SET_IsQueryARB(table, _mesa_IsQueryARB); + SET_GetQueryivARB(table, _mesa_GetQueryivARB); + SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB); + SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB); +#endif + SET_DrawBuffersARB(table, save_DrawBuffersARB); + +#if FEATURE_EXT_framebuffer_blit + SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); +#endif + + /* GL_ARB_shader_objects */ + SET_UseProgramObjectARB(table, save_UseProgramObjectARB); + SET_Uniform1fARB(table, save_Uniform1fARB); + SET_Uniform2fARB(table, save_Uniform2fARB); + SET_Uniform3fARB(table, save_Uniform3fARB); + SET_Uniform4fARB(table, save_Uniform4fARB); + SET_Uniform1fvARB(table, save_Uniform1fvARB); + SET_Uniform2fvARB(table, save_Uniform2fvARB); + SET_Uniform3fvARB(table, save_Uniform3fvARB); + SET_Uniform4fvARB(table, save_Uniform4fvARB); + SET_Uniform1iARB(table, save_Uniform1iARB); + SET_Uniform2iARB(table, save_Uniform2iARB); + SET_Uniform3iARB(table, save_Uniform3iARB); + SET_Uniform4iARB(table, save_Uniform4iARB); + SET_Uniform1ivARB(table, save_Uniform1ivARB); + SET_Uniform2ivARB(table, save_Uniform2ivARB); + SET_Uniform3ivARB(table, save_Uniform3ivARB); + SET_Uniform4ivARB(table, save_Uniform4ivARB); + SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); + SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); + SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); + SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); + + /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); + SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); + SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); + /* XXX additional functions need to be implemented here! */ + + /* 299. GL_EXT_blend_equation_separate */ + SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); + + /* GL_EXT_gpu_program_parameters */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); +#endif + + /* ARB 50. GL_ARB_map_buffer_range */ +#if FEATURE_ARB_map_buffer_range + SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ + SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ +#endif + + /* ARB 59. GL_ARB_copy_buffer */ + SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ + + /* 352. GL_EXT_transform_feedback */ +#if FEATURE_EXT_transform_feedback + SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); + SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); +#endif + + /* 364. GL_EXT_provoking_vertex */ + SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); + + /* 371. GL_APPLE_object_purgeable */ +#if FEATURE_APPLE_object_purgeable + SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); + SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); +#endif + + /* GL_EXT_texture_integer */ + SET_ClearColorIiEXT(table, save_ClearColorIi); + SET_ClearColorIuiEXT(table, save_ClearColorIui); + SET_TexParameterIivEXT(table, save_TexParameterIiv); + SET_TexParameterIuivEXT(table, save_TexParameterIuiv); + SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); + SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); + + /* 377. GL_EXT_separate_shader_objects */ + SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); + SET_ActiveProgramEXT(table, save_ActiveProgramEXT); + + /* GL 3.0 */ +#if 0 + SET_ClearBufferiv(table, save_ClearBufferiv); + SET_ClearBufferuiv(table, save_ClearBufferuiv); + SET_ClearBufferfv(table, save_ClearBufferfv); + SET_ClearBufferfi(table, save_ClearBufferfi); + SET_Uniform1ui(table, save_Uniform1ui); + SET_Uniform2ui(table, save_Uniform2ui); + SET_Uniform3ui(table, save_Uniform3ui); + SET_Uniform4ui(table, save_Uniform4ui); + SET_Uniform1uiv(table, save_Uniform1uiv); + SET_Uniform2uiv(table, save_Uniform2uiv); + SET_Uniform3uiv(table, save_Uniform3uiv); + SET_Uniform4uiv(table, save_Uniform4uiv); +#else + (void) save_ClearBufferiv; + (void) save_ClearBufferuiv; + (void) save_ClearBufferfv; + (void) save_ClearBufferfi; + (void) save_Uniform1ui; + (void) save_Uniform2ui; + (void) save_Uniform3ui; + (void) save_Uniform4ui; + (void) save_Uniform1uiv; + (void) save_Uniform2uiv; + (void) save_Uniform3uiv; + (void) save_Uniform4uiv; +#endif + + /* GL_ARB_instanced_arrays */ + SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor); + + /* GL_ARB_draw_buffer_blend */ + SET_BlendFunciARB(table, save_BlendFunci); + SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei); + SET_BlendEquationiARB(table, save_BlendEquationi); + SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei); + + return table; +} + + + +static const char * +enum_string(GLenum k) +{ + return _mesa_lookup_enum_by_nr(k); +} + + +/** + * Print the commands in a display list. For debugging only. + * TODO: many commands aren't handled yet. + */ +static void GLAPIENTRY +print_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (!islist(ctx, list)) { + printf("%u is not a display list ID\n", list); + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + n = dlist->Head; + + printf("START-LIST %u, address %p\n", list, (void *) n); + + done = n ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_print(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ACCUM: + printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); + break; + case OPCODE_BITMAP: + printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); + break; + case OPCODE_CALL_LIST: + printf("CallList %d\n", (int) n[1].ui); + break; + case OPCODE_CALL_LIST_OFFSET: + printf("CallList %d + offset %u = %u\n", (int) n[1].ui, + ctx->List.ListBase, ctx->List.ListBase + n[1].ui); + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + printf("ColorTableParameterfv %s %s %f %f %f %f\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + printf("ColorTableParameteriv %s %s %d %d %d %d\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].i, n[4].i, n[5].i, n[6].i); + break; + case OPCODE_DISABLE: + printf("Disable %s\n", enum_string(n[1].e)); + break; + case OPCODE_ENABLE: + printf("Enable %s\n", enum_string(n[1].e)); + break; + case OPCODE_FRUSTUM: + printf("Frustum %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_LINE_STIPPLE: + printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); + break; + case OPCODE_LOAD_IDENTITY: + printf("LoadIdentity\n"); + break; + case OPCODE_LOAD_MATRIX: + printf("LoadMatrix\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_MULT_MATRIX: + printf("MultMatrix (or Rotate)\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_ORTHO: + printf("Ortho %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_POP_ATTRIB: + printf("PopAttrib\n"); + break; + case OPCODE_POP_MATRIX: + printf("PopMatrix\n"); + break; + case OPCODE_POP_NAME: + printf("PopName\n"); + break; + case OPCODE_PUSH_ATTRIB: + printf("PushAttrib %x\n", n[1].bf); + break; + case OPCODE_PUSH_MATRIX: + printf("PushMatrix\n"); + break; + case OPCODE_PUSH_NAME: + printf("PushName %d\n", (int) n[1].ui); + break; + case OPCODE_RASTER_POS: + printf("RasterPos %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ROTATE: + printf("Rotate %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_SCALE: + printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_TRANSLATE: + printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_BIND_TEXTURE: + printf("BindTexture %s %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); + break; + case OPCODE_SHADE_MODEL: + printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); + break; + case OPCODE_MAP1: + printf("Map1 %s %.3f %.3f %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].i, n[5].i); + break; + case OPCODE_MAP2: + printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].f, n[5].f, + n[6].i, n[7].i, n[8].i, n[9].i); + break; + case OPCODE_MAPGRID1: + printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); + break; + case OPCODE_MAPGRID2: + printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", + n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); + break; + case OPCODE_EVALMESH1: + printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); + break; + case OPCODE_EVALMESH2: + printf("EvalMesh2 %d %d %d %d\n", + n[1].i, n[2].i, n[3].i, n[4].i); + break; + + case OPCODE_ATTR_1F_NV: + printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_NV: + printf("ATTR_2F_NV attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_NV: + printf("ATTR_3F_NV attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_NV: + printf("ATTR_4F_NV attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + case OPCODE_ATTR_1F_ARB: + printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_ARB: + printf("ATTR_2F_ARB attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_ARB: + printf("ATTR_3F_ARB attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_ARB: + printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + + case OPCODE_MATERIAL: + printf("MATERIAL %x %x: %f %f %f %f\n", + n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_BEGIN: + printf("BEGIN %x\n", n[1].i); + break; + case OPCODE_END: + printf("END\n"); + break; + case OPCODE_RECTF: + printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, + n[4].f); + break; + case OPCODE_EVAL_C1: + printf("EVAL_C1 %f\n", n[1].f); + break; + case OPCODE_EVAL_C2: + printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); + break; + case OPCODE_EVAL_P1: + printf("EVAL_P1 %d\n", n[1].i); + break; + case OPCODE_EVAL_P2: + printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); + break; + + case OPCODE_PROVOKING_VERTEX: + printf("ProvokingVertex %s\n", + _mesa_lookup_enum_by_nr(n[1].ui)); + break; + + /* + * meta opcodes/commands + */ + case OPCODE_ERROR: + printf("Error: %s %s\n", + enum_string(n[1].e), (const char *) n[2].data); + break; + case OPCODE_CONTINUE: + printf("DISPLAY-LIST-CONTINUE\n"); + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + printf("END-LIST %u\n", list); + done = GL_TRUE; + break; + default: + if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { + printf + ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", + opcode, (void *) n); + return; + } + else { + printf("command %d, %u operands\n", opcode, + InstSize[opcode]); + } + } + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } +} + + + +/** + * Clients may call this function to help debug display list problems. + * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, + * changed, or break in the future without notice. + */ +void +mesa_print_display_list(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + print_list(ctx, list); +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void +_mesa_save_vtxfmt_init(GLvertexformat * vfmt) +{ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + + vfmt->Begin = save_Begin; + + _MESA_INIT_DLIST_VTXFMT(vfmt, save_); + + vfmt->Color3f = save_Color3f; + vfmt->Color3fv = save_Color3fv; + vfmt->Color4f = save_Color4f; + vfmt->Color4fv = save_Color4fv; + vfmt->EdgeFlag = save_EdgeFlag; + vfmt->End = save_End; + + _MESA_INIT_EVAL_VTXFMT(vfmt, save_); + + vfmt->FogCoordfEXT = save_FogCoordfEXT; + vfmt->FogCoordfvEXT = save_FogCoordfvEXT; + vfmt->Indexf = save_Indexf; + vfmt->Indexfv = save_Indexfv; + vfmt->Materialfv = save_Materialfv; + vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; + vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; + vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; + vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; + vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; + vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; + vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; + vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; + vfmt->Normal3f = save_Normal3f; + vfmt->Normal3fv = save_Normal3fv; + vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; + vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; + vfmt->TexCoord1f = save_TexCoord1f; + vfmt->TexCoord1fv = save_TexCoord1fv; + vfmt->TexCoord2f = save_TexCoord2f; + vfmt->TexCoord2fv = save_TexCoord2fv; + vfmt->TexCoord3f = save_TexCoord3f; + vfmt->TexCoord3fv = save_TexCoord3fv; + vfmt->TexCoord4f = save_TexCoord4f; + vfmt->TexCoord4fv = save_TexCoord4fv; + vfmt->Vertex2f = save_Vertex2f; + vfmt->Vertex2fv = save_Vertex2fv; + vfmt->Vertex3f = save_Vertex3f; + vfmt->Vertex3fv = save_Vertex3fv; + vfmt->Vertex4f = save_Vertex4f; + vfmt->Vertex4fv = save_Vertex4fv; + vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; + vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; + vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; + vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; + vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; + vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; + vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; + vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; + vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; + vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; + vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; + vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; + vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; + vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; + vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; + + vfmt->Rectf = save_Rectf; + + /* The driver is required to implement these as + * 1) They can probably do a better job. + * 2) A lot of new mechanisms would have to be added to this module + * to support it. That code would probably never get used, + * because of (1). + */ +#if 0 + vfmt->DrawArrays = 0; + vfmt->DrawElements = 0; + vfmt->DrawRangeElements = 0; + vfmt->MultiDrawElemementsEXT = 0; + vfmt->DrawElementsBaseVertex = 0; + vfmt->DrawRangeElementsBaseVertex = 0; + vfmt->MultiDrawElemementsBaseVertex = 0; +#endif +} + + +void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_CallList(disp, vfmt->CallList); + SET_CallLists(disp, vfmt->CallLists); +} + + +void _mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ + SET_CallList(disp, _mesa_CallList); + SET_CallLists(disp, _mesa_CallLists); + + SET_DeleteLists(disp, _mesa_DeleteLists); + SET_EndList(disp, _mesa_EndList); + SET_GenLists(disp, _mesa_GenLists); + SET_IsList(disp, _mesa_IsList); + SET_ListBase(disp, _mesa_ListBase); + SET_NewList(disp, _mesa_NewList); +} + + +#endif /* FEATURE_dlist */ + + +/** + * Initialize display list state for given context. + */ +void +_mesa_init_display_list(struct gl_context *ctx) +{ + static GLboolean tableInitialized = GL_FALSE; + + /* zero-out the instruction size table, just once */ + if (!tableInitialized) { + memset(InstSize, 0, sizeof(InstSize)); + tableInitialized = GL_TRUE; + } + + /* extension info */ + ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); + + /* Display list */ + ctx->ListState.CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->ListState.CurrentBlock = NULL; + ctx->ListState.CurrentPos = 0; + + /* Display List group */ + ctx->List.ListBase = 0; + +#if FEATURE_dlist + _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); +#endif +} + + +void +_mesa_free_display_list_data(struct gl_context *ctx) +{ + free(ctx->ListExt); + ctx->ListExt = NULL; +} diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index a994dbcae..ce7baabe2 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -540,6 +540,12 @@ extern void _mesa_init_sqrt_table(void); #ifdef __GNUC__ + +#ifdef __MINGW32__ +#define ffs __builtin_ffs +#define ffsll __builtin_ffsll +#endif + #define _mesa_ffs(i) ffs(i) #define _mesa_ffsll(i) ffsll(i) diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index 37940efdc..6834f3b5a 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -130,6 +130,8 @@ void vbo_use_buffer_objects(struct gl_context *ctx); void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func); +void vbo_check_buffers_are_unmapped(struct gl_context *ctx); + void GLAPIENTRY _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h index ca100e428..1b0ed7947 100644 --- a/mesalib/src/mesa/vbo/vbo_exec.h +++ b/mesalib/src/mesa/vbo/vbo_exec.h @@ -40,13 +40,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo_attrib.h" +/** + * Max number of primitives (number of glBegin/End pairs) per VBO. + */ #define VBO_MAX_PRIM 64 -/* Wierd implementation stuff: + +/** + * Size of the VBO to use for glBegin/glVertex/glEnd-style rendering. */ #define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */ -#define VBO_MAX_ATTR_CODEGEN 16 -#define ERROR_ATTRIB 16 /** Current vertex program mode */ diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index c4d39d8f1..2f9f3ec7c 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -378,7 +378,7 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) * afterwards). */ if (attr == 0) - exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; + ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; } @@ -862,7 +862,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) /* Hook our functions into the dispatch table. */ - _mesa_install_exec_vtxfmt( exec->ctx, &exec->vtxfmt ); + _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt ); for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { ASSERT(i < Elements(exec->vtx.attrsz)); @@ -941,8 +941,8 @@ void vbo_exec_BeginVertices( struct gl_context *ctx ) vbo_exec_vtx_map( exec ); - assert((exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); - exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; + assert((ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); + ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; } @@ -960,7 +960,7 @@ void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags ) assert(exec->flush_call_depth == 1); #endif - if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { /* We've had glBegin but not glEnd! */ #ifdef DEBUG exec->flush_call_depth--; @@ -974,10 +974,7 @@ void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags ) /* Need to do this to ensure BeginVertices gets called again: */ - if (exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) - exec->ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; - - exec->ctx->Driver.NeedFlush &= ~flags; + ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags); #ifdef DEBUG exec->flush_call_depth--; diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 65a0642f1..457343a1a 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -1,1307 +1,1324 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/state.h" -#include "main/api_validate.h" -#include "main/varray.h" -#include "main/bufferobj.h" -#include "main/enums.h" -#include "main/macros.h" - -#include "vbo_context.h" - - -/** - * All vertex buffers should be in an unmapped state when we're about - * to draw. This debug function checks that. - */ -static void -check_buffers_are_unmapped(const struct gl_client_array **inputs) -{ -#ifdef DEBUG - GLuint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) { - if (inputs[i]) { - struct gl_buffer_object *obj = inputs[i]->BufferObj; - assert(!_mesa_bufferobj_mapped(obj)); - } - } -#endif -} - - -/** - * Compute min and max elements by scanning the index buffer for - * glDraw[Range]Elements() calls. - * If primitive restart is enabled, we need to ignore restart - * indexes when computing min/max. - */ -void -vbo_get_minmax_index(struct gl_context *ctx, - const struct _mesa_prim *prim, - const struct _mesa_index_buffer *ib, - GLuint *min_index, GLuint *max_index) -{ - const GLboolean restart = ctx->Array.PrimitiveRestart; - const GLuint restartIndex = ctx->Array.RestartIndex; - const GLuint count = prim->count; - const void *indices; - GLuint i; - - if (_mesa_is_bufferobj(ib->obj)) { - const GLvoid *map = - ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, ib->obj); - indices = ADD_POINTERS(map, ib->ptr); - } else { - indices = ib->ptr; - } - - switch (ib->type) { - case GL_UNSIGNED_INT: { - const GLuint *ui_indices = (const GLuint *)indices; - GLuint max_ui = 0; - GLuint min_ui = ~0U; - if (restart) { - for (i = 0; i < count; i++) { - if (ui_indices[i] != restartIndex) { - if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; - if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; - } - } - } - else { - for (i = 0; i < count; i++) { - if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; - if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; - } - } - *min_index = min_ui; - *max_index = max_ui; - break; - } - case GL_UNSIGNED_SHORT: { - const GLushort *us_indices = (const GLushort *)indices; - GLuint max_us = 0; - GLuint min_us = ~0U; - if (restart) { - for (i = 0; i < count; i++) { - if (us_indices[i] != restartIndex) { - if (us_indices[i] > max_us) max_us = us_indices[i]; - if (us_indices[i] < min_us) min_us = us_indices[i]; - } - } - } - else { - for (i = 0; i < count; i++) { - if (us_indices[i] > max_us) max_us = us_indices[i]; - if (us_indices[i] < min_us) min_us = us_indices[i]; - } - } - *min_index = min_us; - *max_index = max_us; - break; - } - case GL_UNSIGNED_BYTE: { - const GLubyte *ub_indices = (const GLubyte *)indices; - GLuint max_ub = 0; - GLuint min_ub = ~0U; - if (restart) { - for (i = 0; i < count; i++) { - if (ub_indices[i] != restartIndex) { - if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; - if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; - } - } - } - else { - for (i = 0; i < count; i++) { - if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; - if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; - } - } - *min_index = min_ub; - *max_index = max_ub; - break; - } - default: - assert(0); - break; - } - - if (_mesa_is_bufferobj(ib->obj)) { - ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ib->obj); - } -} - - -/** - * Check that element 'j' of the array has reasonable data. - * Map VBO if needed. - * For debugging purposes; not normally used. - */ -static void -check_array_data(struct gl_context *ctx, struct gl_client_array *array, - GLuint attrib, GLuint j) -{ - if (array->Enabled) { - const void *data = array->Ptr; - if (_mesa_is_bufferobj(array->BufferObj)) { - if (!array->BufferObj->Pointer) { - /* need to map now */ - array->BufferObj->Pointer = - ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, - GL_READ_ONLY, array->BufferObj); - } - data = ADD_POINTERS(data, array->BufferObj->Pointer); - } - switch (array->Type) { - case GL_FLOAT: - { - GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j); - GLint k; - for (k = 0; k < array->Size; k++) { - if (IS_INF_OR_NAN(f[k]) || - f[k] >= 1.0e20 || f[k] <= -1.0e10) { - printf("Bad array data:\n"); - printf(" Element[%u].%u = %f\n", j, k, f[k]); - printf(" Array %u at %p\n", attrib, (void* ) array); - printf(" Type 0x%x, Size %d, Stride %d\n", - array->Type, array->Size, array->Stride); - printf(" Address/offset %p in Buffer Object %u\n", - array->Ptr, array->BufferObj->Name); - f[k] = 1.0; /* XXX replace the bad value! */ - } - /*assert(!IS_INF_OR_NAN(f[k]));*/ - } - } - break; - default: - ; - } - } -} - - -/** - * Unmap the buffer object referenced by given array, if mapped. - */ -static void -unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array) -{ - if (array->Enabled && - _mesa_is_bufferobj(array->BufferObj) && - _mesa_bufferobj_mapped(array->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, array->BufferObj); - } -} - - -/** - * Examine the array's data for NaNs, etc. - * For debug purposes; not normally used. - */ -static void -check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, - const void *elements, GLint basevertex) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - const void *elemMap; - GLint i, k; - - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - elemMap = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - ctx->Array.ElementArrayBufferObj); - elements = ADD_POINTERS(elements, elemMap); - } - - for (i = 0; i < count; i++) { - GLuint j; - - /* j = element[i] */ - switch (elemType) { - case GL_UNSIGNED_BYTE: - j = ((const GLubyte *) elements)[i]; - break; - case GL_UNSIGNED_SHORT: - j = ((const GLushort *) elements)[i]; - break; - case GL_UNSIGNED_INT: - j = ((const GLuint *) elements)[i]; - break; - default: - assert(0); - } - - /* check element j of each enabled array */ - check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j); - check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j); - check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j); - check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j); - for (k = 0; k < Elements(arrayObj->TexCoord); k++) { - check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j); - } - for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) { - check_array_data(ctx, &arrayObj->VertexAttrib[k], - VERT_ATTRIB_GENERIC0 + k, j); - } - } - - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); - } - - unmap_array_buffer(ctx, &arrayObj->Vertex); - unmap_array_buffer(ctx, &arrayObj->Normal); - unmap_array_buffer(ctx, &arrayObj->Color); - for (k = 0; k < Elements(arrayObj->TexCoord); k++) { - unmap_array_buffer(ctx, &arrayObj->TexCoord[k]); - } - for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) { - unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]); - } -} - - -/** - * Check array data, looking for NaNs, etc. - */ -static void -check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count) -{ - /* TO DO */ -} - - -/** - * Print info/data for glDrawArrays(), for debugging. - */ -static void -print_draw_arrays(struct gl_context *ctx, - GLenum mode, GLint start, GLsizei count) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - int i; - - printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", - mode, start, count); - - for (i = 0; i < 32; i++) { - GLuint bufName = exec->array.inputs[i]->BufferObj->Name; - GLint stride = exec->array.inputs[i]->Stride; - printf("attr %2d: size %d stride %d enabled %d " - "ptr %p Bufobj %u\n", - i, - exec->array.inputs[i]->Size, - stride, - /*exec->array.inputs[i]->Enabled,*/ - exec->array.legacy_array[i]->Enabled, - exec->array.inputs[i]->Ptr, - bufName); - - if (bufName) { - struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName); - GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, - GL_READ_ONLY_ARB, buf); - int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr; - float *f = (float *) (p + offset); - int *k = (int *) f; - int i; - int n = (count * stride) / 4; - if (n > 32) - n = 32; - printf(" Data at offset %d:\n", offset); - for (i = 0; i < n; i++) { - printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); - } - ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf); - } - } -} - - -/** - * Bind the VBO executor to the current vertex array object prior - * to drawing. - * - * Just translate the arrayobj into a sane layout. - */ -static void -bind_array_obj(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i; - - /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array - * rather than as individual named arrays. Then this function can - * go away. - */ - exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex; - exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight; - exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal; - exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color; - exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor; - exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord; - exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index; - if (arrayObj->PointSize.Enabled) { - /* this aliases COLOR_INDEX */ - exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize; - } - exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag; - - for (i = 0; i < Elements(arrayObj->TexCoord); i++) - exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i]; - - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { - assert(i < Elements(exec->array.generic_array)); - exec->array.generic_array[i] = &arrayObj->VertexAttrib[i]; - } - - exec->array.array_obj = arrayObj->Name; -} - - -/** - * Set the vbo->exec->inputs[] pointers to point to the enabled - * vertex arrays. This depends on the current vertex program/shader - * being executed because of whether or not generic vertex arrays - * alias the conventional vertex arrays. - * For arrays that aren't enabled, we set the input[attrib] pointer - * to point at a zero-stride current value "array". - */ -static void -recalculate_input_bindings(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - const struct gl_client_array **inputs = &exec->array.inputs[0]; - GLbitfield const_inputs = 0x0; - GLuint i; - - exec->array.program_mode = get_program_mode(ctx); - exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled; - - switch (exec->array.program_mode) { - case VP_NONE: - /* When no vertex program is active (or the vertex program is generated - * from fixed-function state). We put the material values into the - * generic slots. This is the only situation where material values - * are available as per-vertex attributes. - */ - for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { - if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= 1 << i; - } - } - - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i]; - const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); - } - - /* Could use just about anything, just to fill in the empty - * slots: - */ - for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) { - inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; - const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); - } - break; - - case VP_NV: - /* NV_vertex_program - attribute arrays alias and override - * conventional, legacy arrays. No materials, and the generic - * slots are vacant. - */ - for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { - if (exec->array.generic_array[i]->Enabled) - inputs[i] = exec->array.generic_array[i]; - else if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= 1 << i; - } - } - - /* Could use just about anything, just to fill in the empty - * slots: - */ - for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { - inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; - const_inputs |= 1 << i; - } - break; - - case VP_ARB: - /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0] - * attribute array aliases and overrides the legacy position array. - * - * Otherwise, legacy attributes available in the legacy slots, - * generic attributes in the generic slots and materials are not - * available as per-vertex attributes. - */ - if (exec->array.generic_array[0]->Enabled) - inputs[0] = exec->array.generic_array[0]; - else if (exec->array.legacy_array[0]->Enabled) - inputs[0] = exec->array.legacy_array[0]; - else { - inputs[0] = &vbo->legacy_currval[0]; - const_inputs |= 1 << 0; - } - - for (i = 1; i <= VERT_ATTRIB_TEX7; i++) { - if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= 1 << i; - } - } - - for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { - if (exec->array.generic_array[i]->Enabled) - inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; - else { - inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; - const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); - } - - } - break; - } - - _mesa_set_varying_vp_inputs( ctx, ~const_inputs ); -} - - -/** - * Examine the enabled vertex arrays to set the exec->array.inputs[] values. - * These will point to the arrays to actually use for drawing. Some will - * be user-provided arrays, other will be zero-stride const-valued arrays. - * Note that this might set the _NEW_ARRAY dirty flag so state validation - * must be done after this call. - */ -static void -bind_arrays(struct gl_context *ctx) -{ - if (!ctx->Array.RebindArrays) { - return; - } - - bind_array_obj(ctx); - recalculate_input_bindings(ctx); - ctx->Array.RebindArrays = GL_FALSE; -} - - -/** - * Helper function called by the other DrawArrays() functions below. - * This is where we handle primitive restart for drawing non-indexed - * arrays. If primitive restart is enabled, it typically means - * splitting one DrawArrays() into two. - */ -static void -vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, - GLsizei count, GLuint numInstances) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_prim prim[2]; - - bind_arrays(ctx); - - /* Again... because we may have changed the bitmask of per-vertex varying - * attributes. If we regenerate the fixed-function vertex program now - * we may be able to prune down the number of vertex attributes which we - * need in the shader. - */ - if (ctx->NewState) - _mesa_update_state(ctx); - - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; /* filled in below */ - prim[0].count = 0; /* filled in below */ - prim[0].indexed = 0; - prim[0].basevertex = 0; - prim[0].num_instances = numInstances; - - /* Implement the primitive restart index */ - if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) { - GLuint primCount = 0; - - if (ctx->Array.RestartIndex == start) { - /* special case: RestartIndex at beginning */ - if (count > 1) { - prim[0].start = start + 1; - prim[0].count = count - 1; - primCount = 1; - } - } - else if (ctx->Array.RestartIndex == start + count - 1) { - /* special case: RestartIndex at end */ - if (count > 1) { - prim[0].start = start; - prim[0].count = count - 1; - primCount = 1; - } - } - else { - /* general case: RestartIndex in middle, split into two prims */ - prim[0].start = start; - prim[0].count = ctx->Array.RestartIndex - start; - - prim[1] = prim[0]; - prim[1].start = ctx->Array.RestartIndex + 1; - prim[1].count = count - prim[1].start; - - primCount = 2; - } - - if (primCount > 0) { - /* draw one or two prims */ - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL, - GL_TRUE, start, start + count - 1); - } - } - else { - /* no prim restart */ - prim[0].start = start; - prim[0].count = count; - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL, - GL_TRUE, start, start + count - 1); - } -} - - - -/** - * Called from glDrawArrays when in immediate mode (not display list mode). - */ -static void GLAPIENTRY -vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n", - _mesa_lookup_enum_by_nr(mode), start, count); - - if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) - return; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glDrawArrays")) { - return; - } - - if (0) - check_draw_arrays_data(ctx, start, count); - - vbo_draw_arrays(ctx, mode, start, count, 1); - - if (0) - print_draw_arrays(ctx, mode, start, count); -} - - -/** - * Called from glDrawArraysInstanced when in immediate mode (not - * display list mode). - */ -static void GLAPIENTRY -vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count, - GLsizei numInstances) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n", - _mesa_lookup_enum_by_nr(mode), start, count, numInstances); - - if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances)) - return; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glDrawArraysInstanced")) { - return; - } - - if (0) - check_draw_arrays_data(ctx, start, count); - - vbo_draw_arrays(ctx, mode, start, count, numInstances); - - if (0) - print_draw_arrays(ctx, mode, start, count); -} - - -/** - * Map GL_ELEMENT_ARRAY_BUFFER and print contents. - * For debugging. - */ -static void -dump_element_buffer(struct gl_context *ctx, GLenum type) -{ - const GLvoid *map = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - ctx->Array.ElementArrayBufferObj); - switch (type) { - case GL_UNSIGNED_BYTE: - { - const GLubyte *us = (const GLubyte *) map; - GLint i; - for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) { - printf("%02x ", us[i]); - if (i % 32 == 31) - printf("\n"); - } - printf("\n"); - } - break; - case GL_UNSIGNED_SHORT: - { - const GLushort *us = (const GLushort *) map; - GLint i; - for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) { - printf("%04x ", us[i]); - if (i % 16 == 15) - printf("\n"); - } - printf("\n"); - } - break; - case GL_UNSIGNED_INT: - { - const GLuint *us = (const GLuint *) map; - GLint i; - for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) { - printf("%08x ", us[i]); - if (i % 8 == 7) - printf("\n"); - } - printf("\n"); - } - break; - default: - ; - } - - ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); -} - - -/** - * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements. - * Do the rendering for a glDrawElements or glDrawRangeElements call after - * we've validated buffer bounds, etc. - */ -static void -vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, - GLboolean index_bounds_valid, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, - GLint basevertex, GLint numInstances) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_index_buffer ib; - struct _mesa_prim prim[1]; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) { - return; - } - - bind_arrays( ctx ); - - /* check for dirty state again */ - if (ctx->NewState) - _mesa_update_state( ctx ); - - ib.count = count; - ib.type = type; - ib.obj = ctx->Array.ElementArrayBufferObj; - ib.ptr = indices; - - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count; - prim[0].indexed = 1; - prim[0].basevertex = basevertex; - prim[0].num_instances = numInstances; - - /* Need to give special consideration to rendering a range of - * indices starting somewhere above zero. Typically the - * application is issuing multiple DrawRangeElements() to draw - * successive primitives layed out linearly in the vertex arrays. - * Unless the vertex arrays are all in a VBO (or locked as with - * CVA), the OpenGL semantics imply that we need to re-read or - * re-upload the vertex data on each draw call. - * - * In the case of hardware tnl, we want to avoid starting the - * upload at zero, as it will mean every draw call uploads an - * increasing amount of not-used vertex data. Worse - in the - * software tnl module, all those vertices might be transformed and - * lit but never rendered. - * - * If we just upload or transform the vertices in start..end, - * however, the indices will be incorrect. - * - * At this level, we don't know exactly what the requirements of - * the backend are going to be, though it will likely boil down to - * either: - * - * 1) Do nothing, everything is in a VBO and is processed once - * only. - * - * 2) Adjust the indices and vertex arrays so that start becomes - * zero. - * - * Rather than doing anything here, I'll provide a helper function - * for the latter case elsewhere. - */ - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, - index_bounds_valid, start, end ); -} - - -/** - * Called by glDrawRangeElementsBaseVertex() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, - GLint basevertex) -{ - static GLuint warnCount = 0; - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, - "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n", - _mesa_lookup_enum_by_nr(mode), start, end, count, - _mesa_lookup_enum_by_nr(type), indices, basevertex); - - if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, - type, indices, basevertex )) - return; - - /* NOTE: It's important that 'end' is a reasonable value. - * in _tnl_draw_prims(), we use end to determine how many vertices - * to transform. If it's too large, we can unnecessarily split prims - * or we can read/write out of memory in several different places! - */ - - /* Catch/fix some potential user errors */ - if (type == GL_UNSIGNED_BYTE) { - start = MIN2(start, 0xff); - end = MIN2(end, 0xff); - } - else if (type == GL_UNSIGNED_SHORT) { - start = MIN2(start, 0xffff); - end = MIN2(end, 0xffff); - } - - if (end >= ctx->Array.ArrayObj->_MaxElement) { - /* the max element is out of bounds of one or more enabled arrays */ - warnCount++; - - if (warnCount < 10) { - _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, " - "type 0x%x, indices=%p)\n" - "\tend is out of bounds (max=%u) " - "Element Buffer %u (size %d)\n" - "\tThis should probably be fixed in the application.", - start, end, count, type, indices, - ctx->Array.ArrayObj->_MaxElement - 1, - ctx->Array.ElementArrayBufferObj->Name, - (int) ctx->Array.ElementArrayBufferObj->Size); - } - - if (0) - dump_element_buffer(ctx, type); - - if (0) - _mesa_print_arrays(ctx); - -#ifdef DEBUG - /* 'end' was out of bounds, but now let's check the actual array - * indexes to see if any of them are out of bounds. - */ - { - GLuint max = _mesa_max_buffer_index(ctx, count, type, indices, - ctx->Array.ElementArrayBufferObj); - if (max >= ctx->Array.ArrayObj->_MaxElement) { - if (warnCount < 10) { - _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, " - "count %d, type 0x%x, indices=%p)\n" - "\tindex=%u is out of bounds (max=%u) " - "Element Buffer %u (size %d)\n" - "\tSkipping the glDrawRangeElements() call", - start, end, count, type, indices, max, - ctx->Array.ArrayObj->_MaxElement - 1, - ctx->Array.ElementArrayBufferObj->Name, - (int) ctx->Array.ElementArrayBufferObj->Size); - } - } - /* XXX we could also find the min index and compare to 'start' - * to see if start is correct. But it's more likely to get the - * upper bound wrong. - */ - } -#endif - - /* Set 'end' to the max possible legal value */ - assert(ctx->Array.ArrayObj->_MaxElement >= 1); - end = ctx->Array.ArrayObj->_MaxElement - 1; - } - else if (0) { - printf("glDraw[Range]Elements{,BaseVertex}" - "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, " - "base %d\n", - start, end, type, count, - ctx->Array.ElementArrayBufferObj->Name, - basevertex); - } - -#if 0 - check_draw_elements_data(ctx, count, type, indices); -#else - (void) check_draw_elements_data; -#endif - - vbo_validated_drawrangeelements(ctx, mode, GL_TRUE, start, end, - count, type, indices, basevertex, 1); -} - - -/** - * Called by glDrawRangeElements() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end, - GLsizei count, GLenum type, const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, - "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n", - _mesa_lookup_enum_by_nr(mode), start, end, count, - _mesa_lookup_enum_by_nr(type), indices); - - vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type, - indices, 0); -} - - -/** - * Called by glDrawElements() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n", - _mesa_lookup_enum_by_nr(mode), count, - _mesa_lookup_enum_by_nr(type), indices); - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) - return; - - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, - count, type, indices, 0, 1); -} - - -/** - * Called by glDrawElementsBaseVertex() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n", - _mesa_lookup_enum_by_nr(mode), count, - _mesa_lookup_enum_by_nr(type), indices, basevertex); - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, - basevertex )) - return; - - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, - count, type, indices, basevertex, 1); -} - - -/** - * Called by glDrawElementsInstanced() in immediate mode. - */ -static void GLAPIENTRY -vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei numInstances) -{ - GET_CURRENT_CONTEXT(ctx); - - if (MESA_VERBOSE & VERBOSE_DRAW) - _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n", - _mesa_lookup_enum_by_nr(mode), count, - _mesa_lookup_enum_by_nr(type), indices, numInstances); - - if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices, - numInstances)) - return; - - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, - count, type, indices, 0, numInstances); -} - - -/** - * Inner support for both _mesa_MultiDrawElements() and - * _mesa_MultiDrawRangeElements(). - * This does the actual rendering after we've checked array indexes, etc. - */ -static void -vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount, - const GLint *basevertex) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_index_buffer ib; - struct _mesa_prim *prim; - unsigned int index_type_size = 0; - uintptr_t min_index_ptr, max_index_ptr; - GLboolean fallback = GL_FALSE; - int i; - - if (primcount == 0) - return; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) { - return; - } - - prim = calloc(1, primcount * sizeof(*prim)); - if (prim == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); - return; - } - - /* Decide if we can do this all as one set of primitives sharing the - * same index buffer, or if we have to reset the index pointer per - * primitive. - */ - bind_arrays( ctx ); - - /* check for dirty state again */ - if (ctx->NewState) - _mesa_update_state( ctx ); - - switch (type) { - case GL_UNSIGNED_INT: - index_type_size = 4; - break; - case GL_UNSIGNED_SHORT: - index_type_size = 2; - break; - case GL_UNSIGNED_BYTE: - index_type_size = 1; - break; - default: - assert(0); - } - - min_index_ptr = (uintptr_t)indices[0]; - max_index_ptr = 0; - for (i = 0; i < primcount; i++) { - min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]); - max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] + - index_type_size * count[i]); - } - - /* Check if we can handle this thing as a bunch of index offsets from the - * same index pointer. If we can't, then we have to fall back to doing - * a draw_prims per primitive. - * Check that the difference between each prim's indexes is a multiple of - * the index/element size. - */ - if (index_type_size != 1) { - for (i = 0; i < primcount; i++) { - if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) { - fallback = GL_TRUE; - break; - } - } - } - - /* If the index buffer isn't in a VBO, then treating the application's - * subranges of the index buffer as one large index buffer may lead to - * us reading unmapped memory. - */ - if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) - fallback = GL_TRUE; - - if (!fallback) { - ib.count = (max_index_ptr - min_index_ptr) / index_type_size; - ib.type = type; - ib.obj = ctx->Array.ElementArrayBufferObj; - ib.ptr = (void *)min_index_ptr; - - for (i = 0; i < primcount; i++) { - prim[i].begin = (i == 0); - prim[i].end = (i == primcount - 1); - prim[i].weak = 0; - prim[i].pad = 0; - prim[i].mode = mode; - prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size; - prim[i].count = count[i]; - prim[i].indexed = 1; - prim[i].num_instances = 1; - if (basevertex != NULL) - prim[i].basevertex = basevertex[i]; - else - prim[i].basevertex = 0; - } - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib, - GL_FALSE, ~0, ~0); - } else { - /* render one prim at a time */ - for (i = 0; i < primcount; i++) { - ib.count = count[i]; - ib.type = type; - ib.obj = ctx->Array.ElementArrayBufferObj; - ib.ptr = indices[i]; - - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count[i]; - prim[0].indexed = 1; - prim[0].num_instances = 1; - if (basevertex != NULL) - prim[0].basevertex = basevertex[i]; - else - prim[0].basevertex = 0; - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib, - GL_FALSE, ~0, ~0); - } - } - - free(prim); -} - - -static void GLAPIENTRY -vbo_exec_MultiDrawElements(GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, - GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < primcount; i++) { - if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i], - 0)) - return; - } - - vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount, - NULL); -} - - -static void GLAPIENTRY -vbo_exec_MultiDrawElementsBaseVertex(GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLsizei *basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < primcount; i++) { - if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i], - basevertex[i])) - return; - } - - vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount, - basevertex); -} - - -/** - * Plug in the immediate-mode vertex array drawing commands into the - * givven vbo_exec_context object. - */ -void -vbo_exec_array_init( struct vbo_exec_context *exec ) -{ - exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; - exec->vtxfmt.DrawElements = vbo_exec_DrawElements; - exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements; - exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements; - exec->vtxfmt.DrawElementsBaseVertex = vbo_exec_DrawElementsBaseVertex; - exec->vtxfmt.DrawRangeElementsBaseVertex = vbo_exec_DrawRangeElementsBaseVertex; - exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex; - exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced; - exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced; -} - - -void -vbo_exec_array_destroy( struct vbo_exec_context *exec ) -{ - /* nothing to do */ -} - - - -/** - * The following functions are only used for OpenGL ES 1/2 support. - * And some aren't even supported (yet) in ES 1/2. - */ - - -void GLAPIENTRY -_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count) -{ - vbo_exec_DrawArrays(mode, first, count); -} - - -void GLAPIENTRY -_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - vbo_exec_DrawElements(mode, count, type, indices); -} - - -void GLAPIENTRY -_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - vbo_exec_DrawElementsBaseVertex(mode, count, type, indices, basevertex); -} - - -void GLAPIENTRY -_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, - GLenum type, const GLvoid *indices) -{ - vbo_exec_DrawRangeElements(mode, start, end, count, type, indices); -} - - -void GLAPIENTRY -_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type, - indices, basevertex); -} - - -void GLAPIENTRY -_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - vbo_exec_MultiDrawElements(mode, count, type, indices, primcount); -} - - -void GLAPIENTRY -_mesa_MultiDrawElementsBaseVertex(GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount, - const GLint *basevertex) -{ - vbo_exec_MultiDrawElementsBaseVertex(mode, count, type, indices, - primcount, basevertex); -} +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "main/glheader.h" +#include "main/context.h" +#include "main/state.h" +#include "main/api_validate.h" +#include "main/varray.h" +#include "main/bufferobj.h" +#include "main/enums.h" +#include "main/macros.h" + +#include "vbo_context.h" + + +/** + * All vertex buffers should be in an unmapped state when we're about + * to draw. This debug function checks that. + */ +static void +check_buffers_are_unmapped(const struct gl_client_array **inputs) +{ +#ifdef DEBUG + GLuint i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) { + if (inputs[i]) { + struct gl_buffer_object *obj = inputs[i]->BufferObj; + assert(!_mesa_bufferobj_mapped(obj)); + } + } +#endif +} + + +/** + * A debug function that may be called from other parts of Mesa as + * needed during debugging. + */ +void +vbo_check_buffers_are_unmapped(struct gl_context *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + /* check the current vertex arrays */ + check_buffers_are_unmapped(exec->array.inputs); + /* check the current glBegin/glVertex/glEnd-style VBO */ + assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj)); +} + + + +/** + * Compute min and max elements by scanning the index buffer for + * glDraw[Range]Elements() calls. + * If primitive restart is enabled, we need to ignore restart + * indexes when computing min/max. + */ +void +vbo_get_minmax_index(struct gl_context *ctx, + const struct _mesa_prim *prim, + const struct _mesa_index_buffer *ib, + GLuint *min_index, GLuint *max_index) +{ + const GLboolean restart = ctx->Array.PrimitiveRestart; + const GLuint restartIndex = ctx->Array.RestartIndex; + const GLuint count = prim->count; + const void *indices; + GLuint i; + + if (_mesa_is_bufferobj(ib->obj)) { + const GLvoid *map = + ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, ib->obj); + indices = ADD_POINTERS(map, ib->ptr); + } else { + indices = ib->ptr; + } + + switch (ib->type) { + case GL_UNSIGNED_INT: { + const GLuint *ui_indices = (const GLuint *)indices; + GLuint max_ui = 0; + GLuint min_ui = ~0U; + if (restart) { + for (i = 0; i < count; i++) { + if (ui_indices[i] != restartIndex) { + if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; + if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; + } + } + } + else { + for (i = 0; i < count; i++) { + if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; + if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; + } + } + *min_index = min_ui; + *max_index = max_ui; + break; + } + case GL_UNSIGNED_SHORT: { + const GLushort *us_indices = (const GLushort *)indices; + GLuint max_us = 0; + GLuint min_us = ~0U; + if (restart) { + for (i = 0; i < count; i++) { + if (us_indices[i] != restartIndex) { + if (us_indices[i] > max_us) max_us = us_indices[i]; + if (us_indices[i] < min_us) min_us = us_indices[i]; + } + } + } + else { + for (i = 0; i < count; i++) { + if (us_indices[i] > max_us) max_us = us_indices[i]; + if (us_indices[i] < min_us) min_us = us_indices[i]; + } + } + *min_index = min_us; + *max_index = max_us; + break; + } + case GL_UNSIGNED_BYTE: { + const GLubyte *ub_indices = (const GLubyte *)indices; + GLuint max_ub = 0; + GLuint min_ub = ~0U; + if (restart) { + for (i = 0; i < count; i++) { + if (ub_indices[i] != restartIndex) { + if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; + if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; + } + } + } + else { + for (i = 0; i < count; i++) { + if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; + if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; + } + } + *min_index = min_ub; + *max_index = max_ub; + break; + } + default: + assert(0); + break; + } + + if (_mesa_is_bufferobj(ib->obj)) { + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ib->obj); + } +} + + +/** + * Check that element 'j' of the array has reasonable data. + * Map VBO if needed. + * For debugging purposes; not normally used. + */ +static void +check_array_data(struct gl_context *ctx, struct gl_client_array *array, + GLuint attrib, GLuint j) +{ + if (array->Enabled) { + const void *data = array->Ptr; + if (_mesa_is_bufferobj(array->BufferObj)) { + if (!array->BufferObj->Pointer) { + /* need to map now */ + array->BufferObj->Pointer = + ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, + GL_READ_ONLY, array->BufferObj); + } + data = ADD_POINTERS(data, array->BufferObj->Pointer); + } + switch (array->Type) { + case GL_FLOAT: + { + GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j); + GLint k; + for (k = 0; k < array->Size; k++) { + if (IS_INF_OR_NAN(f[k]) || + f[k] >= 1.0e20 || f[k] <= -1.0e10) { + printf("Bad array data:\n"); + printf(" Element[%u].%u = %f\n", j, k, f[k]); + printf(" Array %u at %p\n", attrib, (void* ) array); + printf(" Type 0x%x, Size %d, Stride %d\n", + array->Type, array->Size, array->Stride); + printf(" Address/offset %p in Buffer Object %u\n", + array->Ptr, array->BufferObj->Name); + f[k] = 1.0; /* XXX replace the bad value! */ + } + /*assert(!IS_INF_OR_NAN(f[k]));*/ + } + } + break; + default: + ; + } + } +} + + +/** + * Unmap the buffer object referenced by given array, if mapped. + */ +static void +unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array) +{ + if (array->Enabled && + _mesa_is_bufferobj(array->BufferObj) && + _mesa_bufferobj_mapped(array->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, array->BufferObj); + } +} + + +/** + * Examine the array's data for NaNs, etc. + * For debug purposes; not normally used. + */ +static void +check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, + const void *elements, GLint basevertex) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + const void *elemMap; + GLint i, k; + + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { + elemMap = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, + ctx->Array.ElementArrayBufferObj); + elements = ADD_POINTERS(elements, elemMap); + } + + for (i = 0; i < count; i++) { + GLuint j; + + /* j = element[i] */ + switch (elemType) { + case GL_UNSIGNED_BYTE: + j = ((const GLubyte *) elements)[i]; + break; + case GL_UNSIGNED_SHORT: + j = ((const GLushort *) elements)[i]; + break; + case GL_UNSIGNED_INT: + j = ((const GLuint *) elements)[i]; + break; + default: + assert(0); + } + + /* check element j of each enabled array */ + check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j); + check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j); + check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j); + check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j); + for (k = 0; k < Elements(arrayObj->TexCoord); k++) { + check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j); + } + for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) { + check_array_data(ctx, &arrayObj->VertexAttrib[k], + VERT_ATTRIB_GENERIC0 + k, j); + } + } + + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + } + + unmap_array_buffer(ctx, &arrayObj->Vertex); + unmap_array_buffer(ctx, &arrayObj->Normal); + unmap_array_buffer(ctx, &arrayObj->Color); + for (k = 0; k < Elements(arrayObj->TexCoord); k++) { + unmap_array_buffer(ctx, &arrayObj->TexCoord[k]); + } + for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) { + unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]); + } +} + + +/** + * Check array data, looking for NaNs, etc. + */ +static void +check_draw_arrays_data(struct gl_context *ctx, GLint start, GLsizei count) +{ + /* TO DO */ +} + + +/** + * Print info/data for glDrawArrays(), for debugging. + */ +static void +print_draw_arrays(struct gl_context *ctx, + GLenum mode, GLint start, GLsizei count) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + int i; + + printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", + mode, start, count); + + for (i = 0; i < 32; i++) { + GLuint bufName = exec->array.inputs[i]->BufferObj->Name; + GLint stride = exec->array.inputs[i]->Stride; + printf("attr %2d: size %d stride %d enabled %d " + "ptr %p Bufobj %u\n", + i, + exec->array.inputs[i]->Size, + stride, + /*exec->array.inputs[i]->Enabled,*/ + exec->array.legacy_array[i]->Enabled, + exec->array.inputs[i]->Ptr, + bufName); + + if (bufName) { + struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName); + GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, + GL_READ_ONLY_ARB, buf); + int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr; + float *f = (float *) (p + offset); + int *k = (int *) f; + int i; + int n = (count * stride) / 4; + if (n > 32) + n = 32; + printf(" Data at offset %d:\n", offset); + for (i = 0; i < n; i++) { + printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); + } + ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf); + } + } +} + + +/** + * Bind the VBO executor to the current vertex array object prior + * to drawing. + * + * Just translate the arrayobj into a sane layout. + */ +static void +bind_array_obj(struct gl_context *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint i; + + /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array + * rather than as individual named arrays. Then this function can + * go away. + */ + exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex; + exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight; + exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal; + exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color; + exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor; + exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord; + exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index; + if (arrayObj->PointSize.Enabled) { + /* this aliases COLOR_INDEX */ + exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize; + } + exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag; + + for (i = 0; i < Elements(arrayObj->TexCoord); i++) + exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i]; + + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { + assert(i < Elements(exec->array.generic_array)); + exec->array.generic_array[i] = &arrayObj->VertexAttrib[i]; + } + + exec->array.array_obj = arrayObj->Name; +} + + +/** + * Set the vbo->exec->inputs[] pointers to point to the enabled + * vertex arrays. This depends on the current vertex program/shader + * being executed because of whether or not generic vertex arrays + * alias the conventional vertex arrays. + * For arrays that aren't enabled, we set the input[attrib] pointer + * to point at a zero-stride current value "array". + */ +static void +recalculate_input_bindings(struct gl_context *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + const struct gl_client_array **inputs = &exec->array.inputs[0]; + GLbitfield const_inputs = 0x0; + GLuint i; + + exec->array.program_mode = get_program_mode(ctx); + exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled; + + switch (exec->array.program_mode) { + case VP_NONE: + /* When no vertex program is active (or the vertex program is generated + * from fixed-function state). We put the material values into the + * generic slots. This is the only situation where material values + * are available as per-vertex attributes. + */ + for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else { + inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } + } + + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); + } + + /* Could use just about anything, just to fill in the empty + * slots: + */ + for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) { + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); + } + break; + + case VP_NV: + /* NV_vertex_program - attribute arrays alias and override + * conventional, legacy arrays. No materials, and the generic + * slots are vacant. + */ + for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.generic_array[i]->Enabled) + inputs[i] = exec->array.generic_array[i]; + else if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else { + inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } + } + + /* Could use just about anything, just to fill in the empty + * slots: + */ + for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { + inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; + const_inputs |= 1 << i; + } + break; + + case VP_ARB: + /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0] + * attribute array aliases and overrides the legacy position array. + * + * Otherwise, legacy attributes available in the legacy slots, + * generic attributes in the generic slots and materials are not + * available as per-vertex attributes. + */ + if (exec->array.generic_array[0]->Enabled) + inputs[0] = exec->array.generic_array[0]; + else if (exec->array.legacy_array[0]->Enabled) + inputs[0] = exec->array.legacy_array[0]; + else { + inputs[0] = &vbo->legacy_currval[0]; + const_inputs |= 1 << 0; + } + + for (i = 1; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else { + inputs[i] = &vbo->legacy_currval[i]; + const_inputs |= 1 << i; + } + } + + for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { + if (exec->array.generic_array[i]->Enabled) + inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; + else { + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; + const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i); + } + + } + break; + } + + _mesa_set_varying_vp_inputs( ctx, ~const_inputs ); +} + + +/** + * Examine the enabled vertex arrays to set the exec->array.inputs[] values. + * These will point to the arrays to actually use for drawing. Some will + * be user-provided arrays, other will be zero-stride const-valued arrays. + * Note that this might set the _NEW_ARRAY dirty flag so state validation + * must be done after this call. + */ +static void +bind_arrays(struct gl_context *ctx) +{ + if (!ctx->Array.RebindArrays) { + return; + } + + bind_array_obj(ctx); + recalculate_input_bindings(ctx); + ctx->Array.RebindArrays = GL_FALSE; +} + + +/** + * Helper function called by the other DrawArrays() functions below. + * This is where we handle primitive restart for drawing non-indexed + * arrays. If primitive restart is enabled, it typically means + * splitting one DrawArrays() into two. + */ +static void +vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, + GLsizei count, GLuint numInstances) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct _mesa_prim prim[2]; + + bind_arrays(ctx); + + /* Again... because we may have changed the bitmask of per-vertex varying + * attributes. If we regenerate the fixed-function vertex program now + * we may be able to prune down the number of vertex attributes which we + * need in the shader. + */ + if (ctx->NewState) + _mesa_update_state(ctx); + + prim[0].begin = 1; + prim[0].end = 1; + prim[0].weak = 0; + prim[0].pad = 0; + prim[0].mode = mode; + prim[0].start = 0; /* filled in below */ + prim[0].count = 0; /* filled in below */ + prim[0].indexed = 0; + prim[0].basevertex = 0; + prim[0].num_instances = numInstances; + + /* Implement the primitive restart index */ + if (ctx->Array.PrimitiveRestart && ctx->Array.RestartIndex < count) { + GLuint primCount = 0; + + if (ctx->Array.RestartIndex == start) { + /* special case: RestartIndex at beginning */ + if (count > 1) { + prim[0].start = start + 1; + prim[0].count = count - 1; + primCount = 1; + } + } + else if (ctx->Array.RestartIndex == start + count - 1) { + /* special case: RestartIndex at end */ + if (count > 1) { + prim[0].start = start; + prim[0].count = count - 1; + primCount = 1; + } + } + else { + /* general case: RestartIndex in middle, split into two prims */ + prim[0].start = start; + prim[0].count = ctx->Array.RestartIndex - start; + + prim[1] = prim[0]; + prim[1].start = ctx->Array.RestartIndex + 1; + prim[1].count = count - prim[1].start; + + primCount = 2; + } + + if (primCount > 0) { + /* draw one or two prims */ + check_buffers_are_unmapped(exec->array.inputs); + vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL, + GL_TRUE, start, start + count - 1); + } + } + else { + /* no prim restart */ + prim[0].start = start; + prim[0].count = count; + + check_buffers_are_unmapped(exec->array.inputs); + vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL, + GL_TRUE, start, start + count - 1); + } +} + + + +/** + * Called from glDrawArrays when in immediate mode (not display list mode). + */ +static void GLAPIENTRY +vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n", + _mesa_lookup_enum_by_nr(mode), start, count); + + if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) + return; + + FLUSH_CURRENT( ctx, 0 ); + + if (!_mesa_valid_to_render(ctx, "glDrawArrays")) { + return; + } + + if (0) + check_draw_arrays_data(ctx, start, count); + + vbo_draw_arrays(ctx, mode, start, count, 1); + + if (0) + print_draw_arrays(ctx, mode, start, count); +} + + +/** + * Called from glDrawArraysInstanced when in immediate mode (not + * display list mode). + */ +static void GLAPIENTRY +vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count, + GLsizei numInstances) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n", + _mesa_lookup_enum_by_nr(mode), start, count, numInstances); + + if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances)) + return; + + FLUSH_CURRENT( ctx, 0 ); + + if (!_mesa_valid_to_render(ctx, "glDrawArraysInstanced")) { + return; + } + + if (0) + check_draw_arrays_data(ctx, start, count); + + vbo_draw_arrays(ctx, mode, start, count, numInstances); + + if (0) + print_draw_arrays(ctx, mode, start, count); +} + + +/** + * Map GL_ELEMENT_ARRAY_BUFFER and print contents. + * For debugging. + */ +static void +dump_element_buffer(struct gl_context *ctx, GLenum type) +{ + const GLvoid *map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, + ctx->Array.ElementArrayBufferObj); + switch (type) { + case GL_UNSIGNED_BYTE: + { + const GLubyte *us = (const GLubyte *) map; + GLint i; + for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) { + printf("%02x ", us[i]); + if (i % 32 == 31) + printf("\n"); + } + printf("\n"); + } + break; + case GL_UNSIGNED_SHORT: + { + const GLushort *us = (const GLushort *) map; + GLint i; + for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) { + printf("%04x ", us[i]); + if (i % 16 == 15) + printf("\n"); + } + printf("\n"); + } + break; + case GL_UNSIGNED_INT: + { + const GLuint *us = (const GLuint *) map; + GLint i; + for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) { + printf("%08x ", us[i]); + if (i % 8 == 7) + printf("\n"); + } + printf("\n"); + } + break; + default: + ; + } + + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); +} + + +/** + * Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements. + * Do the rendering for a glDrawElements or glDrawRangeElements call after + * we've validated buffer bounds, etc. + */ +static void +vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, + GLboolean index_bounds_valid, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, + GLint basevertex, GLint numInstances) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct _mesa_index_buffer ib; + struct _mesa_prim prim[1]; + + FLUSH_CURRENT( ctx, 0 ); + + if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) { + return; + } + + bind_arrays( ctx ); + + /* check for dirty state again */ + if (ctx->NewState) + _mesa_update_state( ctx ); + + ib.count = count; + ib.type = type; + ib.obj = ctx->Array.ElementArrayBufferObj; + ib.ptr = indices; + + prim[0].begin = 1; + prim[0].end = 1; + prim[0].weak = 0; + prim[0].pad = 0; + prim[0].mode = mode; + prim[0].start = 0; + prim[0].count = count; + prim[0].indexed = 1; + prim[0].basevertex = basevertex; + prim[0].num_instances = numInstances; + + /* Need to give special consideration to rendering a range of + * indices starting somewhere above zero. Typically the + * application is issuing multiple DrawRangeElements() to draw + * successive primitives layed out linearly in the vertex arrays. + * Unless the vertex arrays are all in a VBO (or locked as with + * CVA), the OpenGL semantics imply that we need to re-read or + * re-upload the vertex data on each draw call. + * + * In the case of hardware tnl, we want to avoid starting the + * upload at zero, as it will mean every draw call uploads an + * increasing amount of not-used vertex data. Worse - in the + * software tnl module, all those vertices might be transformed and + * lit but never rendered. + * + * If we just upload or transform the vertices in start..end, + * however, the indices will be incorrect. + * + * At this level, we don't know exactly what the requirements of + * the backend are going to be, though it will likely boil down to + * either: + * + * 1) Do nothing, everything is in a VBO and is processed once + * only. + * + * 2) Adjust the indices and vertex arrays so that start becomes + * zero. + * + * Rather than doing anything here, I'll provide a helper function + * for the latter case elsewhere. + */ + + check_buffers_are_unmapped(exec->array.inputs); + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, + index_bounds_valid, start, end ); +} + + +/** + * Called by glDrawRangeElementsBaseVertex() in immediate mode. + */ +static void GLAPIENTRY +vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, + GLint basevertex) +{ + static GLuint warnCount = 0; + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, + "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n", + _mesa_lookup_enum_by_nr(mode), start, end, count, + _mesa_lookup_enum_by_nr(type), indices, basevertex); + + if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, + type, indices, basevertex )) + return; + + /* NOTE: It's important that 'end' is a reasonable value. + * in _tnl_draw_prims(), we use end to determine how many vertices + * to transform. If it's too large, we can unnecessarily split prims + * or we can read/write out of memory in several different places! + */ + + /* Catch/fix some potential user errors */ + if (type == GL_UNSIGNED_BYTE) { + start = MIN2(start, 0xff); + end = MIN2(end, 0xff); + } + else if (type == GL_UNSIGNED_SHORT) { + start = MIN2(start, 0xffff); + end = MIN2(end, 0xffff); + } + + if (end >= ctx->Array.ArrayObj->_MaxElement) { + /* the max element is out of bounds of one or more enabled arrays */ + warnCount++; + + if (warnCount < 10) { + _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, " + "type 0x%x, indices=%p)\n" + "\tend is out of bounds (max=%u) " + "Element Buffer %u (size %d)\n" + "\tThis should probably be fixed in the application.", + start, end, count, type, indices, + ctx->Array.ArrayObj->_MaxElement - 1, + ctx->Array.ElementArrayBufferObj->Name, + (int) ctx->Array.ElementArrayBufferObj->Size); + } + + if (0) + dump_element_buffer(ctx, type); + + if (0) + _mesa_print_arrays(ctx); + +#ifdef DEBUG + /* 'end' was out of bounds, but now let's check the actual array + * indexes to see if any of them are out of bounds. + */ + { + GLuint max = _mesa_max_buffer_index(ctx, count, type, indices, + ctx->Array.ElementArrayBufferObj); + if (max >= ctx->Array.ArrayObj->_MaxElement) { + if (warnCount < 10) { + _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, " + "count %d, type 0x%x, indices=%p)\n" + "\tindex=%u is out of bounds (max=%u) " + "Element Buffer %u (size %d)\n" + "\tSkipping the glDrawRangeElements() call", + start, end, count, type, indices, max, + ctx->Array.ArrayObj->_MaxElement - 1, + ctx->Array.ElementArrayBufferObj->Name, + (int) ctx->Array.ElementArrayBufferObj->Size); + } + } + /* XXX we could also find the min index and compare to 'start' + * to see if start is correct. But it's more likely to get the + * upper bound wrong. + */ + } +#endif + + /* Set 'end' to the max possible legal value */ + assert(ctx->Array.ArrayObj->_MaxElement >= 1); + end = ctx->Array.ArrayObj->_MaxElement - 1; + } + else if (0) { + printf("glDraw[Range]Elements{,BaseVertex}" + "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, " + "base %d\n", + start, end, type, count, + ctx->Array.ElementArrayBufferObj->Name, + basevertex); + } + +#if 0 + check_draw_elements_data(ctx, count, type, indices); +#else + (void) check_draw_elements_data; +#endif + + vbo_validated_drawrangeelements(ctx, mode, GL_TRUE, start, end, + count, type, indices, basevertex, 1); +} + + +/** + * Called by glDrawRangeElements() in immediate mode. + */ +static void GLAPIENTRY +vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, + "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n", + _mesa_lookup_enum_by_nr(mode), start, end, count, + _mesa_lookup_enum_by_nr(type), indices); + + vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type, + indices, 0); +} + + +/** + * Called by glDrawElements() in immediate mode. + */ +static void GLAPIENTRY +vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n", + _mesa_lookup_enum_by_nr(mode), count, + _mesa_lookup_enum_by_nr(type), indices); + + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) + return; + + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, + count, type, indices, 0, 1); +} + + +/** + * Called by glDrawElementsBaseVertex() in immediate mode. + */ +static void GLAPIENTRY +vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n", + _mesa_lookup_enum_by_nr(mode), count, + _mesa_lookup_enum_by_nr(type), indices, basevertex); + + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, + basevertex )) + return; + + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, + count, type, indices, basevertex, 1); +} + + +/** + * Called by glDrawElementsInstanced() in immediate mode. + */ +static void GLAPIENTRY +vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLsizei numInstances) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n", + _mesa_lookup_enum_by_nr(mode), count, + _mesa_lookup_enum_by_nr(type), indices, numInstances); + + if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices, + numInstances)) + return; + + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0, + count, type, indices, 0, numInstances); +} + + +/** + * Inner support for both _mesa_MultiDrawElements() and + * _mesa_MultiDrawRangeElements(). + * This does the actual rendering after we've checked array indexes, etc. + */ +static void +vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount, + const GLint *basevertex) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct _mesa_index_buffer ib; + struct _mesa_prim *prim; + unsigned int index_type_size = 0; + uintptr_t min_index_ptr, max_index_ptr; + GLboolean fallback = GL_FALSE; + int i; + + if (primcount == 0) + return; + + FLUSH_CURRENT( ctx, 0 ); + + if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) { + return; + } + + prim = calloc(1, primcount * sizeof(*prim)); + if (prim == NULL) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); + return; + } + + /* Decide if we can do this all as one set of primitives sharing the + * same index buffer, or if we have to reset the index pointer per + * primitive. + */ + bind_arrays( ctx ); + + /* check for dirty state again */ + if (ctx->NewState) + _mesa_update_state( ctx ); + + switch (type) { + case GL_UNSIGNED_INT: + index_type_size = 4; + break; + case GL_UNSIGNED_SHORT: + index_type_size = 2; + break; + case GL_UNSIGNED_BYTE: + index_type_size = 1; + break; + default: + assert(0); + } + + min_index_ptr = (uintptr_t)indices[0]; + max_index_ptr = 0; + for (i = 0; i < primcount; i++) { + min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]); + max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] + + index_type_size * count[i]); + } + + /* Check if we can handle this thing as a bunch of index offsets from the + * same index pointer. If we can't, then we have to fall back to doing + * a draw_prims per primitive. + * Check that the difference between each prim's indexes is a multiple of + * the index/element size. + */ + if (index_type_size != 1) { + for (i = 0; i < primcount; i++) { + if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) { + fallback = GL_TRUE; + break; + } + } + } + + /* If the index buffer isn't in a VBO, then treating the application's + * subranges of the index buffer as one large index buffer may lead to + * us reading unmapped memory. + */ + if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) + fallback = GL_TRUE; + + if (!fallback) { + ib.count = (max_index_ptr - min_index_ptr) / index_type_size; + ib.type = type; + ib.obj = ctx->Array.ElementArrayBufferObj; + ib.ptr = (void *)min_index_ptr; + + for (i = 0; i < primcount; i++) { + prim[i].begin = (i == 0); + prim[i].end = (i == primcount - 1); + prim[i].weak = 0; + prim[i].pad = 0; + prim[i].mode = mode; + prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size; + prim[i].count = count[i]; + prim[i].indexed = 1; + prim[i].num_instances = 1; + if (basevertex != NULL) + prim[i].basevertex = basevertex[i]; + else + prim[i].basevertex = 0; + } + + check_buffers_are_unmapped(exec->array.inputs); + vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib, + GL_FALSE, ~0, ~0); + } else { + /* render one prim at a time */ + for (i = 0; i < primcount; i++) { + ib.count = count[i]; + ib.type = type; + ib.obj = ctx->Array.ElementArrayBufferObj; + ib.ptr = indices[i]; + + prim[0].begin = 1; + prim[0].end = 1; + prim[0].weak = 0; + prim[0].pad = 0; + prim[0].mode = mode; + prim[0].start = 0; + prim[0].count = count[i]; + prim[0].indexed = 1; + prim[0].num_instances = 1; + if (basevertex != NULL) + prim[0].basevertex = basevertex[i]; + else + prim[0].basevertex = 0; + + check_buffers_are_unmapped(exec->array.inputs); + vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib, + GL_FALSE, ~0, ~0); + } + } + + free(prim); +} + + +static void GLAPIENTRY +vbo_exec_MultiDrawElements(GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, + GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < primcount; i++) { + if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i], + 0)) + return; + } + + vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount, + NULL); +} + + +static void GLAPIENTRY +vbo_exec_MultiDrawElementsBaseVertex(GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLsizei *basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < primcount; i++) { + if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i], + basevertex[i])) + return; + } + + vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount, + basevertex); +} + + +/** + * Plug in the immediate-mode vertex array drawing commands into the + * givven vbo_exec_context object. + */ +void +vbo_exec_array_init( struct vbo_exec_context *exec ) +{ + exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; + exec->vtxfmt.DrawElements = vbo_exec_DrawElements; + exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements; + exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements; + exec->vtxfmt.DrawElementsBaseVertex = vbo_exec_DrawElementsBaseVertex; + exec->vtxfmt.DrawRangeElementsBaseVertex = vbo_exec_DrawRangeElementsBaseVertex; + exec->vtxfmt.MultiDrawElementsBaseVertex = vbo_exec_MultiDrawElementsBaseVertex; + exec->vtxfmt.DrawArraysInstanced = vbo_exec_DrawArraysInstanced; + exec->vtxfmt.DrawElementsInstanced = vbo_exec_DrawElementsInstanced; +} + + +void +vbo_exec_array_destroy( struct vbo_exec_context *exec ) +{ + /* nothing to do */ +} + + + +/** + * The following functions are only used for OpenGL ES 1/2 support. + * And some aren't even supported (yet) in ES 1/2. + */ + + +void GLAPIENTRY +_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count) +{ + vbo_exec_DrawArrays(mode, first, count); +} + + +void GLAPIENTRY +_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices) +{ + vbo_exec_DrawElements(mode, count, type, indices); +} + + +void GLAPIENTRY +_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + vbo_exec_DrawElementsBaseVertex(mode, count, type, indices, basevertex); +} + + +void GLAPIENTRY +_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, + GLenum type, const GLvoid *indices) +{ + vbo_exec_DrawRangeElements(mode, start, end, count, type, indices); +} + + +void GLAPIENTRY +_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type, + indices, basevertex); +} + + +void GLAPIENTRY +_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount) +{ + vbo_exec_MultiDrawElements(mode, count, type, indices, primcount); +} + + +void GLAPIENTRY +_mesa_MultiDrawElementsBaseVertex(GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount, + const GLint *basevertex) +{ + vbo_exec_MultiDrawElementsBaseVertex(mode, count, type, indices, + primcount, basevertex); +} diff --git a/pixman/Makefile.am b/pixman/Makefile.am index 062c58a89..f479a6632 100644 --- a/pixman/Makefile.am +++ b/pixman/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = pixman test demos +SUBDIRS = pixman demos test pkgconfigdir=$(libdir)/pkgconfig pkgconfig_DATA=pixman-1.pc diff --git a/pixman/RELEASING b/pixman/RELEASING index 0103eaec9..fbe15813d 100644 --- a/pixman/RELEASING +++ b/pixman/RELEASING @@ -1,57 +1,57 @@ -Here are the steps to follow to create a new pixman release: - -1) Ensure that there are no uncommitted changes or unpushed commits, - and that you are up to date with the latest commits in the central - repository. Here are a couple of useful commands: - - git diff (no output) - - git status (should report "nothing to commit") - - git log master...origin (no output; note: *3* dots) - -2) Increment pixman_(major|minor|micro) in configure.ac according to - the directions in that file. Use git commit to record this. - -3) Make sure that new version works, including - - - make distcheck passes - - - the X server still works with the new pixman version - installed - - - the cairo test suite hasn't gained any new failures compared - to last pixman version. - -4) Use "git commit" to record any changes made in step 3. - -5) Generate and publish the tar files by running - - make PREV= GPGKEY= release-publish - - If your freedesktop user name is different from your local one, - then also set the variable USER to your freedesktop user name. - -6) Run - - make release-publish-message - - to generate a draft release announcement. Edit it as appropriate and - send it to - - cairo-announce@cairographics.org - - pixman@lists.freedesktop.org - - xorg-announce@lists.freedesktop.org - -7) Increment pixman_micro to the next larger (odd) number in - configure.ac. Commit this change, and push all commits created - during this process using - - git push - git push --tags - - You must use "--tags" here; otherwise the new tag will not - be pushed out. - +Here are the steps to follow to create a new pixman release: + +1) Ensure that there are no uncommitted changes or unpushed commits, + and that you are up to date with the latest commits in the central + repository. Here are a couple of useful commands: + + git diff (no output) + + git status (should report "nothing to commit") + + git log master...origin (no output; note: *3* dots) + +2) Increment pixman_(major|minor|micro) in configure.ac according to + the directions in that file. + +3) Make sure that new version works, including + + - make distcheck passes + + - the X server still works with the new pixman version + installed + + - the cairo test suite hasn't gained any new failures compared + to last pixman version. + +4) Use "git commit" to record the changes made in step 2 and 3. + +5) Generate and publish the tar files by running + + make PREV= GPGKEY= release-publish + + If your freedesktop user name is different from your local one, + then also set the variable USER to your freedesktop user name. + +6) Run + + make release-publish-message + + to generate a draft release announcement. Edit it as appropriate and + send it to + + cairo-announce@cairographics.org + + pixman@lists.freedesktop.org + + xorg-announce@lists.freedesktop.org + +7) Increment pixman_micro to the next larger (odd) number in + configure.ac. Commit this change, and push all commits created + during this process using + + git push + git push --tags + + You must use "--tags" here; otherwise the new tag will not + be pushed out. + diff --git a/pixman/configure.ac b/pixman/configure.ac index 8d96647f9..db9a883b6 100644 --- a/pixman/configure.ac +++ b/pixman/configure.ac @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 21) -m4_define([pixman_micro], 5) +m4_define([pixman_micro], 7) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) diff --git a/pixman/pixman/Makefile.am b/pixman/pixman/Makefile.am index 2658e40dc..d016e9f25 100644 --- a/pixman/pixman/Makefile.am +++ b/pixman/pixman/Makefile.am @@ -1,127 +1,127 @@ -lib_LTLIBRARIES = libpixman-1.la -libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -no-undefined @PTHREAD_LDFLAGS@ -libpixman_1_la_LIBADD = @PTHREAD_LIBS@ @DEP_LIBS@ -lm -libpixman_1_la_SOURCES = \ - pixman.h \ - pixman-accessor.h \ - pixman-access.c \ - pixman-access-accessors.c \ - pixman-cpu.c \ - pixman-gradient-walker.c \ - pixman-region16.c \ - pixman-region32.c \ - pixman-compiler.h \ - pixman-private.h \ - pixman-image.c \ - pixman-implementation.c \ - pixman-combine32.c \ - pixman-combine32.h \ - pixman-combine64.c \ - pixman-combine64.h \ - pixman-general.c \ - pixman.c \ - pixman-fast-path.c \ - pixman-fast-path.h \ - pixman-solid-fill.c \ - pixman-conical-gradient.c \ - pixman-linear-gradient.c \ - pixman-radial-gradient.c \ - pixman-bits-image.c \ - pixman-utils.c \ - pixman-edge.c \ - pixman-edge-accessors.c \ - pixman-edge-imp.h \ - pixman-trap.c \ - pixman-timer.c \ - pixman-matrix.c - -libpixmanincludedir = $(includedir)/pixman-1 -libpixmaninclude_HEADERS = pixman.h pixman-version.h -noinst_LTLIBRARIES = - -BUILT_SOURCES = pixman-combine32.h pixman-combine32.c pixman-combine64.h pixman-combine64.c - -pixman-combine32.c : pixman-combine.c.template pixman-combine32.h make-combine.pl - $(PERL) $(srcdir)/make-combine.pl 8 < $(srcdir)/pixman-combine.c.template > $@ || ($(RM) $@; exit 1) -pixman-combine32.h : pixman-combine.h.template make-combine.pl - $(PERL) $(srcdir)/make-combine.pl 8 < $(srcdir)/pixman-combine.h.template > $@ || ($(RM) $@; exit 1) - -pixman-combine64.c : pixman-combine.c.template pixman-combine64.h make-combine.pl - $(PERL) $(srcdir)/make-combine.pl 16 < $(srcdir)/pixman-combine.c.template > $@ || ($(RM) $@; exit 1) -pixman-combine64.h : pixman-combine.h.template make-combine.pl - $(PERL) $(srcdir)/make-combine.pl 16 < $(srcdir)/pixman-combine.h.template > $@ || ($(RM) $@; exit 1) - -EXTRA_DIST = Makefile.win32 pixman-combine.c.template make-combine.pl pixman-region.c \ - pixman-combine.h.template solaris-hwcap.mapfile pixman-x64-mmx-emulation.h -CLEANFILES = pixman-combine32.c pixman-combine64.c pixman-combine32.h pixman-combine64.h - -# mmx code -if USE_MMX -noinst_LTLIBRARIES += libpixman-mmx.la -libpixman_mmx_la_SOURCES = \ - pixman-mmx.c -libpixman_mmx_la_CFLAGS = $(DEP_CFLAGS) $(MMX_CFLAGS) -libpixman_mmx_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LDFLAGS += $(MMX_LDFLAGS) -libpixman_1_la_LIBADD += libpixman-mmx.la - -ASM_CFLAGS_mmx=$(MMX_CFLAGS) -endif - -# vmx code -if USE_VMX -noinst_LTLIBRARIES += libpixman-vmx.la -libpixman_vmx_la_SOURCES = \ - pixman-vmx.c \ - pixman-combine32.h -libpixman_vmx_la_CFLAGS = $(DEP_CFLAGS) $(VMX_CFLAGS) -libpixman_vmx_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LIBADD += libpixman-vmx.la - -ASM_CFLAGS_vmx=$(VMX_CFLAGS) -endif - -# sse2 code -if USE_SSE2 -noinst_LTLIBRARIES += libpixman-sse2.la -libpixman_sse2_la_SOURCES = \ - pixman-sse2.c -libpixman_sse2_la_CFLAGS = $(DEP_CFLAGS) $(SSE2_CFLAGS) -libpixman_sse2_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LDFLAGS += $(SSE2_LDFLAGS) -libpixman_1_la_LIBADD += libpixman-sse2.la - -ASM_CFLAGS_sse2=$(SSE2_CFLAGS) -endif - -# arm simd code -if USE_ARM_SIMD -noinst_LTLIBRARIES += libpixman-arm-simd.la -libpixman_arm_simd_la_SOURCES = \ - pixman-arm-simd.c \ - pixman-arm-common.h \ - pixman-arm-simd-asm.S -libpixman_arm_simd_la_CFLAGS = $(DEP_CFLAGS) -libpixman_arm_simd_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LIBADD += libpixman-arm-simd.la - -ASM_CFLAGS_arm_simd= -endif - -# arm neon code -if USE_ARM_NEON -noinst_LTLIBRARIES += libpixman-arm-neon.la -libpixman_arm_neon_la_SOURCES = \ - pixman-arm-neon.c \ - pixman-arm-common.h \ - pixman-arm-neon-asm.S \ - pixman-arm-neon-asm.h -libpixman_arm_neon_la_CFLAGS = $(DEP_CFLAGS) -libpixman_arm_neon_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LIBADD += libpixman-arm-neon.la - -ASM_CFLAGS_arm_neon= -endif - -.c.s : $(libpixmaninclude_HEADERS) $(BUILT_SOURCES) - $(CC) $(CFLAGS) $(ASM_CFLAGS_$(@:pixman-%.s=%)) $(ASM_CFLAGS_$(@:pixman-arm-%.s=arm_%)) -DHAVE_CONFIG_H -I$(srcdir) -I$(builddir) -I$(top_builddir) -S -o $@ $< +lib_LTLIBRARIES = libpixman-1.la +libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -no-undefined @PTHREAD_LDFLAGS@ +libpixman_1_la_LIBADD = @PTHREAD_LIBS@ @DEP_LIBS@ -lm +libpixman_1_la_SOURCES = \ + pixman.h \ + pixman-accessor.h \ + pixman-access.c \ + pixman-access-accessors.c \ + pixman-cpu.c \ + pixman-gradient-walker.c \ + pixman-region16.c \ + pixman-region32.c \ + pixman-compiler.h \ + pixman-private.h \ + pixman-image.c \ + pixman-implementation.c \ + pixman-combine32.c \ + pixman-combine32.h \ + pixman-combine64.c \ + pixman-combine64.h \ + pixman-general.c \ + pixman.c \ + pixman-fast-path.c \ + pixman-fast-path.h \ + pixman-solid-fill.c \ + pixman-conical-gradient.c \ + pixman-linear-gradient.c \ + pixman-radial-gradient.c \ + pixman-bits-image.c \ + pixman-utils.c \ + pixman-edge.c \ + pixman-edge-accessors.c \ + pixman-edge-imp.h \ + pixman-trap.c \ + pixman-timer.c \ + pixman-matrix.c + +libpixmanincludedir = $(includedir)/pixman-1 +libpixmaninclude_HEADERS = pixman.h pixman-version.h +noinst_LTLIBRARIES = + +BUILT_SOURCES = pixman-combine32.h pixman-combine32.c pixman-combine64.h pixman-combine64.c + +pixman-combine32.c : pixman-combine.c.template pixman-combine32.h make-combine.pl + $(PERL) $(srcdir)/make-combine.pl 8 < $(srcdir)/pixman-combine.c.template > $@ || ($(RM) $@; exit 1) +pixman-combine32.h : pixman-combine.h.template make-combine.pl + $(PERL) $(srcdir)/make-combine.pl 8 < $(srcdir)/pixman-combine.h.template > $@ || ($(RM) $@; exit 1) + +pixman-combine64.c : pixman-combine.c.template pixman-combine64.h make-combine.pl + $(PERL) $(srcdir)/make-combine.pl 16 < $(srcdir)/pixman-combine.c.template > $@ || ($(RM) $@; exit 1) +pixman-combine64.h : pixman-combine.h.template make-combine.pl + $(PERL) $(srcdir)/make-combine.pl 16 < $(srcdir)/pixman-combine.h.template > $@ || ($(RM) $@; exit 1) + +EXTRA_DIST = Makefile.win32 pixman-combine.c.template make-combine.pl pixman-region.c \ + pixman-combine.h.template solaris-hwcap.mapfile +CLEANFILES = pixman-combine32.c pixman-combine64.c pixman-combine32.h pixman-combine64.h + +# mmx code +if USE_MMX +noinst_LTLIBRARIES += libpixman-mmx.la +libpixman_mmx_la_SOURCES = \ + pixman-mmx.c +libpixman_mmx_la_CFLAGS = $(DEP_CFLAGS) $(MMX_CFLAGS) +libpixman_mmx_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LDFLAGS += $(MMX_LDFLAGS) +libpixman_1_la_LIBADD += libpixman-mmx.la + +ASM_CFLAGS_mmx=$(MMX_CFLAGS) +endif + +# vmx code +if USE_VMX +noinst_LTLIBRARIES += libpixman-vmx.la +libpixman_vmx_la_SOURCES = \ + pixman-vmx.c \ + pixman-combine32.h +libpixman_vmx_la_CFLAGS = $(DEP_CFLAGS) $(VMX_CFLAGS) +libpixman_vmx_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-vmx.la + +ASM_CFLAGS_vmx=$(VMX_CFLAGS) +endif + +# sse2 code +if USE_SSE2 +noinst_LTLIBRARIES += libpixman-sse2.la +libpixman_sse2_la_SOURCES = \ + pixman-sse2.c +libpixman_sse2_la_CFLAGS = $(DEP_CFLAGS) $(SSE2_CFLAGS) +libpixman_sse2_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LDFLAGS += $(SSE2_LDFLAGS) +libpixman_1_la_LIBADD += libpixman-sse2.la + +ASM_CFLAGS_sse2=$(SSE2_CFLAGS) +endif + +# arm simd code +if USE_ARM_SIMD +noinst_LTLIBRARIES += libpixman-arm-simd.la +libpixman_arm_simd_la_SOURCES = \ + pixman-arm-simd.c \ + pixman-arm-common.h \ + pixman-arm-simd-asm.S +libpixman_arm_simd_la_CFLAGS = $(DEP_CFLAGS) +libpixman_arm_simd_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-arm-simd.la + +ASM_CFLAGS_arm_simd= +endif + +# arm neon code +if USE_ARM_NEON +noinst_LTLIBRARIES += libpixman-arm-neon.la +libpixman_arm_neon_la_SOURCES = \ + pixman-arm-neon.c \ + pixman-arm-common.h \ + pixman-arm-neon-asm.S \ + pixman-arm-neon-asm.h +libpixman_arm_neon_la_CFLAGS = $(DEP_CFLAGS) +libpixman_arm_neon_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-arm-neon.la + +ASM_CFLAGS_arm_neon= +endif + +.c.s : $(libpixmaninclude_HEADERS) $(BUILT_SOURCES) + $(CC) $(CFLAGS) $(ASM_CFLAGS_$(@:pixman-%.s=%)) $(ASM_CFLAGS_$(@:pixman-arm-%.s=arm_%)) -DHAVE_CONFIG_H -I$(srcdir) -I$(builddir) -I$(top_builddir) -S -o $@ $< diff --git a/pixman/pixman/pixman-x64-mmx-emulation.h b/pixman/pixman/pixman-x64-mmx-emulation.h deleted file mode 100644 index 378019cf2..000000000 --- a/pixman/pixman/pixman-x64-mmx-emulation.h +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef MMX_X64_H_INCLUDED -#define MMX_X64_H_INCLUDED - -/* Implementation of x64 MMX substitition functions, before - * pixman is reimplemented not to use __m64 type on Visual C++ - * - * Copyright (C)2009 by George Yohng - * Released in public domain. - */ - -#include - -#define M64C(a) (*(const __m64 *)(&a)) -#define M64U(a) (*(const unsigned long long *)(&a)) - -__inline __m64 -_m_from_int (int a) -{ - long long i64 = a; - - return M64C (i64); -} - -__inline __m64 -_mm_setzero_si64 () -{ - long long i64 = 0; - - return M64C (i64); -} - -__inline __m64 -_mm_set_pi32 (int i1, int i0) -{ - unsigned long long i64 = ((unsigned)i0) + (((unsigned long long)(unsigned)i1) << 32); - - return M64C (i64); -} - -__inline void -_m_empty () -{ -} - -__inline __m64 -_mm_set1_pi16 (short w) -{ - unsigned long long i64 = ((unsigned long long)(unsigned short)(w)) * 0x0001000100010001ULL; - - return M64C (i64); -} - -__inline int -_m_to_int (__m64 m) -{ - return m.m64_i32[0]; -} - -__inline __m64 -_mm_movepi64_pi64 (__m128i a) -{ - return M64C (a.m128i_i64[0]); -} - -__inline __m64 -_m_pand (__m64 a, __m64 b) -{ - unsigned long long i64 = M64U (a) & M64U (b); - - return M64C (i64); -} - -__inline __m64 -_m_por (__m64 a, __m64 b) -{ - unsigned long long i64 = M64U (a) | M64U (b); - - return M64C (i64); -} - -__inline __m64 -_m_pxor (__m64 a, __m64 b) -{ - unsigned long long i64 = M64U (a) ^ M64U (b); - - return M64C (i64); -} - -__inline __m64 -_m_pmulhuw (__m64 a, __m64 b) /* unoptimized */ -{ - unsigned short d[4] = - { - (unsigned short)((((unsigned)a.m64_u16[0]) * b.m64_u16[0]) >> 16), - (unsigned short)((((unsigned)a.m64_u16[1]) * b.m64_u16[1]) >> 16), - (unsigned short)((((unsigned)a.m64_u16[2]) * b.m64_u16[2]) >> 16), - (unsigned short)((((unsigned)a.m64_u16[3]) * b.m64_u16[3]) >> 16) - }; - - return M64C (d[0]); -} - -__inline __m64 -_m_pmullw2 (__m64 a, __m64 b) /* unoptimized */ -{ - unsigned short d[4] = - { - (unsigned short)((((unsigned)a.m64_u16[0]) * b.m64_u16[0])), - (unsigned short)((((unsigned)a.m64_u16[1]) * b.m64_u16[1])), - (unsigned short)((((unsigned)a.m64_u16[2]) * b.m64_u16[2])), - (unsigned short)((((unsigned)a.m64_u16[3]) * b.m64_u16[3])) - }; - - return M64C (d[0]); -} - -__inline __m64 -_m_pmullw (__m64 a, __m64 b) /* unoptimized */ -{ - unsigned long long x = - ((unsigned long long)(unsigned short)((((unsigned)a.m64_u16[0]) * b.m64_u16[0]))) + - (((unsigned long long)(unsigned short)((((unsigned)a.m64_u16[1]) * b.m64_u16[1]))) << 16) + - (((unsigned long long)(unsigned short)((((unsigned)a.m64_u16[2]) * b.m64_u16[2]))) << 32) + - (((unsigned long long)(unsigned short)((((unsigned)a.m64_u16[3]) * b.m64_u16[3]))) << 48); - - return M64C (x); -} - -__inline __m64 -_m_paddusb (__m64 a, __m64 b) /* unoptimized */ -{ - unsigned long long x = (M64U (a) & 0x00FF00FF00FF00FFULL) + - (M64U (b) & 0x00FF00FF00FF00FFULL); - - unsigned long long y = ((M64U (a) >> 8) & 0x00FF00FF00FF00FFULL) + - ((M64U (b) >> 8) & 0x00FF00FF00FF00FFULL); - - x |= ((x & 0xFF00FF00FF00FF00ULL) >> 8) * 0xFF; - y |= ((y & 0xFF00FF00FF00FF00ULL) >> 8) * 0xFF; - - x = (x & 0x00FF00FF00FF00FFULL) | ((y & 0x00FF00FF00FF00FFULL) << 8); - - return M64C (x); -} - -__inline __m64 -_m_paddusw (__m64 a, __m64 b) /* unoptimized */ -{ - unsigned long long x = (M64U (a) & 0x0000FFFF0000FFFFULL) + - (M64U (b) & 0x0000FFFF0000FFFFULL); - - unsigned long long y = ((M64U (a) >> 16) & 0x0000FFFF0000FFFFULL) + - ((M64U (b) >> 16) & 0x0000FFFF0000FFFFULL); - - x |= ((x & 0xFFFF0000FFFF0000) >> 16) * 0xFFFF; - y |= ((y & 0xFFFF0000FFFF0000) >> 16) * 0xFFFF; - - x = (x & 0x0000FFFF0000FFFFULL) | ((y & 0x0000FFFF0000FFFFULL) << 16); - - return M64C (x); -} - -__inline __m64 -_m_pshufw (__m64 a, int n) /* unoptimized */ -{ - unsigned short d[4] = - { - a.m64_u16[n & 3], - a.m64_u16[(n >> 2) & 3], - a.m64_u16[(n >> 4) & 3], - a.m64_u16[(n >> 6) & 3] - }; - - return M64C (d[0]); -} - -__inline unsigned char -sat16 (unsigned short d) -{ - if (d > 0xFF) return 0xFF; - else return d & 0xFF; -} - -__inline __m64 -_m_packuswb (__m64 m1, __m64 m2) /* unoptimized */ -{ - unsigned char d[8] = - { - sat16 (m1.m64_u16[0]), - sat16 (m1.m64_u16[1]), - sat16 (m1.m64_u16[2]), - sat16 (m1.m64_u16[3]), - sat16 (m2.m64_u16[0]), - sat16 (m2.m64_u16[1]), - sat16 (m2.m64_u16[2]), - sat16 (m2.m64_u16[3]) - }; - - return M64C (d[0]); -} - -__inline __m64 _m_punpcklbw (__m64 m1, __m64 m2) /* unoptimized */ -{ - unsigned char d[8] = - { - m1.m64_u8[0], - m2.m64_u8[0], - m1.m64_u8[1], - m2.m64_u8[1], - m1.m64_u8[2], - m2.m64_u8[2], - m1.m64_u8[3], - m2.m64_u8[3], - }; - - return M64C (d[0]); -} - -__inline __m64 _m_punpckhbw (__m64 m1, __m64 m2) /* unoptimized */ -{ - unsigned char d[8] = - { - m1.m64_u8[4], - m2.m64_u8[4], - m1.m64_u8[5], - m2.m64_u8[5], - m1.m64_u8[6], - m2.m64_u8[6], - m1.m64_u8[7], - m2.m64_u8[7], - }; - - return M64C (d[0]); -} - -__inline __m64 _m_psrlwi (__m64 a, int n) /* unoptimized */ -{ - unsigned short d[4] = - { - a.m64_u16[0] >> n, - a.m64_u16[1] >> n, - a.m64_u16[2] >> n, - a.m64_u16[3] >> n - }; - - return M64C (d[0]); -} - -__inline __m64 _m_psrlqi (__m64 m, int n) -{ - unsigned long long x = M64U (m) >> n; - - return M64C (x); -} - -__inline __m64 _m_psllqi (__m64 m, int n) -{ - unsigned long long x = M64U (m) << n; - - return M64C (x); -} - -#endif /* MMX_X64_H_INCLUDED */ diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index 919ed4b34..3578100ee 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -1,5766 +1,5766 @@ - - - - - - - pc101 - <_description>Generic 101-key PC - Generic - - - - - pc102 - <_description>Generic 102-key (Intl) PC - Generic - - - - - pc104 - <_description>Generic 104-key PC - Generic - - - - - pc105 - <_description>Generic 105-key (Intl) PC - Generic - - - - - dell101 - <_description>Dell 101-key PC - Dell - - - - - latitude - <_description>Dell Latitude series laptop - Dell - - - - - dellm65 - <_description>Dell Precision M65 - Dell - - - - - everex - <_description>Everex STEPnote - Everex - - - - - flexpro - <_description>Keytronic FlexPro - Keytronic - - - - - microsoft - <_description>Microsoft Natural - Microsoft Inc. - - - - - omnikey101 - <_description>Northgate OmniKey 101 - Northgate - - - - - winbook - <_description>Winbook Model XP5 - Generic - - - - - pc98 - <_description>PC-98xx Series - Generic - - - - - a4techKB21 - <_description>A4Tech KB-21 - A4Tech - - - - - a4techKBS8 - <_description>A4Tech KBS-8 - A4Tech - - - - - a4_rfkb23 - <_description>A4Tech Wireless Desktop RFKB-23 - A4Tech - - - - - airkey - <_description>Acer AirKey V - Acer - - - - - azonaRF2300 - <_description>Azona RF2300 wireless Internet Keyboard - Azona - - - - - scorpius - <_description>Advance Scorpius KI - Scorpius - - - - - brother - <_description>Brother Internet Keyboard - Brother - - - - - btc5113rf - <_description>BTC 5113RF Multimedia - BTC - - - - - btc5126t - <_description>BTC 5126T - BTC - - - - - btc6301urf - <_description>BTC 6301URF - BTC - - - - - btc9000 - <_description>BTC 9000 - BTC - - - - - btc9000a - <_description>BTC 9000A - BTC - - - - - btc9001ah - <_description>BTC 9001AH - BTC - - - - - btc5090 - <_description>BTC 5090 - BTC - - - - - btc9019u - <_description>BTC 9019U - BTC - - - - - btc9116u - <_description>BTC 9116U Mini Wireless Internet and Gaming - - - - - cherryblue - <_description>Cherry Blue Line CyBo@rd - - - - - cherryblueb - <_description>Cherry CyMotion Master XPress - Cherry - - - - - cherrybluea - <_description>Cherry Blue Line CyBo@rd (alternate option) - Cherry - - - - - cherrycyboard - <_description>Cherry CyBo@rd USB-Hub - Cherry - - - - - cherrycmexpert - <_description>Cherry CyMotion Expert - Cherry - - - - - cherrybunlim - <_description>Cherry B.UNLIMITED - Cherry - - - - - chicony - <_description>Chicony Internet Keyboard - Chicony - - - - - chicony0108 - <_description>Chicony KU-0108 - Chicony - - - - - chicony0420 - <_description>Chicony KU-0420 - Chicony - - - - - chicony9885 - <_description>Chicony KB-9885 - Chicony - - - - - compaqeak8 - <_description>Compaq Easy Access Keyboard - Compaq - - - - - compaqik7 - <_description>Compaq Internet Keyboard (7 keys) - Compaq - - - - - compaqik13 - <_description>Compaq Internet Keyboard (13 keys) - Compaq - - - - - compaqik18 - <_description>Compaq Internet Keyboard (18 keys) - Compaq - - - - - cymotionlinux - <_description>Cherry CyMotion Master Linux - Cherry - - - - - armada - <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard - Compaq - - - - - presario - <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard - Compaq - - - - - ipaq - <_description>Compaq iPaq Keyboard - Compaq - - - - - dell - <_description>Dell - Dell - - - - - dellsk8125 - <_description>Dell SK-8125 - Dell - - - - - dellsk8135 - <_description>Dell SK-8135 - Dell - - - - - dellusbmm - <_description>Dell USB Multimedia Keyboard - Dell - - - - - inspiron - <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx - Dell - - - - - precision_m - <_description>Dell Laptop/notebook Precision M series - Dell - - - - - dexxa - <_description>Dexxa Wireless Desktop Keyboard - Dexxa - - - - - diamond - <_description>Diamond 9801 / 9802 series - Diamond - - - - - dtk2000 - <_description>DTK2000 - - - - - ennyah_dkb1008 - <_description>Ennyah DKB-1008 - Ennyah - - - - - fscaa1667g - <_description>Fujitsu-Siemens Computers AMILO laptop - Fujitsu-Siemens - - - - - genius - <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910 - Genius - - - - - geniuscomfy - <_description>Genius Comfy KB-12e - Genius - - - - - geniuscomfy2 - <_description>Genius Comfy KB-21e-Scroll - Genius - - - - - geniuskb19e - <_description>Genius KB-19e NB - Genius - - - - - geniuskkb2050hs - <_description>Genius KKB-2050HS - Genius - - - - - gyration - <_description>Gyration - Gyration - - - - - htcdream - <_description>HTC Dream - HTC - - - - - kinesis - <_description>Kinesis - Kinesis - - - - - logitech_base - <_description>Logitech Generic Keyboard - Logitech - - - - - logitech_g15 - <_description>Logitech G15 extra keys via G15daemon - Logitech - - - - - hpi6 - <_description>Hewlett-Packard Internet Keyboard - Hewlett-Packard - - - - - hp250x - <_description>Hewlett-Packard SK-250x Multimedia Keyboard - Hewlett-Packard - - - - - hpxe3gc - <_description>Hewlett-Packard Omnibook XE3 GC - Hewlett-Packard - - - - - hpxe3gf - <_description>Hewlett-Packard Omnibook XE3 GF - Hewlett-Packard - - - - - hpxt1000 - <_description>Hewlett-Packard Omnibook XT1000 - Hewlett-Packard - - - - - hpdv5 - <_description>Hewlett-Packard Pavilion dv5 - Hewlett-Packard - - - - - hpzt11xx - <_description>Hewlett-Packard Pavilion ZT11xx - Hewlett-Packard - - - - - hp500fa - <_description>Hewlett-Packard Omnibook 500 FA - Hewlett-Packard - - - - - hp5xx - <_description>Hewlett-Packard Omnibook 5xx - Hewlett-Packard - - - - - hpnx9020 - <_description>Hewlett-Packard nx9020 - Hewlett-Packard - - - - - hp6000 - <_description>Hewlett-Packard Omnibook 6000/6100 - Hewlett-Packard - - - - - honeywell_euroboard - <_description>Honeywell Euroboard - Hewlett-Packard - - - - - hpmini110 - <_description>Hewlett-Packard Mini 110 Notebook - Hewlett-Packard - - - - - rapidaccess - <_description>IBM Rapid Access - Lenovo (previously IBM) - - - - - rapidaccess2 - <_description>IBM Rapid Access II - Lenovo (previously IBM) - - - - - thinkpad - <_description>IBM ThinkPad 560Z/600/600E/A22E - Lenovo (previously IBM) - - - - - thinkpad60 - <_description>IBM ThinkPad R60/T60/R61/T61 - Lenovo (previously IBM) - - - - - thinkpadz60 - <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t - Lenovo (previously IBM) - - - - - ibm_spacesaver - <_description>IBM Space Saver - Lenovo (previously IBM) - - - - - logiaccess - <_description>Logitech Access Keyboard - Logitech - - - - - logiclx300 - <_description>Logitech Cordless Desktop LX-300 - Logitech - - - - - logii350 - <_description>Logitech Internet 350 Keyboard - Logitech - - - - - logimel - <_description>Logitech Media Elite Keyboard - Logitech - - - - - logicd - <_description>Logitech Cordless Desktop - Logitech - - - - - logicd_it - <_description>Logitech Cordless Desktop iTouch - Logitech - - - - - logicd_nav - <_description>Logitech Cordless Desktop Navigator - Logitech - - - - - logicd_opt - <_description>Logitech Cordless Desktop Optical - Logitech - - - - - logicda - <_description>Logitech Cordless Desktop (alternate option) - Logitech - - - - - logicdpa2 - <_description>Logitech Cordless Desktop Pro (alternate option 2) - Logitech - - - - - logicfn - <_description>Logitech Cordless Freedom/Desktop Navigator - Logitech - - - - - logicdn - <_description>Logitech Cordless Desktop Navigator - Logitech - - - - - logiitc - <_description>Logitech iTouch Cordless Keyboard (model Y-RB6) - Logitech - - - - - logiik - <_description>Logitech Internet Keyboard - Logitech - - - - - itouch - <_description>Logitech iTouch - Logitech - - - - - logicink - <_description>Logitech Internet Navigator Keyboard - Logitech - - - - - logiex110 - <_description>Logitech Cordless Desktop EX110 - Logitech - - - - - logiinkse - <_description>Logitech iTouch Internet Navigator Keyboard SE - Logitech - - - - - logiinkseusb - <_description>Logitech iTouch Internet Navigator Keyboard SE (USB) - Logitech - - - - - logiultrax - <_description>Logitech Ultra-X Keyboard - Logitech - - - - - logiultraxc - <_description>Logitech Ultra-X Cordless Media Desktop Keyboard - Logitech - - - - - logidinovo - <_description>Logitech diNovo Keyboard - Logitech - - - - - logidinovoedge - <_description>Logitech diNovo Edge Keyboard - Logitech - - - - - mx1998 - <_description>Memorex MX1998 - Memorex - - - - - mx2500 - <_description>Memorex MX2500 EZ-Access Keyboard - Memorex - - - - - mx2750 - <_description>Memorex MX2750 - Memorex - - - - - microsoft7000 - <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000 - Microsoft Inc. - - - - - microsoftinet - <_description>Microsoft Internet Keyboard - Microsoft Inc. - - - - - microsoftpro - <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro - Microsoft Inc. - - - - - microsoftprousb - <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro - Microsoft Inc. - - - - - microsoftprooem - <_description>Microsoft Natural Keyboard Pro OEM - Microsoft Inc. - - - - - vsonku306 - <_description>ViewSonic KU-306 Internet Keyboard - ViewSonic - - - - - microsoftprose - <_description>Microsoft Internet Keyboard Pro, Swedish - Microsoft Inc. - - - - - microsoftoffice - <_description>Microsoft Office Keyboard - Microsoft Inc. - - - - - microsoftmult - <_description>Microsoft Wireless Multimedia Keyboard 1.0A - Microsoft Inc. - - - - - microsoftelite - <_description>Microsoft Natural Keyboard Elite - Microsoft Inc. - - - - - microsoftccurve2k - <_description>Microsoft Comfort Curve Keyboard 2000 - Microsoft Inc. - - - - - oretec - <_description>Ortek MCK-800 MM/Internet keyboard - Ortek - - - - - propeller - <_description>Propeller Voyager (KTEZ-1000) - KeyTronic - - - - - qtronix - <_description>QTronix Scorpius 98N+ - QTronix - - - - - samsung4500 - <_description>Samsung SDM 4500P - Samsung - - - - - samsung4510 - <_description>Samsung SDM 4510P - Samsung - - - - - sanwaskbkg3 - Sanwa Supply SKB-KG3 - Sanwa Supply Inc. - - - - - sk1300 - <_description>SK-1300 - NEC - - - - - sk2500 - <_description>SK-2500 - NEC - - - - - sk6200 - <_description>SK-6200 - NEC - - - - - sk7100 - <_description>SK-7100 - NEC - - - - - sp_inet - <_description>Super Power Multimedia Keyboard - Generic - - - - - sven - <_description>SVEN Ergonomic 2500 - SVEN - - - - - sven303 - <_description>SVEN Slim 303 - SVEN - - - - - symplon - <_description>Symplon PaceBook (tablet PC) - Symplon - - - - - toshiba_s3000 - <_description>Toshiba Satellite S3000 - Toshiba - - - - - trust - <_description>Trust Wireless Keyboard Classic - Trust - - - - - trustda - <_description>Trust Direct Access Keyboard - Trust - - - - - trust_slimline - <_description>Trust Slimline - Trust - - - - - tm2020 - <_description>TypeMatrix EZ-Reach 2020 - TypeMatrix - - - - - tm2030PS2 - <_description>TypeMatrix EZ-Reach 2030 PS2 - TypeMatrix - - - - - tm2030USB - <_description>TypeMatrix EZ-Reach 2030 USB - TypeMatrix - - - - - tm2030USB-102 - <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode) - TypeMatrix - - - - - tm2030USB-106 - <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode) - TypeMatrix - - - - - yahoo - <_description>Yahoo! Internet Keyboard - Yahoo! - - - - - macbook78 - <_description>MacBook/MacBook Pro - Apple - - - - - macbook79 - <_description>MacBook/MacBook Pro (Intl) - Apple - - - - - macintosh - <_description>Macintosh - Apple - - - - - macintosh_old - <_description>Macintosh Old - Apple - - - - - macintosh_hhk - <_description>Happy Hacking Keyboard for Mac - Fujitsu - - - - - acer_c300 - <_description>Acer C300 - Acer - - - - - acer_ferrari4k - <_description>Acer Ferrari 4000 - Acer - - - - - acer_laptop - <_description>Acer Laptop - Acer - - - - - asus_laptop - <_description>Asus Laptop - Asus - - - - - apple - <_description>Apple - Apple - - - - - apple_laptop - <_description>Apple Laptop - Apple - - - - - applealu_ansi - <_description>Apple Aluminium Keyboard (ANSI) - Apple - - - - - applealu_iso - <_description>Apple Aluminium Keyboard (ISO) - Apple - - - - - applealu_jis - <_description>Apple Aluminium Keyboard (JIS) - Apple - - - - - silvercrest - <_description>SILVERCREST Multimedia Wireless Keyboard - Silvercrest - - - - - emachines - <_description>Laptop/notebook eMachines m68xx - eMachines - - - - - benqx - <_description>BenQ X-Touch - BenQ - - - - - benqx730 - <_description>BenQ X-Touch 730 - BenQ - - - - - benqx800 - <_description>BenQ X-Touch 800 - BenQ - - - - - hhk - <_description>Happy Hacking Keyboard - Fujitsu - - - - - classmate - <_description>Classmate PC - Intel - - - - - olpc - <_description>OLPC - OLPC - - - - - sun6 - <_description>Sun Type 5/6 - Sun Microsystems - - - - - targa_v811 - <_description>Targa Visionary 811 - Targa - - - - - unitekkb1925 - <_description>Unitek KB-1925 - Unitek Group - - - - - compalfl90 - <_description>FL90 - Compal Electronics Inc. - - - - - creativedw7000 - <_description>Creative Desktop Wireless 7000 - Creative - - - - - htcdream - <_description>Htc Dream phone - htc - - - - - - - us - <_shortDescription>USA - <_description>USA - eng - - - - - chr - <_description>Cherokee - chr - - - - - euro - <_description>With EuroSign on 5 - - - - - intl - <_description>International (with dead keys) - - - - - alt-intl - <_description>Alternative international - - - - - colemak - <_description>Colemak - - - - - dvorak - <_description>Dvorak - - - - - dvorak-intl - <_description>Dvorak international (with dead keys) - - - - - dvorak-alt-intl - <_description>Dvorak alternative international (no dead keys) - - - - - dvorak-l - <_description>Left handed Dvorak - - - - - dvorak-r - <_description>Right handed Dvorak - - - - - dvorak-classic - <_description>Classic Dvorak - - - - - dvp - <_description>Programmer Dvorak - - - - - rus - <_description>Russian phonetic - rus - - - - - mac - <_description>Macintosh - - - - - altgr-intl - <_description>International (AltGr dead keys) - eng - fra - ger - - - - - olpc2 - <_description>Layout toggle on multiply/divide key - - - - - hbs - <_description>Serbo-Croatian - eng - bos - hbs - hrv - srp - - - - - - - ad - <_shortDescription>And - <_description>Andorra - cat - - - - - - af - <_shortDescription>Afg - <_description>Afghanistan - - - - - ps - <_description>Pashto - pus - - - - - uz - <_description>Southern Uzbek - uzb - - - - - olpc-ps - <_description>OLPC Pashto - pus - - - - - olpc-fa - <_description>OLPC Dari - - - - - - olpc-uz - <_description>OLPC Southern Uzbek - uzb - - - - - - - ara - <_shortDescription>Ara - <_description>Arabic - - AE - BH - DZ - EG - EH - JO - KW - LB - LY - MA - MR - OM - PS - QA - SA - SD - SY - TN - YE - - ara - - - - - azerty - <_description>azerty - - - - - azerty_digits - <_description>azerty/digits - - - - - digits - <_description>digits - - - - - qwerty - <_description>qwerty - - - - - qwerty_digits - <_description>qwerty/digits - - - - - buckwalter - <_description>Buckwalter - - - - - - - al - <_shortDescription>Alb - <_description>Albania - alb - - - - - - am - <_shortDescription>Arm - <_description>Armenia - hye - - - - - phonetic - <_description>Phonetic - - - - - phonetic-alt - <_description>Alternative Phonetic - - - - - eastern - <_description>Eastern - - - - - western - <_description>Western - - - - - eastern-alt - <_description>Alternative Eastern - - - - - - - at - <_shortDescription>Aut - <_description>Austria - ger - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - sundeadkeys - <_description>Sun dead keys - - - - - mac - <_description>Macintosh - - - - - - - az - <_shortDescription>Aze - <_description>Azerbaijan - aze - - - - - cyrillic - <_description>Cyrillic - - - - - - - by - <_shortDescription>Blr - <_description>Belarus - bel - - - - - legacy - <_description>Legacy - - - - - latin - <_description>Latin - - - - - - - be - <_shortDescription>Bel - <_description>Belgium - ger - nld - fra - - - - - oss - <_description>Alternative - - - - - oss_latin9 - <_description>Alternative, latin-9 only - - - - - oss_sundeadkeys - <_description>Alternative, Sun dead keys - - - - - iso-alternate - <_description>ISO Alternate - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - sundeadkeys - <_description>Sun dead keys - - - - - wang - <_description>Wang model 724 azerty - - - - - - - bd - <_shortDescription>Bgd - <_description>Bangladesh - ben - - - - - probhat - <_description>Probhat - - - - - - - in - <_shortDescription>Ind - <_description>India - - - - - ben - <_description>Bengali - ben - - - - - ben_probhat - <_description>Bengali Probhat - ben - - - - - guj - <_description>Gujarati - guj - - - - - guru - <_description>Gurmukhi - pan - - - - - jhelum - <_description>Gurmukhi Jhelum - pan - - - - - kan - <_description>Kannada - kan - - - - - mal - <_description>Malayalam - mal - - - - - mal_lalitha - <_description>Malayalam Lalitha - mal - - - - - ori - <_description>Oriya - ori - - - - - tam_unicode - <_description>Tamil Unicode - tam - - - - - tam_keyboard_with_numerals - <_description>Tamil Keyboard with Numerals - tam - - - - - tam_TAB - <_description>Tamil TAB Typewriter - tam - - - - - tam_TSCII - <_description>Tamil TSCII Typewriter - tam - - - - - tam - <_description>Tamil - tam - - - - - tel - <_description>Telugu - tel - - - - - urd-phonetic - <_description>Urdu, Phonetic - urd - - - - - urd-phonetic3 - <_description>Urdu, Alternative phonetic - urd - - - - - urd-winkeys - <_description>Urdu, Winkeys - urd - - - - - bolnagri - <_description>Hindi Bolnagri - hin - - - - - hin-wx - <_description>Hindi Wx - hin - - - - - eng - <_description>English with RupeeSign - eng - - - - - - - ba - <_shortDescription>Bih - <_description>Bosnia and Herzegovina - bos - - - - - alternatequotes - <_description> Use guillemets for quotes - - - - - unicode - <_description>Use Bosnian digraphs - - - - - unicodeus - <_description>US keyboard with Bosnian digraphs - - - - - us - <_description>US keyboard with Bosnian letters - - - - - - - br - <_shortDescription>Bra - <_description>Brazil - por - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - nativo - <_description>Nativo - - - - - nativo-us - <_description>Nativo for USA keyboards - - - - - nativo-epo - <_description>Nativo for Esperanto - epo - - - - - - - bg - <_shortDescription>Bgr - <_description>Bulgaria - bul - - - - - phonetic - <_description>Traditional phonetic - - - - - - - bas_phonetic - <_description>New phonetic - - - - - - - ma - <_description>Morocco - - - - - french - <_description>French - fra - - - - - tifinagh - <_description>Tifinagh - ber - - - - - tifinagh-alt - <_description>Tifinagh alternative - ber - - - - - tifinagh-alt-phonetic - <_description>Tifinagh alternative phonetic - ber - - - - - tifinagh-extended - <_description>Tifinagh extended - ber - - - - - tifinagh-phonetic - <_description>Tifinagh phonetic - ber - - - - - tifinagh-extended-phonetic - <_description>Tifinagh extended phonetic - ber - - - - - - - mm - <_shortDescription>Mmr - <_description>Myanmar - mya - - - - - - ca - <_shortDescription>Can - <_description>Canada - fra - - - - - fr-dvorak - <_description>French Dvorak - - - - - fr-legacy - <_description>French (legacy) - - - - - multix - <_description>Multilingual - - - - - multi - <_description>Multilingual, first part - - - - - multi-2gr - <_description>Multilingual, second part - - - - - ike - <_description>Inuktitut - iku - - - - - shs - <_description>Secwepemctsin - - - - - - kut - <_description>Ktunaxa - - - - - eng - <_description>English - eng - - - - - - - cd - <_shortDescription>COD - <_description>Congo, Democratic Republic of the - fra - - - - - - cn - <_shortDescription>Chn - <_description>China - chi - - - - - tib - <_description>Tibetan - tib - - - - - tib_asciinum - <_description>Tibetan (with ASCII numerals) - tib - - - - - uig - Uyghur - uig - - - - - - - hr - <_shortDescription>Hrv - <_description>Croatia - scr - - - - - alternatequotes - <_description>Use guillemets for quotes - - - - - unicode - <_description>Use Croatian digraphs - - - - - unicodeus - <_description>US keyboard with Croatian digraphs - - - - - us - <_description>US keyboard with Croatian letters - - - - - - - cz - <_shortDescription>Cze - <_description>Czechia - cze - - - - - bksl - <_description>With <\|> key - - - - - qwerty - <_description>qwerty - - - - - qwerty_bksl - <_description>qwerty, extended Backslash - - - - - ucw - <_description>UCW layout (accented letters only) - - - - - dvorak-ucw - <_description>US Dvorak with CZ UCW support - - - - - - - dk - <_shortDescription>Dnk - <_description>Denmark - dan - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - mac - <_description>Macintosh - - - - - mac_nodeadkeys - <_description>Macintosh, eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - - - nl - <_shortDescription>Nld - <_description>Netherlands - nld - - - - - sundeadkeys - <_description>Sun dead keys - - - - - mac - <_description>Macintosh - - - - - std - <_description>Standard - - - - - - - bt - <_shortDescription>Btn - <_description>Bhutan - dzo - - - - - ee - <_shortDescription>Est - <_description>Estonia - est - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - us - <_description>US keyboard with Estonian letters - - - - - - - ir - <_shortDescription>Irn - <_description>Iran - per - - - - - pes_keypad - <_description>Persian, with Persian Keypad - - - - - ku - <_description>Kurdish, Latin Q - kur - - - - - ku_f - <_description>Kurdish, (F) - kur - - - - - ku_alt - <_description>Kurdish, Latin Alt-Q - kur - - - - - ku_ara - <_description>Kurdish, Arabic-Latin - kur - - - - - - - iq - <_shortDescription>Irq - <_description>Iraq - ara - kur - - - - - ku - <_description>Kurdish, Latin Q - kur - - - - - ku_f - <_description>Kurdish, (F) - kur - - - - - ku_alt - <_description>Kurdish, Latin Alt-Q - kur - - - - - ku_ara - <_description>Kurdish, Arabic-Latin - kur - - - - - - - fo - <_shortDescription>Fro - <_description>Faroe Islands - fao - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - - - fi - <_shortDescription>Fin - <_description>Finland - fin - - - - - classic - <_description>Classic - - - - - nodeadkeys - <_description>Classic, eliminate dead keys - - - - - smi - <_description>Northern Saami - smi - sme - - - - - mac - <_description>Macintosh - - - - - - - fr - <_shortDescription>Fra - <_description>France - fra - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - sundeadkeys - <_description>Sun dead keys - - - - - oss - <_description>Alternative - - - - - oss_latin9 - <_description>Alternative, latin-9 only - - - - - oss_nodeadkeys - <_description>Alternative, eliminate dead keys - - - - - oss_sundeadkeys - <_description>Alternative, Sun dead keys - - - - - latin9 - <_description>(Legacy) Alternative - - - - - latin9_nodeadkeys - <_description>(Legacy) Alternative, eliminate dead keys - - - - - latin9_sundeadkeys - <_description>(Legacy) Alternative, Sun dead keys - - - - - bepo - <_description>Bepo, ergonomic, Dvorak way - - - - - bepo_latin9 - <_description>Bepo, ergonomic, Dvorak way, latin-9 only - - - - - dvorak - <_description>Dvorak - - - - - mac - <_description>Macintosh - - - - - bre - <_description>Breton - - - - - oci - <_description>Occitan - oci - - - - - geo - <_description>Georgian AZERTY Tskapo - geo - - - - - - - gh - <_shortDescription>Gha - <_description>Ghana - eng - - - - - generic - <_description>Multilingual - - - - - akan - <_description>Akan - aka - - - - - ewe - <_description>Ewe - ewe - - - - - fula - <_description>Fula - ful - - - - - ga - <_description>Ga - gaa - - - - - hausa - <_description>Hausa - hau - - - - - avn - <_description>Avatime - avn - - - - - gillbt - <_description>GILLBT - - - - - - - gn - <_shortDescription>Gin - <_description>Guinea - fra - - - - - - ge - <_shortDescription>Geo - <_description>Georgia - geo - - - - - ergonomic - <_description>Ergonomic - - - - - mess - <_description>MESS - - - - - ru - <_description>Russian - rus - - - - - os - <_description>Ossetian - oss - - - - - - - de - <_shortDescription>Deu - <_description>Germany - ger - - - - - deadacute - <_description>Dead acute - - - - - deadgraveacute - <_description>Dead grave acute - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - ro - <_description>Romanian keyboard with German letters - - - - - ro_nodeadkeys - <_description>Romanian keyboard with German letters, eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - sundeadkeys - <_description>Sun dead keys - - - - - neo - <_description>Neo 2 - - - - - mac - <_description>Macintosh - - - - - mac_nodeadkeys - <_description>Macintosh, eliminate dead keys - - - - - dsb - <_description>Lower Sorbian - dsb - - - - - dsb_qwertz - <_description>Lower Sorbian (qwertz) - dsb - - - - - qwerty - <_description>qwerty - - - - - ru - <_description>Russian phonetic - rus - - - - - - - gr - <_shortDescription>Grc - <_description>Greece - gre - - - - - simple - <_description>Simple - - - - - extended - <_description>Extended - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - polytonic - <_description>Polytonic - - - - - - - hu - <_shortDescription>Hun - <_description>Hungary - hun - - - - - standard - <_description>Standard - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - qwerty - <_description>qwerty - - - - - - - 101_qwertz_comma_dead - <_description>101/qwertz/comma/Dead keys - - - - - 101_qwertz_comma_nodead - <_description>101/qwertz/comma/Eliminate dead keys - - - - - 101_qwertz_dot_dead - <_description>101/qwertz/dot/Dead keys - - - - - 101_qwertz_dot_nodead - <_description>101/qwertz/dot/Eliminate dead keys - - - - - 101_qwerty_comma_dead - <_description>101/qwerty/comma/Dead keys - - - - - 101_qwerty_comma_nodead - <_description>101/qwerty/comma/Eliminate dead keys - - - - - 101_qwerty_dot_dead - <_description>101/qwerty/dot/Dead keys - - - - - 101_qwerty_dot_nodead - <_description>101/qwerty/dot/Eliminate dead keys - - - - - - - - 102_qwertz_comma_dead - <_description>102/qwertz/comma/Dead keys - - - - - 102_qwertz_comma_nodead - <_description>102/qwertz/comma/Eliminate dead keys - - - - - 102_qwertz_dot_dead - <_description>102/qwertz/dot/Dead keys - - - - - 102_qwertz_dot_nodead - <_description>102/qwertz/dot/Eliminate dead keys - - - - - 102_qwerty_comma_dead - <_description>102/qwerty/comma/Dead keys - - - - - 102_qwerty_comma_nodead - <_description>102/qwerty/comma/Eliminate dead keys - - - - - 102_qwerty_dot_dead - <_description>102/qwerty/dot/Dead keys - - - - - 102_qwerty_dot_nodead - <_description>102/qwerty/dot/Eliminate dead keys - - - - - - - is - <_shortDescription>Isl - <_description>Iceland - ice - - - - - Sundeadkeys - <_description>Sun dead keys - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - mac - <_description>Macintosh - - - - - dvorak - <_description>Dvorak - - - - - - - il - <_shortDescription>Isr - <_description>Israel - heb - - - - - lyx - <_description>lyx - - - - - phonetic - <_description>Phonetic - - - - - biblical - <_description>Biblical Hebrew (Tiro) - - - - - - - it - <_shortDescription>Ita - <_description>Italy - ita - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - mac - <_description>Macintosh - - - - - us - <_description>US keyboard with Italian letters - - - - - geo - <_description>Georgian - geo - - - - - - - jp - <_shortDescription>Jpn - <_description>Japan - jpn - - - - - kana - <_description>Kana - - - - - kana86 - <_description>Kana 86 - - - - - OADG109A - <_description>OADG 109A - - - - - mac - <_description>Macintosh - - - - - - - kg - <_shortDescription>Kgz - <_description>Kyrgyzstan - kir - - - - - phonetic - <_description>Phonetic - - - - - - - kh - <_shortDescription>Khm - <_description>Cambodia - khm - - - - - - kz - <_shortDescription>Kaz - <_description>Kazakhstan - kaz - - - - - ruskaz - <_description>Russian with Kazakh - kaz - rus - - - - - kazrus - <_description>Kazakh with Russian - kaz - rus - - - - - - - la - <_shortDescription>Lao - <_description>Laos - lao - - - - - basic - <_description>Laos - lao - - - - - - stea - <_description>Laos - STEA (proposed standard layout) - lao - - - - - - - - latam - <_shortDescription>Esp - <_description>Latin American - - AR - BO - CL - CO - CR - CU - DO - EC - GT - HN - HT - MX - NI - PA - PE - PR - PY - SV - US - UY - VE - - spa - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - deadtilde - <_description>Include dead tilde - - - - - sundeadkeys - <_description>Sun dead keys - - - - - - - lt - <_shortDescription>Ltu - <_description>Lithuania - lit - - - - - std - <_description>Standard - - - - - us - <_description>US keyboard with Lithuanian letters - - - - - ibm - <_description>IBM (LST 1205-92) - - - - - lekp - <_description>LEKP - - - - - lekpa - <_description>LEKPa - - - - - - - lv - <_shortDescription>Lva - <_description>Latvia - lav - - - - - apostrophe - <_description>Apostrophe (') variant - - - - - tilde - <_description>Tilde (~) variant - - - - - fkey - <_description>F-letter (F) variant - - - - - - - mao - <_shortDescription>Mao - <_description>Maori - mao - - - - - - me - <_shortDescription>MNE - <_description>Montenegro - srp - - - - - cyrillic - <_description>Cyrillic - - - - - cyrillicyz - <_description>Cyrillic, Z and ZHE swapped - - - - - latinunicode - <_description>Latin unicode - - - - - latinyz - <_description>Latin qwerty - - - - - latinunicodeyz - <_description>Latin unicode qwerty - - - - - cyrillicalternatequotes - <_description>Cyrillic with guillemets - - - - - latinalternatequotes - <_description>Latin with guillemets - - - - - - - mk - <_shortDescription>Mkd - <_description>Macedonia - mkd - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - - - mt - <_shortDescription>Mlt - <_description>Malta - mlt - - - - - us - <_description>Maltese keyboard with US layout - - - - - - - mn - <_shortDescription>Mng - <_description>Mongolia - mng - - - - - - no - <_shortDescription>Nor - <_description>Norway - nor - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - smi - <_description>Northern Saami - sme - - - - - smi_nodeadkeys - <_description>Northern Saami, eliminate dead keys - sme - - - - - mac - <_description>Macintosh - - - - - mac_nodeadkeys - <_description>Macintosh, eliminate dead keys - - - - - - - pl - <_shortDescription>Pol - <_description>Poland - pol - - - - - qwertz - <_description>qwertz - - - - - dvorak - <_description>Dvorak - - - - - dvorak_quotes - <_description>Dvorak, Polish quotes on quotemark key - - - - - dvorak_altquotes - <_description>Dvorak, Polish quotes on key 1 - - - - - csb - <_description>Kashubian - csb - - - - - ru_phonetic_dvorak - <_description>Russian phonetic Dvorak - rus - - - - - dvp - <_description>Programmer Dvorak - - - - - - - pt - <_shortDescription>Prt - <_description>Portugal - por - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - sundeadkeys - <_description>Sun dead keys - - - - - mac - <_description>Macintosh - - - - - mac_nodeadkeys - <_description>Macintosh, eliminate dead keys - - - - - mac_sundeadkeys - <_description>Macintosh, Sun dead keys - - - - - nativo - <_description>Nativo - - - - - nativo-us - <_description>Nativo for USA keyboards - - - - - nativo-epo - <_description>Nativo for Esperanto - epo - - - - - - - ro - <_shortDescription>Rou - <_description>Romania - rum - - - - - cedilla - <_description>Cedilla - - - - - std - <_description>Standard - - - - - std_cedilla - <_description>Standard (Cedilla) - - - - - winkeys - <_description>Winkeys - - - - - crh_f - <_description>Crimean Tatar (Turkish F) - crh - - - - - crh_alt - <_description>Crimean Tatar (Turkish Alt-Q) - crh - - - - - crh_dobruca1 - <_description>Crimean Tatar (Dobruca-1 Q) - crh - - - - - crh_dobruca2 - <_description>Crimean Tatar (Dobruca-2 Q) - crh - - - - - - - ru - <_shortDescription>Rus - <_description>Russia - rus - - - - - phonetic - <_description>Phonetic - - - - - phonetic_winkeys - <_description>Phonetic Winkeys - - - - - typewriter - <_description>Typewriter - - - - - legacy - <_description>Legacy - - - - - typewriter-legacy - <_description>Typewriter, legacy - - - - - tt - <_description>Tatar - tat - - - - - os_legacy - <_description>Ossetian, legacy - oss - - - - - os_winkeys - <_description>Ossetian, Winkeys - oss - - - - - cv - <_description>Chuvash - chv - - - - - cv_latin - <_description>Chuvash Latin - chv - - - - - udm - <_description>Udmurt - udm - - - - - kom - <_description>Komi - kom - - - - - sah - <_description>Yakut - sah - - - - - xal - <_description>Kalmyk - xal - - - - - dos - <_description>DOS - - - - - srp - <_description>Serbian - rus - srp - - - - - bak - <_description>Bashkirian - bak - - - - - chm - <_description>Mari - chm - - - - - - - rs - <_shortDescription>SRB - <_description>Serbia - srp - - - - - yz - <_description>Z and ZHE swapped - - - - - latin - <_description>Latin - - - - - latinunicode - <_description>Latin Unicode - - - - - latinyz - <_description>Latin qwerty - - - - - latinunicodeyz - <_description>Latin Unicode qwerty - - - - - alternatequotes - <_description>With guillemets - - - - - latinalternatequotes - <_description>Latin with guillemets - - - - - rue - <_description>Pannonian Rusyn Homophonic - rue - - - - - - - si - <_shortDescription>Svn - <_description>Slovenia - slv - - - - - alternatequotes - <_description>Use guillemets for quotes - - - - - us - <_description>US keyboard with Slovenian letters - - - - - - - sk - <_shortDescription>Svk - <_description>Slovakia - slo - - - - - bksl - <_description>Extended Backslash - - - - - qwerty - <_description>qwerty - - - - - qwerty_bksl - <_description>qwerty, extended Backslash - - - - - - - es - <_shortDescription>Esp - <_description>Spain - spa - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - deadtilde - <_description>Include dead tilde - - - - - sundeadkeys - <_description>Sun dead keys - - - - - dvorak - <_description>Dvorak - - - - - ast - <_description>Asturian variant with bottom-dot H and bottom-dot L - ast - - - - - cat - <_description>Catalan variant with middle-dot L - cat - - - - - mac - <_description>Macintosh - - - - - - - se - <_shortDescription>Swe - <_description>Sweden - swe - - - - - nodeadkeys - <_description>Eliminate dead keys - - - - - dvorak - <_description>Dvorak - - - - - rus - <_description>Russian phonetic - rus - - - - - rus_nodeadkeys - <_description>Russian phonetic, eliminate dead keys - rus - - - - - smi - <_description>Northern Saami - sme - - - - - mac - <_description>Macintosh - - - - - svdvorak - <_description>Svdvorak - - - - - - - ch - <_shortDescription>Che - <_description>Switzerland - ger - gsw - - - - - legacy - <_description>Legacy - - - - - de_nodeadkeys - <_description>German, eliminate dead keys - - - - - de_sundeadkeys - <_description>German, Sun dead keys - - - - - fr - <_description>French - fra - - - - - fr_nodeadkeys - <_description>French, eliminate dead keys - fra - - - - - fr_sundeadkeys - <_description>French, Sun dead keys - fra - - - - - fr_mac - <_description>French (Macintosh) - fra - - - - - de_mac - <_description>German (Macintosh) - - - - - - - sy - <_shortDescription>Syr - <_description>Syria - syr - - - - - syc - <_description>Syriac - - - - - syc_phonetic - <_description>Syriac phonetic - - - - - ku - <_description>Kurdish, Latin Q - kur - - - - - ku_f - <_description>Kurdish, (F) - kur - - - - - ku_alt - <_description>Kurdish, Latin Alt-Q - kur - - - - - - - tj - <_shortDescription>Tjk - <_description>Tajikistan - tgk - - - - - legacy - <_description>Legacy - - - - - - - lk - <_shortDescription>Lka - <_description>Sri Lanka - sin - - - - - tam_unicode - <_description>Tamil Unicode - tam - - - - - tam_TAB - <_description>Tamil TAB Typewriter - tam - - - - - - - th - <_shortDescription>Tha - <_description>Thailand - tha - - - - - tis - <_description>TIS-820.2538 - - - - - pat - <_description>Pattachote - - - - - - - tr - <_shortDescription>Tur - <_description>Turkey - tur - - - - - f - <_description>(F) - - - - - alt - <_description>Alt-Q - - - - - sundeadkeys - <_description>Sun dead keys - - - - - ku - <_description>Kurdish, Latin Q - kur - - - - - ku_f - <_description>Kurdish, (F) - kur - - - - - ku_alt - <_description>Kurdish, Latin Alt-Q - kur - - - - - intl - <_description>International (with dead keys) - - - - - crh - <_description>Crimean Tatar (Turkish Q) - crh - - - - - crh_f - <_description>Crimean Tatar (Turkish F) - crh - - - - - crh_alt - <_description>Crimean Tatar (Turkish Alt-Q) - crh - - - - - - - ua - <_shortDescription>Ukr - <_description>Ukraine - ukr - - - - - phonetic - <_description>Phonetic - - - - - typewriter - <_description>Typewriter - - - - - winkeys - <_description>Winkeys - - - - - legacy - <_description>Legacy - - - - - rstu - - <_description>Standard RSTU - - - - - rstu_ru - - <_description>Standard RSTU on Russian layout - - - - - homophonic - <_description>Homophonic - - - - - crh - <_description>Crimean Tatar (Turkish Q) - crh - - - - - crh_f - <_description>Crimean Tatar (Turkish F) - crh - - - - - crh_alt - <_description>Crimean Tatar (Turkish Alt-Q) - crh - - - - - - - gb - <_shortDescription>GBr - <_description>United Kingdom - eng - - - - - extd - <_description>Extended - Winkeys - - - - - intl - <_description>International (with dead keys) - - - - - dvorak - <_description>Dvorak - - - - - dvorakukp - <_description>Dvorak (UK Punctuation) - - - - - mac - <_description>Macintosh - - - - - mac_intl - <_description>Macintosh (International) - - - - - colemak - <_description>Colemak - - - - - - - uz - <_shortDescription>Uzb - <_description>Uzbekistan - uzb - - - - - latin - <_description>Latin - - - - - crh - <_description>Crimean Tatar (Turkish Q) - crh - - - - - crh_f - <_description>Crimean Tatar (Turkish F) - crh - - - - - crh_alt - <_description>Crimean Tatar (Turkish Alt-Q) - crh - - - - - - - vn - <_shortDescription>Vnm - <_description>Vietnam - vie - - - - - - kr - <_shortDescription>Kor - <_description>Korea, Republic of - kor - - - - - kr104 - <_description>101/104 key Compatible - - - - - - - nec_vndr/jp - <_shortDescription>Jpn - <_description>Japan (PC-98xx Series) - JP - jpn - - - - - - ie - <_shortDescription>Irl - <_description>Ireland - eng - - - - - CloGaelach - <_description>CloGaelach - gla - - - - - UnicodeExpert - <_description>UnicodeExpert - - - - - ogam - <_description>Ogham - - - - - - ogam_is434 - <_description>Ogham IS434 - - - - - - - - pk - <_shortDescription>Pak - <_description>Pakistan - urd - - - - - urd-crulp - <_description>CRULP - urd - - - - - urd-nla - <_description>NLA - urd - - - - - ara - <_description>Arabic - ara - - - - - snd - <_description>Sindhi - sd - - - - - - - mv - <_shortDescription>Mdv - <_description>Maldives - div - - - - - - za - <_shortDescription>Zaf - <_description>South Africa - eng - - - - - epo - <_shortDescription>Epo - <_description>Esperanto - epo - - - - - legacy - <_description>displaced semicolon and quote (obsolete) - - - - - - - np - <_shortDescription>Npl - <_description>Nepal - nep - - - - - ng - <_shortDescription>Nga - <_description>Nigeria - eng - - - - - igbo - <_description>Igbo - ibo - - - - - yoruba - <_description>Yoruba - yor - - - - - hausa - <_description>Hausa - hau - - - - - - - et - <_shortDescription>Eth - <_description>Ethiopia - amh - - - - - - sn - <_shortDescription>Sen - <_description>Senegal - wol - - - - - - brai - <_shortDescription>Brl - <_description>Braille - - - - - left_hand - <_description>Left hand - - - - - right_hand - <_description>Right hand - - - - - - - tm - <_shortDescription>Tkm - <_description>Turkmenistan - tuk - - - - - alt - <_description>Alt-Q - - - - - - - ml - <_shortDescription>Mli - <_description>Mali - bam - - - - - fr-oss - <_description>Français (France Alternative) - - - - - us-mac - <_description>English (USA Macintosh) - - - - - us-intl - <_description>English (USA International) - - - - - - - tz - <_shortDescription>Tza - <_description>Tanzania - swa - - - - - ke - <_shortDescription>Ken - <_description>Kenya - swa - - - - - kik - <_description>Kikuyu - kik - - - - - - - bw - <_shortDescription>Bwa - <_description>Botswana - tsn - - - - - ph - <_shortDescription>Phi - <_description>Philippines - eng - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - qwerty-bay - <_description>QWERTY (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - capewell-dvorak - <_description>Capewell-Dvorak (Latin) - - - - - capewell-dvorak-bay - <_description>Capewell-Dvorak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - capewell-qwerf2k6 - <_description>Capewell-QWERF 2006 (Latin) - - - - - capewell-qwerf2k6-bay - <_description>Capewell-QWERF 2006 (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - colemak - <_description>Colemak (Latin) - - - - - colemak-bay - <_description>Colemak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - dvorak - <_description>Dvorak (Latin) - - - - - dvorak-bay - <_description>Dvorak (Baybayin) - bik - ceb - fil - hil - ilo - pam - pag - phi - tgl - war - - - - - - - - - - grp - <_description>Key(s) to change layout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - lv3 - <_description>Key to choose 3rd level - - - - - - - - - - - - - - - - - - - - - - - ctrl - <_description>Ctrl key position - - - - - - - - - - - - - grp_led - <_description>Use keyboard LED to show alternative layout - - - - - - - - - keypad - <_description>Numeric keypad layout selection - - - - - - - - - - - - - - - kpdl - <_description>Numeric keypad delete key behaviour - - - - - - - - - - - - - - caps - <_description>Caps Lock key behavior - - - - - - - - - - - - - - - - - - - altwin - <_description>Alt/Win key behavior - - - - - - - - - - - - - - - Compose key - <_description>Compose key position - - - - - - - - - - - - - - - - compat - <_description>Miscellaneous compatibility options - - - - - - - - - - - - - - - - - - eurosign - <_description>Adding currency signs to certain keys - - - - - - - - - - lv5 - <_description>Key to choose 5th level - - - - - - - - - - - - - - - - nbsp - <_description>Using space key to input non-breakable space character - - - - - - - - - - - - - - - - - - - - - japan - <_description>Japanese keyboard options - - - - - - - esperanto - <_description>Adding Esperanto circumflexes (supersigno) - - - - - - - terminate - <_description>Key sequence to kill the X server - - - - - + + + + + + + pc101 + <_description>Generic 101-key PC + Generic + + + + + pc102 + <_description>Generic 102-key (Intl) PC + Generic + + + + + pc104 + <_description>Generic 104-key PC + Generic + + + + + pc105 + <_description>Generic 105-key (Intl) PC + Generic + + + + + dell101 + <_description>Dell 101-key PC + Dell + + + + + latitude + <_description>Dell Latitude series laptop + Dell + + + + + dellm65 + <_description>Dell Precision M65 + Dell + + + + + everex + <_description>Everex STEPnote + Everex + + + + + flexpro + <_description>Keytronic FlexPro + Keytronic + + + + + microsoft + <_description>Microsoft Natural + Microsoft Inc. + + + + + omnikey101 + <_description>Northgate OmniKey 101 + Northgate + + + + + winbook + <_description>Winbook Model XP5 + Generic + + + + + pc98 + <_description>PC-98xx Series + Generic + + + + + a4techKB21 + <_description>A4Tech KB-21 + A4Tech + + + + + a4techKBS8 + <_description>A4Tech KBS-8 + A4Tech + + + + + a4_rfkb23 + <_description>A4Tech Wireless Desktop RFKB-23 + A4Tech + + + + + airkey + <_description>Acer AirKey V + Acer + + + + + azonaRF2300 + <_description>Azona RF2300 wireless Internet Keyboard + Azona + + + + + scorpius + <_description>Advance Scorpius KI + Scorpius + + + + + brother + <_description>Brother Internet Keyboard + Brother + + + + + btc5113rf + <_description>BTC 5113RF Multimedia + BTC + + + + + btc5126t + <_description>BTC 5126T + BTC + + + + + btc6301urf + <_description>BTC 6301URF + BTC + + + + + btc9000 + <_description>BTC 9000 + BTC + + + + + btc9000a + <_description>BTC 9000A + BTC + + + + + btc9001ah + <_description>BTC 9001AH + BTC + + + + + btc5090 + <_description>BTC 5090 + BTC + + + + + btc9019u + <_description>BTC 9019U + BTC + + + + + btc9116u + <_description>BTC 9116U Mini Wireless Internet and Gaming + + + + + cherryblue + <_description>Cherry Blue Line CyBo@rd + + + + + cherryblueb + <_description>Cherry CyMotion Master XPress + Cherry + + + + + cherrybluea + <_description>Cherry Blue Line CyBo@rd (alternate option) + Cherry + + + + + cherrycyboard + <_description>Cherry CyBo@rd USB-Hub + Cherry + + + + + cherrycmexpert + <_description>Cherry CyMotion Expert + Cherry + + + + + cherrybunlim + <_description>Cherry B.UNLIMITED + Cherry + + + + + chicony + <_description>Chicony Internet Keyboard + Chicony + + + + + chicony0108 + <_description>Chicony KU-0108 + Chicony + + + + + chicony0420 + <_description>Chicony KU-0420 + Chicony + + + + + chicony9885 + <_description>Chicony KB-9885 + Chicony + + + + + compaqeak8 + <_description>Compaq Easy Access Keyboard + Compaq + + + + + compaqik7 + <_description>Compaq Internet Keyboard (7 keys) + Compaq + + + + + compaqik13 + <_description>Compaq Internet Keyboard (13 keys) + Compaq + + + + + compaqik18 + <_description>Compaq Internet Keyboard (18 keys) + Compaq + + + + + cymotionlinux + <_description>Cherry CyMotion Master Linux + Cherry + + + + + armada + <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard + Compaq + + + + + presario + <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard + Compaq + + + + + ipaq + <_description>Compaq iPaq Keyboard + Compaq + + + + + dell + <_description>Dell + Dell + + + + + dellsk8125 + <_description>Dell SK-8125 + Dell + + + + + dellsk8135 + <_description>Dell SK-8135 + Dell + + + + + dellusbmm + <_description>Dell USB Multimedia Keyboard + Dell + + + + + inspiron + <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx + Dell + + + + + precision_m + <_description>Dell Laptop/notebook Precision M series + Dell + + + + + dexxa + <_description>Dexxa Wireless Desktop Keyboard + Dexxa + + + + + diamond + <_description>Diamond 9801 / 9802 series + Diamond + + + + + dtk2000 + <_description>DTK2000 + + + + + ennyah_dkb1008 + <_description>Ennyah DKB-1008 + Ennyah + + + + + fscaa1667g + <_description>Fujitsu-Siemens Computers AMILO laptop + Fujitsu-Siemens + + + + + genius + <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910 + Genius + + + + + geniuscomfy + <_description>Genius Comfy KB-12e + Genius + + + + + geniuscomfy2 + <_description>Genius Comfy KB-21e-Scroll + Genius + + + + + geniuskb19e + <_description>Genius KB-19e NB + Genius + + + + + geniuskkb2050hs + <_description>Genius KKB-2050HS + Genius + + + + + gyration + <_description>Gyration + Gyration + + + + + htcdream + <_description>HTC Dream + HTC + + + + + kinesis + <_description>Kinesis + Kinesis + + + + + logitech_base + <_description>Logitech Generic Keyboard + Logitech + + + + + logitech_g15 + <_description>Logitech G15 extra keys via G15daemon + Logitech + + + + + hpi6 + <_description>Hewlett-Packard Internet Keyboard + Hewlett-Packard + + + + + hp250x + <_description>Hewlett-Packard SK-250x Multimedia Keyboard + Hewlett-Packard + + + + + hpxe3gc + <_description>Hewlett-Packard Omnibook XE3 GC + Hewlett-Packard + + + + + hpxe3gf + <_description>Hewlett-Packard Omnibook XE3 GF + Hewlett-Packard + + + + + hpxt1000 + <_description>Hewlett-Packard Omnibook XT1000 + Hewlett-Packard + + + + + hpdv5 + <_description>Hewlett-Packard Pavilion dv5 + Hewlett-Packard + + + + + hpzt11xx + <_description>Hewlett-Packard Pavilion ZT11xx + Hewlett-Packard + + + + + hp500fa + <_description>Hewlett-Packard Omnibook 500 FA + Hewlett-Packard + + + + + hp5xx + <_description>Hewlett-Packard Omnibook 5xx + Hewlett-Packard + + + + + hpnx9020 + <_description>Hewlett-Packard nx9020 + Hewlett-Packard + + + + + hp6000 + <_description>Hewlett-Packard Omnibook 6000/6100 + Hewlett-Packard + + + + + honeywell_euroboard + <_description>Honeywell Euroboard + Hewlett-Packard + + + + + hpmini110 + <_description>Hewlett-Packard Mini 110 Notebook + Hewlett-Packard + + + + + rapidaccess + <_description>IBM Rapid Access + Lenovo (previously IBM) + + + + + rapidaccess2 + <_description>IBM Rapid Access II + Lenovo (previously IBM) + + + + + thinkpad + <_description>IBM ThinkPad 560Z/600/600E/A22E + Lenovo (previously IBM) + + + + + thinkpad60 + <_description>IBM ThinkPad R60/T60/R61/T61 + Lenovo (previously IBM) + + + + + thinkpadz60 + <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t + Lenovo (previously IBM) + + + + + ibm_spacesaver + <_description>IBM Space Saver + Lenovo (previously IBM) + + + + + logiaccess + <_description>Logitech Access Keyboard + Logitech + + + + + logiclx300 + <_description>Logitech Cordless Desktop LX-300 + Logitech + + + + + logii350 + <_description>Logitech Internet 350 Keyboard + Logitech + + + + + logimel + <_description>Logitech Media Elite Keyboard + Logitech + + + + + logicd + <_description>Logitech Cordless Desktop + Logitech + + + + + logicd_it + <_description>Logitech Cordless Desktop iTouch + Logitech + + + + + logicd_nav + <_description>Logitech Cordless Desktop Navigator + Logitech + + + + + logicd_opt + <_description>Logitech Cordless Desktop Optical + Logitech + + + + + logicda + <_description>Logitech Cordless Desktop (alternate option) + Logitech + + + + + logicdpa2 + <_description>Logitech Cordless Desktop Pro (alternate option 2) + Logitech + + + + + logicfn + <_description>Logitech Cordless Freedom/Desktop Navigator + Logitech + + + + + logicdn + <_description>Logitech Cordless Desktop Navigator + Logitech + + + + + logiitc + <_description>Logitech iTouch Cordless Keyboard (model Y-RB6) + Logitech + + + + + logiik + <_description>Logitech Internet Keyboard + Logitech + + + + + itouch + <_description>Logitech iTouch + Logitech + + + + + logicink + <_description>Logitech Internet Navigator Keyboard + Logitech + + + + + logiex110 + <_description>Logitech Cordless Desktop EX110 + Logitech + + + + + logiinkse + <_description>Logitech iTouch Internet Navigator Keyboard SE + Logitech + + + + + logiinkseusb + <_description>Logitech iTouch Internet Navigator Keyboard SE (USB) + Logitech + + + + + logiultrax + <_description>Logitech Ultra-X Keyboard + Logitech + + + + + logiultraxc + <_description>Logitech Ultra-X Cordless Media Desktop Keyboard + Logitech + + + + + logidinovo + <_description>Logitech diNovo Keyboard + Logitech + + + + + logidinovoedge + <_description>Logitech diNovo Edge Keyboard + Logitech + + + + + mx1998 + <_description>Memorex MX1998 + Memorex + + + + + mx2500 + <_description>Memorex MX2500 EZ-Access Keyboard + Memorex + + + + + mx2750 + <_description>Memorex MX2750 + Memorex + + + + + microsoft7000 + <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000 + Microsoft Inc. + + + + + microsoftinet + <_description>Microsoft Internet Keyboard + Microsoft Inc. + + + + + microsoftpro + <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro + Microsoft Inc. + + + + + microsoftprousb + <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro + Microsoft Inc. + + + + + microsoftprooem + <_description>Microsoft Natural Keyboard Pro OEM + Microsoft Inc. + + + + + vsonku306 + <_description>ViewSonic KU-306 Internet Keyboard + ViewSonic + + + + + microsoftprose + <_description>Microsoft Internet Keyboard Pro, Swedish + Microsoft Inc. + + + + + microsoftoffice + <_description>Microsoft Office Keyboard + Microsoft Inc. + + + + + microsoftmult + <_description>Microsoft Wireless Multimedia Keyboard 1.0A + Microsoft Inc. + + + + + microsoftelite + <_description>Microsoft Natural Keyboard Elite + Microsoft Inc. + + + + + microsoftccurve2k + <_description>Microsoft Comfort Curve Keyboard 2000 + Microsoft Inc. + + + + + oretec + <_description>Ortek MCK-800 MM/Internet keyboard + Ortek + + + + + propeller + <_description>Propeller Voyager (KTEZ-1000) + KeyTronic + + + + + qtronix + <_description>QTronix Scorpius 98N+ + QTronix + + + + + samsung4500 + <_description>Samsung SDM 4500P + Samsung + + + + + samsung4510 + <_description>Samsung SDM 4510P + Samsung + + + + + sanwaskbkg3 + <_description>Sanwa Supply SKB-KG3 + Sanwa Supply Inc. + + + + + sk1300 + <_description>SK-1300 + NEC + + + + + sk2500 + <_description>SK-2500 + NEC + + + + + sk6200 + <_description>SK-6200 + NEC + + + + + sk7100 + <_description>SK-7100 + NEC + + + + + sp_inet + <_description>Super Power Multimedia Keyboard + Generic + + + + + sven + <_description>SVEN Ergonomic 2500 + SVEN + + + + + sven303 + <_description>SVEN Slim 303 + SVEN + + + + + symplon + <_description>Symplon PaceBook (tablet PC) + Symplon + + + + + toshiba_s3000 + <_description>Toshiba Satellite S3000 + Toshiba + + + + + trust + <_description>Trust Wireless Keyboard Classic + Trust + + + + + trustda + <_description>Trust Direct Access Keyboard + Trust + + + + + trust_slimline + <_description>Trust Slimline + Trust + + + + + tm2020 + <_description>TypeMatrix EZ-Reach 2020 + TypeMatrix + + + + + tm2030PS2 + <_description>TypeMatrix EZ-Reach 2030 PS2 + TypeMatrix + + + + + tm2030USB + <_description>TypeMatrix EZ-Reach 2030 USB + TypeMatrix + + + + + tm2030USB-102 + <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode) + TypeMatrix + + + + + tm2030USB-106 + <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode) + TypeMatrix + + + + + yahoo + <_description>Yahoo! Internet Keyboard + Yahoo! + + + + + macbook78 + <_description>MacBook/MacBook Pro + Apple + + + + + macbook79 + <_description>MacBook/MacBook Pro (Intl) + Apple + + + + + macintosh + <_description>Macintosh + Apple + + + + + macintosh_old + <_description>Macintosh Old + Apple + + + + + macintosh_hhk + <_description>Happy Hacking Keyboard for Mac + Fujitsu + + + + + acer_c300 + <_description>Acer C300 + Acer + + + + + acer_ferrari4k + <_description>Acer Ferrari 4000 + Acer + + + + + acer_laptop + <_description>Acer Laptop + Acer + + + + + asus_laptop + <_description>Asus Laptop + Asus + + + + + apple + <_description>Apple + Apple + + + + + apple_laptop + <_description>Apple Laptop + Apple + + + + + applealu_ansi + <_description>Apple Aluminium Keyboard (ANSI) + Apple + + + + + applealu_iso + <_description>Apple Aluminium Keyboard (ISO) + Apple + + + + + applealu_jis + <_description>Apple Aluminium Keyboard (JIS) + Apple + + + + + silvercrest + <_description>SILVERCREST Multimedia Wireless Keyboard + Silvercrest + + + + + emachines + <_description>Laptop/notebook eMachines m68xx + eMachines + + + + + benqx + <_description>BenQ X-Touch + BenQ + + + + + benqx730 + <_description>BenQ X-Touch 730 + BenQ + + + + + benqx800 + <_description>BenQ X-Touch 800 + BenQ + + + + + hhk + <_description>Happy Hacking Keyboard + Fujitsu + + + + + classmate + <_description>Classmate PC + Intel + + + + + olpc + <_description>OLPC + OLPC + + + + + sun6 + <_description>Sun Type 5/6 + Sun Microsystems + + + + + targa_v811 + <_description>Targa Visionary 811 + Targa + + + + + unitekkb1925 + <_description>Unitek KB-1925 + Unitek Group + + + + + compalfl90 + <_description>FL90 + Compal Electronics Inc. + + + + + creativedw7000 + <_description>Creative Desktop Wireless 7000 + Creative + + + + + htcdream + <_description>Htc Dream phone + htc + + + + + + + us + <_shortDescription>USA + <_description>USA + eng + + + + + chr + <_description>Cherokee + chr + + + + + euro + <_description>With EuroSign on 5 + + + + + intl + <_description>International (with dead keys) + + + + + alt-intl + <_description>Alternative international + + + + + colemak + <_description>Colemak + + + + + dvorak + <_description>Dvorak + + + + + dvorak-intl + <_description>Dvorak international (with dead keys) + + + + + dvorak-alt-intl + <_description>Dvorak alternative international (no dead keys) + + + + + dvorak-l + <_description>Left handed Dvorak + + + + + dvorak-r + <_description>Right handed Dvorak + + + + + dvorak-classic + <_description>Classic Dvorak + + + + + dvp + <_description>Programmer Dvorak + + + + + rus + <_description>Russian phonetic + rus + + + + + mac + <_description>Macintosh + + + + + altgr-intl + <_description>International (AltGr dead keys) + eng + fra + ger + + + + + olpc2 + <_description>Layout toggle on multiply/divide key + + + + + hbs + <_description>Serbo-Croatian + eng + bos + hbs + hrv + srp + + + + + + + ad + <_shortDescription>And + <_description>Andorra + cat + + + + + + af + <_shortDescription>Afg + <_description>Afghanistan + + + + + ps + <_description>Pashto + pus + + + + + uz + <_description>Southern Uzbek + uzb + + + + + olpc-ps + <_description>OLPC Pashto + pus + + + + + olpc-fa + <_description>OLPC Dari + + + + + + olpc-uz + <_description>OLPC Southern Uzbek + uzb + + + + + + + ara + <_shortDescription>Ara + <_description>Arabic + + AE + BH + DZ + EG + EH + JO + KW + LB + LY + MA + MR + OM + PS + QA + SA + SD + SY + TN + YE + + ara + + + + + azerty + <_description>azerty + + + + + azerty_digits + <_description>azerty/digits + + + + + digits + <_description>digits + + + + + qwerty + <_description>qwerty + + + + + qwerty_digits + <_description>qwerty/digits + + + + + buckwalter + <_description>Buckwalter + + + + + + + al + <_shortDescription>Alb + <_description>Albania + alb + + + + + + am + <_shortDescription>Arm + <_description>Armenia + hye + + + + + phonetic + <_description>Phonetic + + + + + phonetic-alt + <_description>Alternative Phonetic + + + + + eastern + <_description>Eastern + + + + + western + <_description>Western + + + + + eastern-alt + <_description>Alternative Eastern + + + + + + + at + <_shortDescription>Aut + <_description>Austria + ger + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + sundeadkeys + <_description>Sun dead keys + + + + + mac + <_description>Macintosh + + + + + + + az + <_shortDescription>Aze + <_description>Azerbaijan + aze + + + + + cyrillic + <_description>Cyrillic + + + + + + + by + <_shortDescription>Blr + <_description>Belarus + bel + + + + + legacy + <_description>Legacy + + + + + latin + <_description>Latin + + + + + + + be + <_shortDescription>Bel + <_description>Belgium + ger + nld + fra + + + + + oss + <_description>Alternative + + + + + oss_latin9 + <_description>Alternative, latin-9 only + + + + + oss_sundeadkeys + <_description>Alternative, Sun dead keys + + + + + iso-alternate + <_description>ISO Alternate + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + sundeadkeys + <_description>Sun dead keys + + + + + wang + <_description>Wang model 724 azerty + + + + + + + bd + <_shortDescription>Bgd + <_description>Bangladesh + ben + + + + + probhat + <_description>Probhat + + + + + + + in + <_shortDescription>Ind + <_description>India + + + + + ben + <_description>Bengali + ben + + + + + ben_probhat + <_description>Bengali Probhat + ben + + + + + guj + <_description>Gujarati + guj + + + + + guru + <_description>Gurmukhi + pan + + + + + jhelum + <_description>Gurmukhi Jhelum + pan + + + + + kan + <_description>Kannada + kan + + + + + mal + <_description>Malayalam + mal + + + + + mal_lalitha + <_description>Malayalam Lalitha + mal + + + + + ori + <_description>Oriya + ori + + + + + tam_unicode + <_description>Tamil Unicode + tam + + + + + tam_keyboard_with_numerals + <_description>Tamil Keyboard with Numerals + tam + + + + + tam_TAB + <_description>Tamil TAB Typewriter + tam + + + + + tam_TSCII + <_description>Tamil TSCII Typewriter + tam + + + + + tam + <_description>Tamil + tam + + + + + tel + <_description>Telugu + tel + + + + + urd-phonetic + <_description>Urdu, Phonetic + urd + + + + + urd-phonetic3 + <_description>Urdu, Alternative phonetic + urd + + + + + urd-winkeys + <_description>Urdu, Winkeys + urd + + + + + bolnagri + <_description>Hindi Bolnagri + hin + + + + + hin-wx + <_description>Hindi Wx + hin + + + + + eng + <_description>English with RupeeSign + eng + + + + + + + ba + <_shortDescription>Bih + <_description>Bosnia and Herzegovina + bos + + + + + alternatequotes + <_description> Use guillemets for quotes + + + + + unicode + <_description>Use Bosnian digraphs + + + + + unicodeus + <_description>US keyboard with Bosnian digraphs + + + + + us + <_description>US keyboard with Bosnian letters + + + + + + + br + <_shortDescription>Bra + <_description>Brazil + por + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + nativo + <_description>Nativo + + + + + nativo-us + <_description>Nativo for USA keyboards + + + + + nativo-epo + <_description>Nativo for Esperanto + epo + + + + + + + bg + <_shortDescription>Bgr + <_description>Bulgaria + bul + + + + + phonetic + <_description>Traditional phonetic + + + + + + + bas_phonetic + <_description>New phonetic + + + + + + + ma + <_description>Morocco + + + + + french + <_description>French + fra + + + + + tifinagh + <_description>Tifinagh + ber + + + + + tifinagh-alt + <_description>Tifinagh alternative + ber + + + + + tifinagh-alt-phonetic + <_description>Tifinagh alternative phonetic + ber + + + + + tifinagh-extended + <_description>Tifinagh extended + ber + + + + + tifinagh-phonetic + <_description>Tifinagh phonetic + ber + + + + + tifinagh-extended-phonetic + <_description>Tifinagh extended phonetic + ber + + + + + + + mm + <_shortDescription>Mmr + <_description>Myanmar + mya + + + + + + ca + <_shortDescription>Can + <_description>Canada + fra + + + + + fr-dvorak + <_description>French Dvorak + + + + + fr-legacy + <_description>French (legacy) + + + + + multix + <_description>Multilingual + + + + + multi + <_description>Multilingual, first part + + + + + multi-2gr + <_description>Multilingual, second part + + + + + ike + <_description>Inuktitut + iku + + + + + shs + <_description>Secwepemctsin + + + + + + kut + <_description>Ktunaxa + + + + + eng + <_description>English + eng + + + + + + + cd + <_shortDescription>COD + <_description>Congo, Democratic Republic of the + fra + + + + + + cn + <_shortDescription>Chn + <_description>China + chi + + + + + tib + <_description>Tibetan + tib + + + + + tib_asciinum + <_description>Tibetan (with ASCII numerals) + tib + + + + + uig + <_description>Uyghur + uig + + + + + + + hr + <_shortDescription>Hrv + <_description>Croatia + scr + + + + + alternatequotes + <_description>Use guillemets for quotes + + + + + unicode + <_description>Use Croatian digraphs + + + + + unicodeus + <_description>US keyboard with Croatian digraphs + + + + + us + <_description>US keyboard with Croatian letters + + + + + + + cz + <_shortDescription>Cze + <_description>Czechia + cze + + + + + bksl + <_description>With <\|> key + + + + + qwerty + <_description>qwerty + + + + + qwerty_bksl + <_description>qwerty, extended Backslash + + + + + ucw + <_description>UCW layout (accented letters only) + + + + + dvorak-ucw + <_description>US Dvorak with CZ UCW support + + + + + + + dk + <_shortDescription>Dnk + <_description>Denmark + dan + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + mac + <_description>Macintosh + + + + + mac_nodeadkeys + <_description>Macintosh, eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + + + nl + <_shortDescription>Nld + <_description>Netherlands + nld + + + + + sundeadkeys + <_description>Sun dead keys + + + + + mac + <_description>Macintosh + + + + + std + <_description>Standard + + + + + + + bt + <_shortDescription>Btn + <_description>Bhutan + dzo + + + + + ee + <_shortDescription>Est + <_description>Estonia + est + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + us + <_description>US keyboard with Estonian letters + + + + + + + ir + <_shortDescription>Irn + <_description>Iran + per + + + + + pes_keypad + <_description>Persian, with Persian Keypad + + + + + ku + <_description>Kurdish, Latin Q + kur + + + + + ku_f + <_description>Kurdish, (F) + kur + + + + + ku_alt + <_description>Kurdish, Latin Alt-Q + kur + + + + + ku_ara + <_description>Kurdish, Arabic-Latin + kur + + + + + + + iq + <_shortDescription>Irq + <_description>Iraq + ara + kur + + + + + ku + <_description>Kurdish, Latin Q + kur + + + + + ku_f + <_description>Kurdish, (F) + kur + + + + + ku_alt + <_description>Kurdish, Latin Alt-Q + kur + + + + + ku_ara + <_description>Kurdish, Arabic-Latin + kur + + + + + + + fo + <_shortDescription>Fro + <_description>Faroe Islands + fao + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + + + fi + <_shortDescription>Fin + <_description>Finland + fin + + + + + classic + <_description>Classic + + + + + nodeadkeys + <_description>Classic, eliminate dead keys + + + + + smi + <_description>Northern Saami + smi + sme + + + + + mac + <_description>Macintosh + + + + + + + fr + <_shortDescription>Fra + <_description>France + fra + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + sundeadkeys + <_description>Sun dead keys + + + + + oss + <_description>Alternative + + + + + oss_latin9 + <_description>Alternative, latin-9 only + + + + + oss_nodeadkeys + <_description>Alternative, eliminate dead keys + + + + + oss_sundeadkeys + <_description>Alternative, Sun dead keys + + + + + latin9 + <_description>(Legacy) Alternative + + + + + latin9_nodeadkeys + <_description>(Legacy) Alternative, eliminate dead keys + + + + + latin9_sundeadkeys + <_description>(Legacy) Alternative, Sun dead keys + + + + + bepo + <_description>Bepo, ergonomic, Dvorak way + + + + + bepo_latin9 + <_description>Bepo, ergonomic, Dvorak way, latin-9 only + + + + + dvorak + <_description>Dvorak + + + + + mac + <_description>Macintosh + + + + + bre + <_description>Breton + + + + + oci + <_description>Occitan + oci + + + + + geo + <_description>Georgian AZERTY Tskapo + geo + + + + + + + gh + <_shortDescription>Gha + <_description>Ghana + eng + + + + + generic + <_description>Multilingual + + + + + akan + <_description>Akan + aka + + + + + ewe + <_description>Ewe + ewe + + + + + fula + <_description>Fula + ful + + + + + ga + <_description>Ga + gaa + + + + + hausa + <_description>Hausa + hau + + + + + avn + <_description>Avatime + avn + + + + + gillbt + <_description>GILLBT + + + + + + + gn + <_shortDescription>Gin + <_description>Guinea + fra + + + + + + ge + <_shortDescription>Geo + <_description>Georgia + geo + + + + + ergonomic + <_description>Ergonomic + + + + + mess + <_description>MESS + + + + + ru + <_description>Russian + rus + + + + + os + <_description>Ossetian + oss + + + + + + + de + <_shortDescription>Deu + <_description>Germany + ger + + + + + deadacute + <_description>Dead acute + + + + + deadgraveacute + <_description>Dead grave acute + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + ro + <_description>Romanian keyboard with German letters + + + + + ro_nodeadkeys + <_description>Romanian keyboard with German letters, eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + sundeadkeys + <_description>Sun dead keys + + + + + neo + <_description>Neo 2 + + + + + mac + <_description>Macintosh + + + + + mac_nodeadkeys + <_description>Macintosh, eliminate dead keys + + + + + dsb + <_description>Lower Sorbian + dsb + + + + + dsb_qwertz + <_description>Lower Sorbian (qwertz) + dsb + + + + + qwerty + <_description>qwerty + + + + + ru + <_description>Russian phonetic + rus + + + + + + + gr + <_shortDescription>Grc + <_description>Greece + gre + + + + + simple + <_description>Simple + + + + + extended + <_description>Extended + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + polytonic + <_description>Polytonic + + + + + + + hu + <_shortDescription>Hun + <_description>Hungary + hun + + + + + standard + <_description>Standard + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + qwerty + <_description>qwerty + + + + + + + 101_qwertz_comma_dead + <_description>101/qwertz/comma/Dead keys + + + + + 101_qwertz_comma_nodead + <_description>101/qwertz/comma/Eliminate dead keys + + + + + 101_qwertz_dot_dead + <_description>101/qwertz/dot/Dead keys + + + + + 101_qwertz_dot_nodead + <_description>101/qwertz/dot/Eliminate dead keys + + + + + 101_qwerty_comma_dead + <_description>101/qwerty/comma/Dead keys + + + + + 101_qwerty_comma_nodead + <_description>101/qwerty/comma/Eliminate dead keys + + + + + 101_qwerty_dot_dead + <_description>101/qwerty/dot/Dead keys + + + + + 101_qwerty_dot_nodead + <_description>101/qwerty/dot/Eliminate dead keys + + + + + + + + 102_qwertz_comma_dead + <_description>102/qwertz/comma/Dead keys + + + + + 102_qwertz_comma_nodead + <_description>102/qwertz/comma/Eliminate dead keys + + + + + 102_qwertz_dot_dead + <_description>102/qwertz/dot/Dead keys + + + + + 102_qwertz_dot_nodead + <_description>102/qwertz/dot/Eliminate dead keys + + + + + 102_qwerty_comma_dead + <_description>102/qwerty/comma/Dead keys + + + + + 102_qwerty_comma_nodead + <_description>102/qwerty/comma/Eliminate dead keys + + + + + 102_qwerty_dot_dead + <_description>102/qwerty/dot/Dead keys + + + + + 102_qwerty_dot_nodead + <_description>102/qwerty/dot/Eliminate dead keys + + + + + + + is + <_shortDescription>Isl + <_description>Iceland + ice + + + + + Sundeadkeys + <_description>Sun dead keys + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + mac + <_description>Macintosh + + + + + dvorak + <_description>Dvorak + + + + + + + il + <_shortDescription>Isr + <_description>Israel + heb + + + + + lyx + <_description>lyx + + + + + phonetic + <_description>Phonetic + + + + + biblical + <_description>Biblical Hebrew (Tiro) + + + + + + + it + <_shortDescription>Ita + <_description>Italy + ita + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + mac + <_description>Macintosh + + + + + us + <_description>US keyboard with Italian letters + + + + + geo + <_description>Georgian + geo + + + + + + + jp + <_shortDescription>Jpn + <_description>Japan + jpn + + + + + kana + <_description>Kana + + + + + kana86 + <_description>Kana 86 + + + + + OADG109A + <_description>OADG 109A + + + + + mac + <_description>Macintosh + + + + + + + kg + <_shortDescription>Kgz + <_description>Kyrgyzstan + kir + + + + + phonetic + <_description>Phonetic + + + + + + + kh + <_shortDescription>Khm + <_description>Cambodia + khm + + + + + + kz + <_shortDescription>Kaz + <_description>Kazakhstan + kaz + + + + + ruskaz + <_description>Russian with Kazakh + kaz + rus + + + + + kazrus + <_description>Kazakh with Russian + kaz + rus + + + + + + + la + <_shortDescription>Lao + <_description>Laos + lao + + + + + basic + <_description>Laos + lao + + + + + + stea + <_description>Laos - STEA (proposed standard layout) + lao + + + + + + + + latam + <_shortDescription>Esp + <_description>Latin American + + AR + BO + CL + CO + CR + CU + DO + EC + GT + HN + HT + MX + NI + PA + PE + PR + PY + SV + US + UY + VE + + spa + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + deadtilde + <_description>Include dead tilde + + + + + sundeadkeys + <_description>Sun dead keys + + + + + + + lt + <_shortDescription>Ltu + <_description>Lithuania + lit + + + + + std + <_description>Standard + + + + + us + <_description>US keyboard with Lithuanian letters + + + + + ibm + <_description>IBM (LST 1205-92) + + + + + lekp + <_description>LEKP + + + + + lekpa + <_description>LEKPa + + + + + + + lv + <_shortDescription>Lva + <_description>Latvia + lav + + + + + apostrophe + <_description>Apostrophe (') variant + + + + + tilde + <_description>Tilde (~) variant + + + + + fkey + <_description>F-letter (F) variant + + + + + + + mao + <_shortDescription>Mao + <_description>Maori + mao + + + + + + me + <_shortDescription>MNE + <_description>Montenegro + srp + + + + + cyrillic + <_description>Cyrillic + + + + + cyrillicyz + <_description>Cyrillic, Z and ZHE swapped + + + + + latinunicode + <_description>Latin unicode + + + + + latinyz + <_description>Latin qwerty + + + + + latinunicodeyz + <_description>Latin unicode qwerty + + + + + cyrillicalternatequotes + <_description>Cyrillic with guillemets + + + + + latinalternatequotes + <_description>Latin with guillemets + + + + + + + mk + <_shortDescription>Mkd + <_description>Macedonia + mkd + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + + + mt + <_shortDescription>Mlt + <_description>Malta + mlt + + + + + us + <_description>Maltese keyboard with US layout + + + + + + + mn + <_shortDescription>Mng + <_description>Mongolia + mng + + + + + + no + <_shortDescription>Nor + <_description>Norway + nor + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + smi + <_description>Northern Saami + sme + + + + + smi_nodeadkeys + <_description>Northern Saami, eliminate dead keys + sme + + + + + mac + <_description>Macintosh + + + + + mac_nodeadkeys + <_description>Macintosh, eliminate dead keys + + + + + + + pl + <_shortDescription>Pol + <_description>Poland + pol + + + + + qwertz + <_description>qwertz + + + + + dvorak + <_description>Dvorak + + + + + dvorak_quotes + <_description>Dvorak, Polish quotes on quotemark key + + + + + dvorak_altquotes + <_description>Dvorak, Polish quotes on key 1 + + + + + csb + <_description>Kashubian + csb + + + + + ru_phonetic_dvorak + <_description>Russian phonetic Dvorak + rus + + + + + dvp + <_description>Programmer Dvorak + + + + + + + pt + <_shortDescription>Prt + <_description>Portugal + por + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + sundeadkeys + <_description>Sun dead keys + + + + + mac + <_description>Macintosh + + + + + mac_nodeadkeys + <_description>Macintosh, eliminate dead keys + + + + + mac_sundeadkeys + <_description>Macintosh, Sun dead keys + + + + + nativo + <_description>Nativo + + + + + nativo-us + <_description>Nativo for USA keyboards + + + + + nativo-epo + <_description>Nativo for Esperanto + epo + + + + + + + ro + <_shortDescription>Rou + <_description>Romania + rum + + + + + cedilla + <_description>Cedilla + + + + + std + <_description>Standard + + + + + std_cedilla + <_description>Standard (Cedilla) + + + + + winkeys + <_description>Winkeys + + + + + crh_f + <_description>Crimean Tatar (Turkish F) + crh + + + + + crh_alt + <_description>Crimean Tatar (Turkish Alt-Q) + crh + + + + + crh_dobruca1 + <_description>Crimean Tatar (Dobruca-1 Q) + crh + + + + + crh_dobruca2 + <_description>Crimean Tatar (Dobruca-2 Q) + crh + + + + + + + ru + <_shortDescription>Rus + <_description>Russia + rus + + + + + phonetic + <_description>Phonetic + + + + + phonetic_winkeys + <_description>Phonetic Winkeys + + + + + typewriter + <_description>Typewriter + + + + + legacy + <_description>Legacy + + + + + typewriter-legacy + <_description>Typewriter, legacy + + + + + tt + <_description>Tatar + tat + + + + + os_legacy + <_description>Ossetian, legacy + oss + + + + + os_winkeys + <_description>Ossetian, Winkeys + oss + + + + + cv + <_description>Chuvash + chv + + + + + cv_latin + <_description>Chuvash Latin + chv + + + + + udm + <_description>Udmurt + udm + + + + + kom + <_description>Komi + kom + + + + + sah + <_description>Yakut + sah + + + + + xal + <_description>Kalmyk + xal + + + + + dos + <_description>DOS + + + + + srp + <_description>Serbian + rus + srp + + + + + bak + <_description>Bashkirian + bak + + + + + chm + <_description>Mari + chm + + + + + + + rs + <_shortDescription>SRB + <_description>Serbia + srp + + + + + yz + <_description>Z and ZHE swapped + + + + + latin + <_description>Latin + + + + + latinunicode + <_description>Latin Unicode + + + + + latinyz + <_description>Latin qwerty + + + + + latinunicodeyz + <_description>Latin Unicode qwerty + + + + + alternatequotes + <_description>With guillemets + + + + + latinalternatequotes + <_description>Latin with guillemets + + + + + rue + <_description>Pannonian Rusyn Homophonic + rue + + + + + + + si + <_shortDescription>Svn + <_description>Slovenia + slv + + + + + alternatequotes + <_description>Use guillemets for quotes + + + + + us + <_description>US keyboard with Slovenian letters + + + + + + + sk + <_shortDescription>Svk + <_description>Slovakia + slo + + + + + bksl + <_description>Extended Backslash + + + + + qwerty + <_description>qwerty + + + + + qwerty_bksl + <_description>qwerty, extended Backslash + + + + + + + es + <_shortDescription>Esp + <_description>Spain + spa + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + deadtilde + <_description>Include dead tilde + + + + + sundeadkeys + <_description>Sun dead keys + + + + + dvorak + <_description>Dvorak + + + + + ast + <_description>Asturian variant with bottom-dot H and bottom-dot L + ast + + + + + cat + <_description>Catalan variant with middle-dot L + cat + + + + + mac + <_description>Macintosh + + + + + + + se + <_shortDescription>Swe + <_description>Sweden + swe + + + + + nodeadkeys + <_description>Eliminate dead keys + + + + + dvorak + <_description>Dvorak + + + + + rus + <_description>Russian phonetic + rus + + + + + rus_nodeadkeys + <_description>Russian phonetic, eliminate dead keys + rus + + + + + smi + <_description>Northern Saami + sme + + + + + mac + <_description>Macintosh + + + + + svdvorak + <_description>Svdvorak + + + + + + + ch + <_shortDescription>Che + <_description>Switzerland + ger + gsw + + + + + legacy + <_description>Legacy + + + + + de_nodeadkeys + <_description>German, eliminate dead keys + + + + + de_sundeadkeys + <_description>German, Sun dead keys + + + + + fr + <_description>French + fra + + + + + fr_nodeadkeys + <_description>French, eliminate dead keys + fra + + + + + fr_sundeadkeys + <_description>French, Sun dead keys + fra + + + + + fr_mac + <_description>French (Macintosh) + fra + + + + + de_mac + <_description>German (Macintosh) + + + + + + + sy + <_shortDescription>Syr + <_description>Syria + syr + + + + + syc + <_description>Syriac + + + + + syc_phonetic + <_description>Syriac phonetic + + + + + ku + <_description>Kurdish, Latin Q + kur + + + + + ku_f + <_description>Kurdish, (F) + kur + + + + + ku_alt + <_description>Kurdish, Latin Alt-Q + kur + + + + + + + tj + <_shortDescription>Tjk + <_description>Tajikistan + tgk + + + + + legacy + <_description>Legacy + + + + + + + lk + <_shortDescription>Lka + <_description>Sri Lanka + sin + + + + + tam_unicode + <_description>Tamil Unicode + tam + + + + + tam_TAB + <_description>Tamil TAB Typewriter + tam + + + + + + + th + <_shortDescription>Tha + <_description>Thailand + tha + + + + + tis + <_description>TIS-820.2538 + + + + + pat + <_description>Pattachote + + + + + + + tr + <_shortDescription>Tur + <_description>Turkey + tur + + + + + f + <_description>(F) + + + + + alt + <_description>Alt-Q + + + + + sundeadkeys + <_description>Sun dead keys + + + + + ku + <_description>Kurdish, Latin Q + kur + + + + + ku_f + <_description>Kurdish, (F) + kur + + + + + ku_alt + <_description>Kurdish, Latin Alt-Q + kur + + + + + intl + <_description>International (with dead keys) + + + + + crh + <_description>Crimean Tatar (Turkish Q) + crh + + + + + crh_f + <_description>Crimean Tatar (Turkish F) + crh + + + + + crh_alt + <_description>Crimean Tatar (Turkish Alt-Q) + crh + + + + + + + ua + <_shortDescription>Ukr + <_description>Ukraine + ukr + + + + + phonetic + <_description>Phonetic + + + + + typewriter + <_description>Typewriter + + + + + winkeys + <_description>Winkeys + + + + + legacy + <_description>Legacy + + + + + rstu + + <_description>Standard RSTU + + + + + rstu_ru + + <_description>Standard RSTU on Russian layout + + + + + homophonic + <_description>Homophonic + + + + + crh + <_description>Crimean Tatar (Turkish Q) + crh + + + + + crh_f + <_description>Crimean Tatar (Turkish F) + crh + + + + + crh_alt + <_description>Crimean Tatar (Turkish Alt-Q) + crh + + + + + + + gb + <_shortDescription>GBr + <_description>United Kingdom + eng + + + + + extd + <_description>Extended - Winkeys + + + + + intl + <_description>International (with dead keys) + + + + + dvorak + <_description>Dvorak + + + + + dvorakukp + <_description>Dvorak (UK Punctuation) + + + + + mac + <_description>Macintosh + + + + + mac_intl + <_description>Macintosh (International) + + + + + colemak + <_description>Colemak + + + + + + + uz + <_shortDescription>Uzb + <_description>Uzbekistan + uzb + + + + + latin + <_description>Latin + + + + + crh + <_description>Crimean Tatar (Turkish Q) + crh + + + + + crh_f + <_description>Crimean Tatar (Turkish F) + crh + + + + + crh_alt + <_description>Crimean Tatar (Turkish Alt-Q) + crh + + + + + + + vn + <_shortDescription>Vnm + <_description>Vietnam + vie + + + + + + kr + <_shortDescription>Kor + <_description>Korea, Republic of + kor + + + + + kr104 + <_description>101/104 key Compatible + + + + + + + nec_vndr/jp + <_shortDescription>Jpn + <_description>Japan (PC-98xx Series) + JP + jpn + + + + + + ie + <_shortDescription>Irl + <_description>Ireland + eng + + + + + CloGaelach + <_description>CloGaelach + gla + + + + + UnicodeExpert + <_description>UnicodeExpert + + + + + ogam + <_description>Ogham + + + + + + ogam_is434 + <_description>Ogham IS434 + + + + + + + + pk + <_shortDescription>Pak + <_description>Pakistan + urd + + + + + urd-crulp + <_description>CRULP + urd + + + + + urd-nla + <_description>NLA + urd + + + + + ara + <_description>Arabic + ara + + + + + snd + <_description>Sindhi + sd + + + + + + + mv + <_shortDescription>Mdv + <_description>Maldives + div + + + + + + za + <_shortDescription>Zaf + <_description>South Africa + eng + + + + + epo + <_shortDescription>Epo + <_description>Esperanto + epo + + + + + legacy + <_description>displaced semicolon and quote (obsolete) + + + + + + + np + <_shortDescription>Npl + <_description>Nepal + nep + + + + + ng + <_shortDescription>Nga + <_description>Nigeria + eng + + + + + igbo + <_description>Igbo + ibo + + + + + yoruba + <_description>Yoruba + yor + + + + + hausa + <_description>Hausa + hau + + + + + + + et + <_shortDescription>Eth + <_description>Ethiopia + amh + + + + + + sn + <_shortDescription>Sen + <_description>Senegal + wol + + + + + + brai + <_shortDescription>Brl + <_description>Braille + + + + + left_hand + <_description>Left hand + + + + + right_hand + <_description>Right hand + + + + + + + tm + <_shortDescription>Tkm + <_description>Turkmenistan + tuk + + + + + alt + <_description>Alt-Q + + + + + + + ml + <_shortDescription>Mli + <_description>Mali + bam + + + + + fr-oss + <_description>Français (France Alternative) + + + + + us-mac + <_description>English (USA Macintosh) + + + + + us-intl + <_description>English (USA International) + + + + + + + tz + <_shortDescription>Tza + <_description>Tanzania + swa + + + + + ke + <_shortDescription>Ken + <_description>Kenya + swa + + + + + kik + <_description>Kikuyu + kik + + + + + + + bw + <_shortDescription>Bwa + <_description>Botswana + tsn + + + + + ph + <_shortDescription>Phi + <_description>Philippines + eng + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + qwerty-bay + <_description>QWERTY (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + capewell-dvorak + <_description>Capewell-Dvorak (Latin) + + + + + capewell-dvorak-bay + <_description>Capewell-Dvorak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + capewell-qwerf2k6 + <_description>Capewell-QWERF 2006 (Latin) + + + + + capewell-qwerf2k6-bay + <_description>Capewell-QWERF 2006 (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + colemak + <_description>Colemak (Latin) + + + + + colemak-bay + <_description>Colemak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + dvorak + <_description>Dvorak (Latin) + + + + + dvorak-bay + <_description>Dvorak (Baybayin) + bik + ceb + fil + hil + ilo + pam + pag + phi + tgl + war + + + + + + + + + + grp + <_description>Key(s) to change layout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lv3 + <_description>Key to choose 3rd level + + + + + + + + + + + + + + + + + + + + + + + ctrl + <_description>Ctrl key position + + + + + + + + + + + + + grp_led + <_description>Use keyboard LED to show alternative layout + + + + + + + + + keypad + <_description>Numeric keypad layout selection + + + + + + + + + + + + + + + kpdl + <_description>Numeric keypad delete key behaviour + + + + + + + + + + + + + + caps + <_description>Caps Lock key behavior + + + + + + + + + + + + + + + + + + + altwin + <_description>Alt/Win key behavior + + + + + + + + + + + + + + + Compose key + <_description>Compose key position + + + + + + + + + + + + + + + + compat + <_description>Miscellaneous compatibility options + + + + + + + + + + + + + + + + + + eurosign + <_description>Adding currency signs to certain keys + + + + + + + + + + lv5 + <_description>Key to choose 5th level + + + + + + + + + + + + + + + + nbsp + <_description>Using space key to input non-breakable space character + + + + + + + + + + + + + + + + + + + + + japan + <_description>Japanese keyboard options + + + + + + + esperanto + <_description>Adding Esperanto circumflexes (supersigno) + + + + + + + terminate + <_description>Key sequence to kill the X server + + + + + -- cgit v1.2.3