X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fdlist.c;h=431c4b48b7979b3c8cf00293a8b0bde3ce2152e7;hb=c4925d7f3b66d63fbdd7b7607cd809db1e58bee9;hp=0112d9dde363febaee68b4036628328fae3aec79;hpb=9a9c1e1ae1d54af6d73dbdb393d80bf5ad37f28d;p=mesa.git diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 0112d9dde36..431c4b48b79 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,6 +1,5 @@ /* * 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. @@ -18,9 +17,10 @@ * 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. + * THE AUTHORS OR COPYRIGHT HOLDERS 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. */ @@ -29,26 +29,25 @@ * Display lists management functions. */ +#include "c99_math.h" #include "glheader.h" #include "imports.h" #include "api_arrayelt.h" #include "api_exec.h" #include "api_loopback.h" -#if FEATURE_ATI_fragment_shader +#include "api_validate.h" #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 "fbobject.h" #include "framebuffer.h" #include "glapi/glapi.h" +#include "glformats.h" #include "hash.h" #include "image.h" #include "light.h" @@ -56,20 +55,22 @@ #include "pack.h" #include "pbo.h" #include "queryobj.h" +#include "samplerobj.h" +#include "shaderapi.h" +#include "syncobj.h" #include "teximage.h" +#include "texstorage.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 "transformfeedback.h" #include "math/m_matrix.h" #include "main/dispatch.h" +#include "vbo/vbo.h" + /** @@ -81,7 +82,7 @@ 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 ); + void (*Print)( struct gl_context *ctx, void *data, FILE *f ); }; @@ -123,9 +124,8 @@ do { \ */ #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" ); \ + if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \ return retval; \ } \ } while (0) @@ -138,9 +138,8 @@ do { \ */ #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" ); \ + if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \ return; \ } \ } while (0) @@ -211,18 +210,6 @@ typedef enum 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, @@ -245,7 +232,6 @@ typedef enum OPCODE_FRONT_FACE, OPCODE_FRUSTUM, OPCODE_HINT, - OPCODE_HISTOGRAM, OPCODE_INDEX_MASK, OPCODE_INIT_NAMES, OPCODE_LIGHT, @@ -262,7 +248,6 @@ typedef enum OPCODE_MAPGRID1, OPCODE_MAPGRID2, OPCODE_MATRIX_MODE, - OPCODE_MIN_MAX, OPCODE_MULT_MATRIX, OPCODE_ORTHO, OPCODE_PASSTHROUGH, @@ -283,8 +268,6 @@ typedef enum OPCODE_PUSH_NAME, OPCODE_RASTER_POS, OPCODE_READ_BUFFER, - OPCODE_RESET_HISTOGRAM, - OPCODE_RESET_MIN_MAX, OPCODE_ROTATE, OPCODE_SCALE, OPCODE_SCISSOR, @@ -319,15 +302,9 @@ typedef enum 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_BIND_PROGRAM_NV, 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 */ @@ -341,8 +318,6 @@ typedef enum /* 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 */ @@ -388,6 +363,48 @@ typedef enum OPCODE_UNIFORM_3UIV, OPCODE_UNIFORM_4UIV, + /* OpenGL 4.2 / GL_ARB_separate_shader_objects */ + OPCODE_USE_PROGRAM_STAGES, + OPCODE_PROGRAM_UNIFORM_1F, + OPCODE_PROGRAM_UNIFORM_2F, + OPCODE_PROGRAM_UNIFORM_3F, + OPCODE_PROGRAM_UNIFORM_4F, + OPCODE_PROGRAM_UNIFORM_1FV, + OPCODE_PROGRAM_UNIFORM_2FV, + OPCODE_PROGRAM_UNIFORM_3FV, + OPCODE_PROGRAM_UNIFORM_4FV, + OPCODE_PROGRAM_UNIFORM_1I, + OPCODE_PROGRAM_UNIFORM_2I, + OPCODE_PROGRAM_UNIFORM_3I, + OPCODE_PROGRAM_UNIFORM_4I, + OPCODE_PROGRAM_UNIFORM_1IV, + OPCODE_PROGRAM_UNIFORM_2IV, + OPCODE_PROGRAM_UNIFORM_3IV, + OPCODE_PROGRAM_UNIFORM_4IV, + OPCODE_PROGRAM_UNIFORM_1UI, + OPCODE_PROGRAM_UNIFORM_2UI, + OPCODE_PROGRAM_UNIFORM_3UI, + OPCODE_PROGRAM_UNIFORM_4UI, + OPCODE_PROGRAM_UNIFORM_1UIV, + OPCODE_PROGRAM_UNIFORM_2UIV, + OPCODE_PROGRAM_UNIFORM_3UIV, + OPCODE_PROGRAM_UNIFORM_4UIV, + OPCODE_PROGRAM_UNIFORM_MATRIX22F, + OPCODE_PROGRAM_UNIFORM_MATRIX33F, + OPCODE_PROGRAM_UNIFORM_MATRIX44F, + OPCODE_PROGRAM_UNIFORM_MATRIX23F, + OPCODE_PROGRAM_UNIFORM_MATRIX32F, + OPCODE_PROGRAM_UNIFORM_MATRIX24F, + OPCODE_PROGRAM_UNIFORM_MATRIX42F, + OPCODE_PROGRAM_UNIFORM_MATRIX34F, + OPCODE_PROGRAM_UNIFORM_MATRIX43F, + + /* GL_ARB_clip_control */ + OPCODE_CLIP_CONTROL, + + /* GL_ARB_color_buffer_float */ + OPCODE_CLAMP_COLOR, + /* GL_EXT_framebuffer_blit */ OPCODE_BLIT_FRAMEBUFFER, @@ -417,6 +434,10 @@ typedef enum /* GL_EXT_transform_feedback */ OPCODE_BEGIN_TRANSFORM_FEEDBACK, OPCODE_END_TRANSFORM_FEEDBACK, + OPCODE_BIND_TRANSFORM_FEEDBACK, + OPCODE_PAUSE_TRANSFORM_FEEDBACK, + OPCODE_RESUME_TRANSFORM_FEEDBACK, + OPCODE_DRAW_TRANSFORM_FEEDBACK, /* GL_EXT_texture_integer */ OPCODE_CLEARCOLOR_I, @@ -424,19 +445,53 @@ typedef enum 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, /* GL_NV_texture_barrier */ OPCODE_TEXTURE_BARRIER_NV, + /* GL_ARB_sampler_object */ + OPCODE_BIND_SAMPLER, + OPCODE_SAMPLER_PARAMETERIV, + OPCODE_SAMPLER_PARAMETERFV, + OPCODE_SAMPLER_PARAMETERIIV, + OPCODE_SAMPLER_PARAMETERUIV, + + /* GL_ARB_geometry_shader4 */ + OPCODE_PROGRAM_PARAMETERI, + OPCODE_FRAMEBUFFER_TEXTURE, + OPCODE_FRAMEBUFFER_TEXTURE_FACE, + + /* GL_ARB_sync */ + OPCODE_WAIT_SYNC, + + /* GL_NV_conditional_render */ + OPCODE_BEGIN_CONDITIONAL_RENDER, + OPCODE_END_CONDITIONAL_RENDER, + + /* ARB_timer_query */ + OPCODE_QUERY_COUNTER, + + /* ARB_transform_feedback3 */ + OPCODE_BEGIN_QUERY_INDEXED, + OPCODE_END_QUERY_INDEXED, + OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM, + + /* ARB_transform_feedback_instanced */ + OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED, + OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED, + + /* ARB_uniform_buffer_object */ + OPCODE_UNIFORM_BLOCK_BINDING, + + /* EXT_polygon_offset_clamp */ + OPCODE_POLYGON_OFFSET_CLAMP, + /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_CONTINUE, + OPCODE_NOP, /* No-op (used for 8-byte alignment */ OPCODE_END_OF_LIST, OPCODE_EXT_0 } OpCode; @@ -453,6 +508,10 @@ typedef enum * 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. + * + * Note, all of these members should be 4 bytes in size or less for the + * sake of compact display lists. We store 8-byte pointers in a pair of + * these nodes using the save/get_pointer() functions below. */ union gl_dlist_node { @@ -466,18 +525,77 @@ union gl_dlist_node GLuint ui; GLenum e; GLfloat f; - GLvoid *data; - void *next; /* If prev node's opcode==OPCODE_CONTINUE */ + GLsizei si; }; typedef union gl_dlist_node Node; +/** How many 4-byte dwords to store a pointer */ +#define POINTER_DWORDS (sizeof(void *) / 4) + +/* We want to keep sizeof(union gl_dlist_node) == 4 to minimize + * space for display lists. The following types and functions are + * used to help store 4- and 8-byte pointers in 1 or 2 dlist_nodes. + */ +union pointer +{ + void *ptr; + GLuint dwords[POINTER_DWORDS]; +}; + + /** - * How many nodes to allocate at a time. - * - * \note Reduced now that we hold vertices etc. elsewhere. + * Save a 4 or 8-byte pointer at dest (and dest+1). + */ +static inline void +save_pointer(Node *dest, void *src) +{ + union pointer p; + unsigned i; + + STATIC_ASSERT(POINTER_DWORDS == 1 || POINTER_DWORDS == 2); + STATIC_ASSERT(sizeof(Node) == 4); + + p.ptr = src; + + for (i = 0; i < POINTER_DWORDS; i++) + dest[i].ui = p.dwords[i]; +} + + +/** + * Retrieve a 4 or 8-byte pointer from node (node+1). + */ +static inline void * +get_pointer(const Node *node) +{ + union pointer p; + unsigned i; + + for (i = 0; i < POINTER_DWORDS; i++) + p.dwords[i] = node[i].ui; + + return p.ptr; +} + + +/** + * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit + * environment. + */ +union uint64_pair +{ + GLuint64 uint64; + GLuint uint32[2]; +}; + + +/** + * How many nodes to allocate at a time. Note that bulk vertex data + * from glBegin/glVertex/glEnd primitives will typically wind up in + * a VBO, and not directly in the display list itself. */ #define BLOCK_SIZE 256 @@ -490,27 +608,19 @@ typedef union gl_dlist_node Node; 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. + * Allocate a gl_display_list object with an initial block of storage. + * \param count how many display list nodes/tokes to allocate */ 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 = malloc(sizeof(Node) * count); dlist->Head[0].opcode = OPCODE_END_OF_LIST; return dlist; } @@ -519,8 +629,8 @@ make_list(GLuint name, GLuint count) /** * Lookup function to just encapsulate casting. */ -static INLINE struct gl_display_list * -lookup_list(struct gl_context *ctx, GLuint list) +struct gl_display_list * +_mesa_lookup_list(struct gl_context *ctx, GLuint list) { return (struct gl_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list); @@ -528,7 +638,7 @@ lookup_list(struct gl_context *ctx, GLuint list) /** Is the given opcode an extension code? */ -static INLINE GLboolean +static inline GLboolean is_ext_opcode(OpCode opcode) { return (opcode >= OPCODE_EXT_0); @@ -561,11 +671,11 @@ ext_opcode_execute(struct gl_context *ctx, Node *node) /** Print an extended opcode instruction */ static GLint -ext_opcode_print(struct gl_context *ctx, Node *node) +ext_opcode_print(struct gl_context *ctx, Node *node, FILE *f) { const GLint i = node[0].opcode - OPCODE_EXT_0; GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1]); + ctx->ListExt->Opcode[i].Print(ctx, &node[1], f); step = ctx->ListExt->Opcode[i].Size; return step; } @@ -595,111 +705,77 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) switch (opcode) { /* for some commands, we need to free malloc'd memory */ case OPCODE_MAP1: - free(n[6].data); + free(get_pointer(&n[6])); n += InstSize[n[0].opcode]; break; case OPCODE_MAP2: - free(n[10].data); + free(get_pointer(&n[10])); n += InstSize[n[0].opcode]; break; case OPCODE_DRAW_PIXELS: - free(n[5].data); + free(get_pointer(&n[5])); 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); + free(get_pointer(&n[7])); n += InstSize[n[0].opcode]; break; case OPCODE_POLYGON_STIPPLE: - free(n[1].data); + free(get_pointer(&n[1])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE1D: - free(n[8].data); + free(get_pointer(&n[8])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE2D: - free(n[9].data); + free(get_pointer(&n[9])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE3D: - free(n[10].data); + free(get_pointer(&n[10])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE1D: - free(n[7].data); + free(get_pointer(&n[7])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE2D: - free(n[9].data); + free(get_pointer(&n[9])); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE3D: - free(n[11].data); + free(get_pointer(&n[11])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_1D: - free(n[7].data); + free(get_pointer(&n[7])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_2D: - free(n[8].data); + free(get_pointer(&n[8])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_3D: - free(n[9].data); + free(get_pointer(&n[9])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: - free(n[7].data); + free(get_pointer(&n[7])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: - free(n[9].data); + free(get_pointer(&n[9])); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: - free(n[11].data); + free(get_pointer(&n[11])); 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 */ + free(get_pointer(&n[4])); /* program string */ n += InstSize[n[0].opcode]; break; -#endif case OPCODE_UNIFORM_1FV: case OPCODE_UNIFORM_2FV: case OPCODE_UNIFORM_3FV: @@ -712,7 +788,7 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) case OPCODE_UNIFORM_2UIV: case OPCODE_UNIFORM_3UIV: case OPCODE_UNIFORM_4UIV: - free(n[3].data); + free(get_pointer(&n[3])); n += InstSize[n[0].opcode]; break; case OPCODE_UNIFORM_MATRIX22: @@ -724,12 +800,43 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) case OPCODE_UNIFORM_MATRIX32: case OPCODE_UNIFORM_MATRIX34: case OPCODE_UNIFORM_MATRIX43: - free(n[4].data); + free(get_pointer(&n[4])); + n += InstSize[n[0].opcode]; + break; + case OPCODE_PROGRAM_UNIFORM_1FV: + case OPCODE_PROGRAM_UNIFORM_2FV: + case OPCODE_PROGRAM_UNIFORM_3FV: + case OPCODE_PROGRAM_UNIFORM_4FV: + case OPCODE_PROGRAM_UNIFORM_1IV: + case OPCODE_PROGRAM_UNIFORM_2IV: + case OPCODE_PROGRAM_UNIFORM_3IV: + case OPCODE_PROGRAM_UNIFORM_4IV: + case OPCODE_PROGRAM_UNIFORM_1UIV: + case OPCODE_PROGRAM_UNIFORM_2UIV: + case OPCODE_PROGRAM_UNIFORM_3UIV: + case OPCODE_PROGRAM_UNIFORM_4UIV: + free(get_pointer(&n[4])); + n += InstSize[n[0].opcode]; + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX22F: + case OPCODE_PROGRAM_UNIFORM_MATRIX33F: + case OPCODE_PROGRAM_UNIFORM_MATRIX44F: + case OPCODE_PROGRAM_UNIFORM_MATRIX24F: + case OPCODE_PROGRAM_UNIFORM_MATRIX42F: + case OPCODE_PROGRAM_UNIFORM_MATRIX23F: + case OPCODE_PROGRAM_UNIFORM_MATRIX32F: + case OPCODE_PROGRAM_UNIFORM_MATRIX34F: + case OPCODE_PROGRAM_UNIFORM_MATRIX43F: + free(get_pointer(&n[5])); + n += InstSize[n[0].opcode]; + break; + case OPCODE_PIXEL_MAP: + free(get_pointer(&n[3])); n += InstSize[n[0].opcode]; break; case OPCODE_CONTINUE: - n = (Node *) n[1].next; + n = (Node *) get_pointer(&n[1]); free(block); block = n; break; @@ -745,6 +852,7 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) } } + free(dlist->Label); free(dlist); } @@ -761,7 +869,7 @@ destroy_list(struct gl_context *ctx, GLuint list) if (list == 0) return; - dlist = lookup_list(ctx, list); + dlist = _mesa_lookup_list(ctx, list); if (!dlist) return; @@ -805,7 +913,7 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list) return (GLint) uiptr[n]; case GL_FLOAT: fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); + return (GLint) floorf(fptr[n]); case GL_2_BYTES: ubptr = ((GLubyte *) list) + 2 * n; return (GLint) ubptr[0] * 256 @@ -827,15 +935,13 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list) } - - -/**********************************************************************/ -/***** Public *****/ -/**********************************************************************/ - /** - * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. - * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. + * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects. + * If width < 0 or height < 0 or format or type are invalid we'll just + * return NULL. We will not generate an error since OpenGL command + * arguments aren't error-checked until the command is actually executed + * (not when they're compiled). + * But if we run out of memory, GL_OUT_OF_MEMORY will be recorded. */ static GLvoid * unpack_image(struct gl_context *ctx, GLuint dimensions, @@ -843,23 +949,35 @@ unpack_image(struct gl_context *ctx, GLuint dimensions, GLenum format, GLenum type, const GLvoid * pixels, const struct gl_pixelstore_attrib *unpack) { + if (width <= 0 || height <= 0) { + return NULL; + } + + if (_mesa_bytes_per_pixel(format, type) < 0) { + /* bad format and/or type */ + return NULL; + } + if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* no PBO */ - GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); + GLvoid *image; + + 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)) { + else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, + depth, format, type, INT_MAX, pixels)) { const GLubyte *map, *src; GLvoid *image; map = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); + ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size, + GL_MAP_READ_BIT, unpack->BufferObj, + MAP_INTERNAL); if (!map) { /* unable to map src buffer! */ _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); @@ -870,59 +988,109 @@ unpack_image(struct gl_context *ctx, GLuint dimensions, image = _mesa_unpack_image(dimensions, width, height, depth, format, type, src, unpack); - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); } return image; } + /* bad access! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "invalid PBO access"); return NULL; } +/** 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; +} + + /** * 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) + * \param align8 does the payload need to be 8-byte aligned? + * This is only relevant in 64-bit environments. + * \return pointer to allocated memory (the payload will be at pointer+1) */ static Node * -dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) +dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8) { const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); + const GLuint contNodes = 1 + POINTER_DWORDS; /* size of continue info */ + GLuint nopNode; Node *n; - if (opcode < (GLuint) OPCODE_EXT_0) { + if (opcode < OPCODE_EXT_0) { if (InstSize[opcode] == 0) { /* save instruction size now */ InstSize[opcode] = numNodes; } else { /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); + assert(numNodes == InstSize[opcode]); } } - if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { + if (sizeof(void *) > sizeof(Node) && align8 + && ctx->ListState.CurrentPos % 2 == 0) { + /* The opcode would get placed at node[0] and the payload would start + * at node[1]. But the payload needs to be at an even offset (8-byte + * multiple). + */ + nopNode = 1; + } + else { + nopNode = 0; + } + + if (ctx->ListState.CurrentPos + nopNode + numNodes + contNodes + > 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); + newblock = malloc(sizeof(Node) * BLOCK_SIZE); if (!newblock) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); return NULL; } - n[1].next = (Node *) newblock; + + /* a fresh block should be 8-byte aligned on 64-bit systems */ + assert(((GLintptr) newblock) % sizeof(void *) == 0); + + save_pointer(&n[1], newblock); ctx->ListState.CurrentBlock = newblock; ctx->ListState.CurrentPos = 0; + + /* Display list nodes are always 4 bytes. If we need 8-byte alignment + * we have to insert a NOP so that the payload of the real opcode lands + * on an even location: + * node[0] = OPCODE_NOP + * node[1] = OPCODE_x; + * node[2] = start of payload + */ + nopNode = sizeof(void *) > sizeof(Node) && align8; } n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - ctx->ListState.CurrentPos += numNodes; + if (nopNode) { + assert(ctx->ListState.CurrentPos % 2 == 0); /* even value */ + n[0].opcode = OPCODE_NOP; + n++; + /* The "real" opcode will now be at an odd location and the payload + * will be at an even location. + */ + } + ctx->ListState.CurrentPos += nopNode + numNodes; n[0].opcode = opcode; @@ -943,7 +1111,22 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) void * _mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) { - Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); + Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes, false); + if (n) + return n + 1; /* return pointer to payload area, after opcode */ + else + return NULL; +} + + +/** + * Same as _mesa_dlist_alloc(), but return a pointer which is 8-byte + * aligned in 64-bit environments, 4-byte aligned otherwise. + */ +void * +_mesa_dlist_alloc_aligned(struct gl_context *ctx, GLuint opcode, GLuint bytes) +{ + Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes, true); if (n) return n + 1; /* return pointer to payload area, after opcode */ else @@ -966,7 +1149,7 @@ _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 *)) + void (*print) (struct gl_context *, void *, FILE *)) { if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { const GLuint i = ctx->ListExt->NumOpcodes++; @@ -990,10 +1173,41 @@ _mesa_dlist_alloc_opcode(struct gl_context *ctx, * \param nparams number of function parameters * \return pointer to start of instruction space */ -static INLINE Node * +static inline Node * alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) { - return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); + return dlist_alloc(ctx, opcode, nparams * sizeof(Node), false); +} + + +/** + * Called by EndList to try to reduce memory used for the list. + */ +static void +trim_list(struct gl_context *ctx) +{ + /* If the list we're ending only has one allocated block of nodes/tokens + * and its size isn't a full block size, realloc the block to use less + * memory. This is important for apps that create many small display + * lists and apps that use glXUseXFont (many lists each containing one + * glBitmap call). + * Note: we currently only trim display lists that allocated one block + * of tokens. That hits the short list case which is what we're mainly + * concerned with. Trimming longer lists would involve traversing the + * linked list of blocks. + */ + struct gl_dlist_state *list = &ctx->ListState; + + if ((list->CurrentList->Head == list->CurrentBlock) && + (list->CurrentPos < BLOCK_SIZE)) { + /* There's only one block and it's not full, so realloc */ + GLuint newSize = list->CurrentPos * sizeof(Node); + list->CurrentList->Head = + list->CurrentBlock = realloc(list->CurrentBlock, newSize); + if (!list->CurrentBlock) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEndList"); + } + } } @@ -1060,7 +1274,7 @@ save_Bitmap(GLsizei width, GLsizei height, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BITMAP, 7); + n = alloc_instruction(ctx, OPCODE_BITMAP, 6 + POINTER_DWORDS); if (n) { n[1].i = (GLint) width; n[2].i = (GLint) height; @@ -1068,7 +1282,9 @@ save_Bitmap(GLsizei width, GLsizei height, n[4].f = yorig; n[5].f = xmove; n[6].f = ymove; - n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); + save_pointer(&n[7], + unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX, + GL_BITMAP, pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_Bitmap(ctx->Exec, (width, height, @@ -1105,7 +1321,7 @@ save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) n[2].e = modeA; } if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); + CALL_BlendEquationSeparate(ctx->Exec, (modeRGB, modeA)); } } @@ -1125,7 +1341,7 @@ save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, n[4].e = dfactorA; } if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateEXT(ctx->Exec, + CALL_BlendFuncSeparate(ctx->Exec, (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); } } @@ -1232,7 +1448,91 @@ save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA) } -static void invalidate_saved_current_state( struct gl_context *ctx ) +/* GL_ARB_draw_instanced. */ +static void GLAPIENTRY +save_DrawArraysInstancedARB(GLenum mode, + GLint first, + GLsizei count, + GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawArraysInstanced() during display list compile"); +} + +static void GLAPIENTRY +save_DrawElementsInstancedARB(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawElementsInstanced() during display list compile"); +} + +static void GLAPIENTRY +save_DrawElementsInstancedBaseVertexARB(GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices, + GLsizei primcount, + GLint basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawElementsInstancedBaseVertex() during display list compile"); +} + +/* GL_ARB_base_instance. */ +static void GLAPIENTRY +save_DrawArraysInstancedBaseInstance(GLenum mode, + GLint first, + GLsizei count, + GLsizei primcount, + GLuint baseinstance) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawArraysInstancedBaseInstance() during display list compile"); +} + +static void APIENTRY +save_DrawElementsInstancedBaseInstance(GLenum mode, + GLsizei count, + GLenum type, + const void *indices, + GLsizei primcount, + GLuint baseinstance) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawElementsInstancedBaseInstance() during display list compile"); +} + +static void APIENTRY +save_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, + GLsizei count, + GLenum type, + const void *indices, + GLsizei primcount, + GLint basevertex, + GLuint baseinstance) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawElementsInstancedBaseVertexBaseInstance() during display list compile"); +} + + +/** + * While building a display list we cache some OpenGL state. + * Under some circumstances we need to invalidate that state (immediately + * when we start compiling a list, or after glCallList(s)). + */ +static void +invalidate_saved_current_state(struct gl_context *ctx) { GLint i; @@ -1247,6 +1547,7 @@ static void invalidate_saved_current_state( struct gl_context *ctx ) ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; } + static void GLAPIENTRY save_CallList(GLuint list) { @@ -1355,7 +1656,7 @@ save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) } } if (ctx->ExecuteFlag) { - /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ + CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value)); } } @@ -1383,7 +1684,7 @@ save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) } } if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value)); } } @@ -1411,7 +1712,7 @@ save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) } } if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + CALL_ClearBufferfv(ctx->Exec, (buffer, drawbuffer, value)); } } @@ -1431,7 +1732,7 @@ save_ClearBufferfi(GLenum buffer, GLint drawbuffer, n[4].i = stencil; } if (ctx->ExecuteFlag) { - /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ + CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil)); } } @@ -1579,7 +1880,7 @@ save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, n[5].b = alpha; } if (ctx->ExecuteFlag) { - /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ + /*CALL_ColorMaski(ctx->Exec, (buf, red, green, blue, alpha));*/ } } @@ -1603,417 +1904,110 @@ save_ColorMaterial(GLenum face, GLenum mode) static void GLAPIENTRY -save_ColorTable(GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid * table) +save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) { GET_CURRENT_CONTEXT(ctx); - if (_mesa_is_proxy_texture(target)) { - /* execute immediately */ - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); + 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; } - 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)); - } + if (ctx->ExecuteFlag) { + CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); } } static void GLAPIENTRY -save_ColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat *params) +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_COLOR_TABLE_PARAMETER_FV, 6); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); 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]; - } + 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_ColorTableParameterfv(ctx->Exec, (target, pname, params)); + CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, + x, y, width, border)); } } static void GLAPIENTRY -save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +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_COLOR_TABLE_PARAMETER_IV, 6); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); 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]; - } + 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_ColorTableParameteriv(ctx->Exec, (target, pname, params)); + CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, + x, y, width, height, border)); } } static void GLAPIENTRY -save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid * table) +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_COLOR_SUB_TABLE, 6); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 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); + n[2].i = level; + n[3].i = xoffset; + n[4].i = x; + n[5].i = y; + n[6].i = width; } if (ctx->ExecuteFlag) { - CALL_ColorSubTable(ctx->Exec, - (target, start, count, format, type, table)); + CALL_CopyTexSubImage1D(ctx->Exec, + (target, level, xoffset, x, y, width)); } } static void GLAPIENTRY -save_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) +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_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); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); if (n) { n[1].e = target; n[2].i = level; @@ -2152,7 +2146,7 @@ save_DisableIndexed(GLuint index, GLenum cap) n[2].e = cap; } if (ctx->ExecuteFlag) { - CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); + CALL_Disablei(ctx->Exec, (index, cap)); } } @@ -2182,14 +2176,15 @@ save_DrawPixels(GLsizei width, GLsizei height, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); + n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 4 + POINTER_DWORDS); 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); + save_pointer(&n[5], + unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); @@ -2227,7 +2222,7 @@ save_EnableIndexed(GLuint index, GLenum cap) n[2].e = cap; } if (ctx->ExecuteFlag) { - CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); + CALL_Enablei(ctx->Exec, (index, cap)); } } @@ -2397,27 +2392,6 @@ save_Hint(GLenum target, GLenum 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) { @@ -2758,7 +2732,7 @@ save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); + n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS); if (n) { GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); n[1].e = target; @@ -2766,7 +2740,7 @@ save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, n[3].f = (GLfloat) u2; n[4].i = _mesa_evaluator_components(target); /* stride */ n[5].i = order; - n[6].data = (void *) pnts; + save_pointer(&n[6], pnts); } if (ctx->ExecuteFlag) { CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); @@ -2780,7 +2754,7 @@ save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); + n = alloc_instruction(ctx, OPCODE_MAP1, 5 + POINTER_DWORDS); if (n) { GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); n[1].e = target; @@ -2788,7 +2762,7 @@ save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, n[3].f = u2; n[4].i = _mesa_evaluator_components(target); /* stride */ n[5].i = order; - n[6].data = (void *) pnts; + save_pointer(&n[6], pnts); } if (ctx->ExecuteFlag) { CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); @@ -2805,7 +2779,7 @@ save_Map2d(GLenum target, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); + n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS); if (n) { GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, vstride, vorder, points); @@ -2819,7 +2793,7 @@ save_Map2d(GLenum target, n[7].i = _mesa_evaluator_components(target); /*vstride */ n[8].i = uorder; n[9].i = vorder; - n[10].data = (void *) pnts; + save_pointer(&n[10], pnts); } if (ctx->ExecuteFlag) { CALL_Map2d(ctx->Exec, (target, @@ -2838,7 +2812,7 @@ save_Map2f(GLenum target, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); + n = alloc_instruction(ctx, OPCODE_MAP2, 9 + POINTER_DWORDS); if (n) { GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, vstride, vorder, points); @@ -2852,7 +2826,7 @@ save_Map2f(GLenum target, n[7].i = _mesa_evaluator_components(target); /*vstride */ n[8].i = uorder; n[9].i = vorder; - n[10].data = (void *) pnts; + save_pointer(&n[10], pnts); } if (ctx->ExecuteFlag) { CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, @@ -2935,39 +2909,20 @@ save_MatrixMode(GLenum mode) static void GLAPIENTRY -save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +save_MultMatrixf(const GLfloat * m) { GET_CURRENT_CONTEXT(ctx); Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); + n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].b = sink; + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } } 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)); + CALL_MultMatrixf(ctx->Exec, (m)); } } @@ -3024,12 +2979,11 @@ 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); + n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 2 + POINTER_DWORDS); 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)); + save_pointer(&n[3], memdup(values, mapsize * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); @@ -3130,7 +3084,7 @@ save_PointParameterfvEXT(GLenum pname, const GLfloat *params) n[4].f = params[2]; } if (ctx->ExecuteFlag) { - CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); + CALL_PointParameterfv(ctx->Exec, (pname, params)); } } @@ -3204,10 +3158,11 @@ save_PolygonStipple(const GLubyte * pattern) ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); + n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, POINTER_DWORDS); if (n) { - n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - pattern, &ctx->Unpack); + save_pointer(&n[1], + unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + pattern, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); @@ -3240,6 +3195,22 @@ save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); } +static void GLAPIENTRY +save_PolygonOffsetClampEXT(GLfloat factor, GLfloat units, GLfloat clamp) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET_CLAMP, 3); + if (n) { + n[1].f = factor; + n[2].f = units; + n[3].f = clamp; + } + if (ctx->ExecuteFlag) { + CALL_PolygonOffsetClampEXT(ctx->Exec, (factor, units, clamp)); + } +} static void GLAPIENTRY save_PopAttrib(void) @@ -3534,38 +3505,6 @@ save_ReadBuffer(GLenum 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) { @@ -3647,15 +3586,16 @@ save_ShadeModel(GLenum mode) CALL_ShadeModel(ctx->Exec, (mode)); } + /* Don't compile this call if it's a no-op. + * By avoiding this state change we have a better chance of + * coalescing subsequent drawing commands into one batch. + */ 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; + ctx->ListState.Current.ShadeModel = mode; n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); if (n) { @@ -4007,7 +3947,7 @@ save_TexImage1D(GLenum target, else { Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 7 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4016,8 +3956,9 @@ save_TexImage1D(GLenum target, 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); + save_pointer(&n[8], + unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexImage1D(ctx->Exec, (target, level, components, width, @@ -4042,7 +3983,7 @@ save_TexImage2D(GLenum target, else { Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 8 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4052,8 +3993,9 @@ save_TexImage2D(GLenum target, 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); + save_pointer(&n[9], + unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexImage2D(ctx->Exec, (target, level, components, width, @@ -4080,7 +4022,7 @@ save_TexImage3D(GLenum target, else { Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 9 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4091,8 +4033,9 @@ save_TexImage3D(GLenum target, 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); + save_pointer(&n[10], + unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, @@ -4113,7 +4056,7 @@ save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 6 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4121,8 +4064,9 @@ save_TexSubImage1D(GLenum target, GLint level, GLint 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); + save_pointer(&n[7], + unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, @@ -4142,7 +4086,7 @@ save_TexSubImage2D(GLenum target, GLint level, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 8 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4152,8 +4096,9 @@ save_TexSubImage2D(GLenum target, GLint level, 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); + save_pointer(&n[9], + unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, @@ -4173,7 +4118,7 @@ save_TexSubImage3D(GLenum target, GLint level, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 10 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4185,8 +4130,9 @@ save_TexSubImage3D(GLenum target, GLint level, 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); + save_pointer(&n[11], + unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack)); } if (ctx->ExecuteFlag) { CALL_TexSubImage3D(ctx->Exec, (target, level, @@ -4414,7 +4360,7 @@ save_ActiveTextureARB(GLenum target) n[1].e = target; } if (ctx->ExecuteFlag) { - CALL_ActiveTextureARB(ctx->Exec, (target)); + CALL_ActiveTexture(ctx->Exec, (target)); } } @@ -4456,6 +4402,24 @@ save_MultTransposeMatrixfARB(const GLfloat m[16]) save_MultMatrixf(tm); } +static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func) +{ + GET_CURRENT_CONTEXT(ctx); + GLvoid *image; + + if (!data) + return NULL; + + image = malloc(size); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + return NULL; + } + memcpy(image, data, size); + + return image; +} + /* GL_ARB_texture_compression */ static void GLAPIENTRY @@ -4467,22 +4431,16 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_1D) { /* don't compile, execute immediately */ - CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, + CALL_CompressedTexImage1D(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); + + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, + 6 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4490,13 +4448,11 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, n[4].i = (GLint) width; n[5].i = border; n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); + save_pointer(&n[7], + copy_data(data, imageSize, "glCompressedTexImage1DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexImage1DARB(ctx->Exec, + CALL_CompressedTexImage1D(ctx->Exec, (target, level, internalFormat, width, border, imageSize, data)); } @@ -4513,22 +4469,16 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_2D) { /* don't compile, execute immediately */ - CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, + CALL_CompressedTexImage2D(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); + + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, + 7 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4537,13 +4487,11 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, n[5].i = (GLint) height; n[6].i = border; n[7].i = imageSize; - n[8].data = image; - } - else if (image) { - free(image); + save_pointer(&n[8], + copy_data(data, imageSize, "glCompressedTexImage2DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexImage2DARB(ctx->Exec, + CALL_CompressedTexImage2D(ctx->Exec, (target, level, internalFormat, width, height, border, imageSize, data)); } @@ -4560,22 +4508,16 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_3D) { /* don't compile, execute immediately */ - CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, + CALL_CompressedTexImage3D(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); + + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, + 8 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4585,13 +4527,11 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, n[6].i = (GLint) depth; n[7].i = border; n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); + save_pointer(&n[9], + copy_data(data, imageSize, "glCompressedTexImage3DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexImage3DARB(ctx->Exec, + CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat, width, height, depth, border, imageSize, data)); @@ -4606,19 +4546,11 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, 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); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, + 6 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4626,13 +4558,11 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, n[4].i = (GLint) width; n[5].e = format; n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); + save_pointer(&n[7], + copy_data(data, imageSize, "glCompressedTexSubImage1DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, + CALL_CompressedTexSubImage1D(ctx->Exec, (target, level, xoffset, width, format, imageSize, data)); } @@ -4646,19 +4576,11 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, 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); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, + 8 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4668,13 +4590,11 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, n[6].i = (GLint) height; n[7].e = format; n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); + save_pointer(&n[9], + copy_data(data, imageSize, "glCompressedTexSubImage2DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage2DARB(ctx->Exec, + CALL_CompressedTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, width, height, format, imageSize, data)); } @@ -4688,19 +4608,11 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, 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); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, + 10 + POINTER_DWORDS); if (n) { n[1].e = target; n[2].i = level; @@ -4712,13 +4624,11 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, n[8].i = (GLint) depth; n[9].e = format; n[10].i = imageSize; - n[11].data = image; - } - else if (image) { - free(image); + save_pointer(&n[11], + copy_data(data, imageSize, "glCompressedTexSubImage3DARB")); } if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage3DARB(ctx->Exec, + CALL_CompressedTexSubImage3D(ctx->Exec, (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data)); @@ -4739,15 +4649,14 @@ save_SampleCoverageARB(GLclampf value, GLboolean invert) n[2].b = invert; } if (ctx->ExecuteFlag) { - CALL_SampleCoverageARB(ctx->Exec, (value, invert)); + CALL_SampleCoverage(ctx->Exec, (value, invert)); } } /* - * GL_NV_vertex_program + * GL_NV_fragment_program */ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program static void GLAPIENTRY save_BindProgramNV(GLenum target, GLuint id) { @@ -4760,7 +4669,7 @@ save_BindProgramNV(GLenum target, GLuint id) n[2].ui = id; } if (ctx->ExecuteFlag) { - CALL_BindProgramNV(ctx->Exec, (target, id)); + CALL_BindProgramARB(ctx->Exec, (target, id)); } } @@ -4847,130 +4756,7 @@ save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, (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) @@ -5091,66 +4877,6 @@ save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, } } -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 @@ -5188,8 +4914,6 @@ save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - static void GLAPIENTRY save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string) @@ -5199,9 +4923,9 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); + n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 3 + POINTER_DWORDS); if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); + GLubyte *programCopy = malloc(len); if (!programCopy) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); return; @@ -5210,17 +4934,13 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, n[1].e = target; n[2].e = format; n[3].i = len; - n[4].data = programCopy; + save_pointer(&n[4], 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) @@ -5234,11 +4954,10 @@ save_BeginQueryARB(GLenum target, GLuint id) n[2].ui = id; } if (ctx->ExecuteFlag) { - CALL_BeginQueryARB(ctx->Exec, (target, id)); + CALL_BeginQuery(ctx->Exec, (target, id)); } } - static void GLAPIENTRY save_EndQueryARB(GLenum target) { @@ -5250,72 +4969,88 @@ save_EndQueryARB(GLenum target) n[1].e = target; } if (ctx->ExecuteFlag) { - CALL_EndQueryARB(ctx->Exec, (target)); + CALL_EndQuery(ctx->Exec, (target)); } } -#endif /* FEATURE_queryobj */ - - static void GLAPIENTRY -save_DrawBuffersARB(GLsizei count, const GLenum * buffers) +save_QueryCounter(GLuint id, GLenum target) { 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); + n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2); 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]; - } + n[1].ui = id; + n[2].e = target; } if (ctx->ExecuteFlag) { - CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); + CALL_QueryCounter(ctx->Exec, (id, target)); } } static void GLAPIENTRY -save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) +save_BeginQueryIndexed(GLenum target, GLuint index, GLuint id) { GET_CURRENT_CONTEXT(ctx); Node *n; - - n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_INDEXED, 3); 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]; + n[1].e = target; + n[2].ui = index; + n[3].ui = id; } if (ctx->ExecuteFlag) { - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); + CALL_BeginQueryIndexed(ctx->Exec, (target, index, id)); } } 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) +save_EndQueryIndexed(GLenum target, GLuint index) { GET_CURRENT_CONTEXT(ctx); Node *n; - - n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_END_QUERY_INDEXED, 2); + if (n) { + n[1].e = target; + n[2].ui = index; + } + if (ctx->ExecuteFlag) { + CALL_EndQueryIndexed(ctx->Exec, (target, index)); + } +} + + +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_DrawBuffers(ctx->Exec, (count, buffers)); + } +} + +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; } @@ -5342,9 +5077,8 @@ save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); } } -#endif -static void +static void GLAPIENTRY save_Attr1fNV(GLenum attr, GLfloat x) { GET_CURRENT_CONTEXT(ctx); @@ -5356,7 +5090,7 @@ save_Attr1fNV(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -5365,7 +5099,7 @@ save_Attr1fNV(GLenum attr, GLfloat x) } } -static void +static void GLAPIENTRY save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) { GET_CURRENT_CONTEXT(ctx); @@ -5378,7 +5112,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -5387,7 +5121,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) } } -static void +static void GLAPIENTRY save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) { GET_CURRENT_CONTEXT(ctx); @@ -5401,7 +5135,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -5410,7 +5144,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) } } -static void +static void GLAPIENTRY save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GET_CURRENT_CONTEXT(ctx); @@ -5425,7 +5159,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -5435,7 +5169,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) } -static void +static void GLAPIENTRY save_Attr1fARB(GLenum attr, GLfloat x) { GET_CURRENT_CONTEXT(ctx); @@ -5447,7 +5181,7 @@ save_Attr1fARB(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -5456,7 +5190,7 @@ save_Attr1fARB(GLenum attr, GLfloat x) } } -static void +static void GLAPIENTRY save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) { GET_CURRENT_CONTEXT(ctx); @@ -5469,7 +5203,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -5478,7 +5212,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) } } -static void +static void GLAPIENTRY save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) { GET_CURRENT_CONTEXT(ctx); @@ -5492,7 +5226,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -5501,7 +5235,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) } } -static void +static void GLAPIENTRY save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GET_CURRENT_CONTEXT(ctx); @@ -5516,7 +5250,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -5616,17 +5350,25 @@ save_Indexfv(const GLfloat * v) static void GLAPIENTRY save_EdgeFlag(GLboolean x) { - save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); + save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? 1.0f : 0.0f); } -static INLINE GLboolean compare4fv( const GLfloat *a, - const GLfloat *b, - GLuint count ) + +/** + * Compare 'count' elements of vectors 'a' and 'b'. + * \return GL_TRUE if equal, GL_FALSE if different. + */ +static inline GLboolean +compare_vec(const GLfloat *a, const GLfloat *b, GLuint count) { return memcmp( a, b, count * sizeof(GLfloat) ) == 0; } - + +/** + * This glMaterial function is used for glMaterial calls that are outside + * a glBegin/End pair. For glMaterial inside glBegin/End, see the VBO code. + */ static void GLAPIENTRY save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) { @@ -5641,7 +5383,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) case GL_FRONT_AND_BACK: break; default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); + _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)"); return; } @@ -5660,7 +5402,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) args = 3; break; default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); + _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)"); return; } @@ -5677,7 +5419,8 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) 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)) { + compare_vec(ctx->ListState.CurrentMaterial[i], param, args)) { + /* no change in material value */ bitmask &= ~(1 << i); } else { @@ -5687,8 +5430,7 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) } } - /* If this call has effect, return early: - */ + /* If this call has no effect, return early */ if (bitmask == 0) return; @@ -5707,29 +5449,20 @@ 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; + if (!_mesa_is_valid_prim_mode(ctx, mode)) { + /* compile this error into the display list */ + _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)"); } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentSavePrimitive = mode; + else if (_mesa_inside_dlist_begin_end(ctx)) { + /* compile this error into the display list */ + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive glBegin"); } else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } + Node *n; + + ctx->Driver.CurrentSavePrimitive = mode; - if (!error) { /* Give the driver an opportunity to hook in an optimized * display list compiler. */ @@ -5741,10 +5474,10 @@ save_Begin(GLenum mode) if (n) { n[1].e = mode; } - } - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); + if (ctx->ExecuteFlag) { + CALL_Begin(ctx->Exec, (mode)); + } } } @@ -5765,7 +5498,7 @@ save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) { GET_CURRENT_CONTEXT(ctx); Node *n; - SAVE_FLUSH_VERTICES(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = alloc_instruction(ctx, OPCODE_RECTF, 4); if (n) { n[1].f = a; @@ -5996,85 +5729,6 @@ index_error(void) } -/* 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) @@ -6149,36 +5803,6 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) 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, @@ -6201,12 +5825,11 @@ save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, n[10].e = filter; } if (ctx->ExecuteFlag) { - CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, + CALL_BlitFramebuffer(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter)); } } -#endif /** GL_EXT_provoking_vertex */ @@ -6221,8 +5844,8 @@ save_ProvokingVertexEXT(GLenum mode) n[1].e = mode; } if (ctx->ExecuteFlag) { - /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ - _mesa_ProvokingVertexEXT(mode); + /*CALL_ProvokingVertex(ctx->Exec, (mode));*/ + _mesa_ProvokingVertex(mode); } } @@ -6239,7 +5862,7 @@ save_BeginTransformFeedback(GLenum mode) n[1].e = mode; } if (ctx->ExecuteFlag) { - CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); + CALL_BeginTransformFeedback(ctx->Exec, (mode)); } } @@ -6252,10 +5875,118 @@ save_EndTransformFeedback(void) ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); if (ctx->ExecuteFlag) { - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + CALL_EndTransformFeedback(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_BindTransformFeedback(GLenum target, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2); + if (n) { + n[1].e = target; + n[2].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_BindTransformFeedback(ctx->Exec, (target, name)); + } +} + +static void GLAPIENTRY +save_PauseTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_PauseTransformFeedback(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_ResumeTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_ResumeTransformFeedback(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_DrawTransformFeedback(GLenum mode, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2); + if (n) { + n[1].e = mode; + n[2].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_DrawTransformFeedback(ctx->Exec, (mode, name)); + } +} + +static void GLAPIENTRY +save_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM, 3); + if (n) { + n[1].e = mode; + n[2].ui = name; + n[3].ui = stream; + } + if (ctx->ExecuteFlag) { + CALL_DrawTransformFeedbackStream(ctx->Exec, (mode, name, stream)); + } +} + +static void GLAPIENTRY +save_DrawTransformFeedbackInstanced(GLenum mode, GLuint name, + GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED, 3); + if (n) { + n[1].e = mode; + n[2].ui = name; + n[3].si = primcount; + } + if (ctx->ExecuteFlag) { + CALL_DrawTransformFeedbackInstanced(ctx->Exec, (mode, name, primcount)); } } +static void GLAPIENTRY +save_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name, + GLuint stream, GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED, 4); + if (n) { + n[1].e = mode; + n[2].ui = name; + n[3].ui = stream; + n[4].si = primcount; + } + if (ctx->ExecuteFlag) { + CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec, (mode, name, stream, + primcount)); + } +} /* aka UseProgram() */ static void GLAPIENTRY @@ -6269,7 +6000,7 @@ save_UseProgramObjectARB(GLhandleARB program) n[1].ui = program; } if (ctx->ExecuteFlag) { - CALL_UseProgramObjectARB(ctx->Exec, (program)); + CALL_UseProgram(ctx->Exec, (program)); } } @@ -6286,7 +6017,7 @@ save_Uniform1fARB(GLint location, GLfloat x) n[2].f = x; } if (ctx->ExecuteFlag) { - CALL_Uniform1fARB(ctx->Exec, (location, x)); + CALL_Uniform1f(ctx->Exec, (location, x)); } } @@ -6304,7 +6035,7 @@ save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) n[3].f = y; } if (ctx->ExecuteFlag) { - CALL_Uniform2fARB(ctx->Exec, (location, x, y)); + CALL_Uniform2f(ctx->Exec, (location, x, y)); } } @@ -6323,7 +6054,7 @@ save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } if (ctx->ExecuteFlag) { - CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); + CALL_Uniform3f(ctx->Exec, (location, x, y, z)); } } @@ -6343,36 +6074,25 @@ save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } if (ctx->ExecuteFlag) { - CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); + CALL_Uniform4f(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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); + save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); + CALL_Uniform1fv(ctx->Exec, (location, count, v)); } } @@ -6382,14 +6102,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); + save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); + CALL_Uniform2fv(ctx->Exec, (location, count, v)); } } @@ -6399,14 +6119,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); + save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); + CALL_Uniform3fv(ctx->Exec, (location, count, v)); } } @@ -6416,14 +6136,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); + CALL_Uniform4fv(ctx->Exec, (location, count, v)); } } @@ -6440,7 +6160,7 @@ save_Uniform1iARB(GLint location, GLint x) n[2].i = x; } if (ctx->ExecuteFlag) { - CALL_Uniform1iARB(ctx->Exec, (location, x)); + CALL_Uniform1i(ctx->Exec, (location, x)); } } @@ -6457,7 +6177,7 @@ save_Uniform2iARB(GLint location, GLint x, GLint y) n[3].i = y; } if (ctx->ExecuteFlag) { - CALL_Uniform2iARB(ctx->Exec, (location, x, y)); + CALL_Uniform2i(ctx->Exec, (location, x, y)); } } @@ -6475,7 +6195,7 @@ save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) n[4].i = z; } if (ctx->ExecuteFlag) { - CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); + CALL_Uniform3i(ctx->Exec, (location, x, y, z)); } } @@ -6494,7 +6214,7 @@ save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) n[5].i = w; } if (ctx->ExecuteFlag) { - CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); + CALL_Uniform4i(ctx->Exec, (location, x, y, z, w)); } } @@ -6506,14 +6226,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLint)); + save_pointer(&n[3], memdup(v, count * 1 * sizeof(GLint))); } if (ctx->ExecuteFlag) { - CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); + CALL_Uniform1iv(ctx->Exec, (location, count, v)); } } @@ -6523,14 +6243,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLint)); + save_pointer(&n[3], memdup(v, count * 2 * sizeof(GLint))); } if (ctx->ExecuteFlag) { - CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); + CALL_Uniform2iv(ctx->Exec, (location, count, v)); } } @@ -6540,14 +6260,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLint)); + save_pointer(&n[3], memdup(v, count * 3 * sizeof(GLint))); } if (ctx->ExecuteFlag) { - CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); + CALL_Uniform3iv(ctx->Exec, (location, count, v)); } } @@ -6557,14 +6277,14 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + save_pointer(&n[3], memdup(v, count * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); + CALL_Uniform4iv(ctx->Exec, (location, count, v)); } } @@ -6648,11 +6368,11 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(*v)); + save_pointer(&n[3], memdup(v, count * 1 * sizeof(*v))); } if (ctx->ExecuteFlag) { /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ @@ -6665,11 +6385,11 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(*v)); + save_pointer(&n[3], memdup(v, count * 2 * sizeof(*v))); } if (ctx->ExecuteFlag) { /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ @@ -6682,11 +6402,11 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(*v)); + save_pointer(&n[3], memdup(v, count * 3 * sizeof(*v))); } if (ctx->ExecuteFlag) { /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ @@ -6699,11 +6419,11 @@ 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); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 2 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(*v)); + save_pointer(&n[3], memdup(v, count * 4 * sizeof(*v))); } if (ctx->ExecuteFlag) { /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ @@ -6719,15 +6439,15 @@ save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 2 * 2 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); + CALL_UniformMatrix2fv(ctx->Exec, (location, count, transpose, m)); } } @@ -6738,15 +6458,15 @@ save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 3 * 3 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); + CALL_UniformMatrix3fv(ctx->Exec, (location, count, transpose, m)); } } @@ -6757,15 +6477,15 @@ save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 4 * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); + CALL_UniformMatrix4fv(ctx->Exec, (location, count, transpose, m)); } } @@ -6777,12 +6497,12 @@ save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 2 * 3 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); @@ -6796,12 +6516,12 @@ save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 3 * 2 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); @@ -6816,12 +6536,12 @@ save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 2 * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); @@ -6835,12 +6555,12 @@ save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 4 * 2 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); @@ -6855,12 +6575,12 @@ save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 3 * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); @@ -6874,12 +6594,12 @@ save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 3 + POINTER_DWORDS); if (n) { n[1].i = location; n[2].i = count; n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); + save_pointer(&n[4], memdup(m, count * 4 * 3 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); @@ -6887,2370 +6607,2619 @@ save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, } static void GLAPIENTRY -save_UseShaderProgramEXT(GLenum type, GLuint program) +save_UseProgramStages(GLuint pipeline, GLbitfield stages, 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); + n = alloc_instruction(ctx, OPCODE_USE_PROGRAM_STAGES, 3); if (n) { - n[1].ui = type; - n[2].ui = program; + n[1].ui = pipeline; + n[2].ui = stages; + n[3].ui = program; } if (ctx->ExecuteFlag) { - CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); + CALL_UseProgramStages(ctx->Exec, (pipeline, stages, program)); } } static void GLAPIENTRY -save_ActiveProgramEXT(GLuint program) +save_ProgramUniform1f(GLuint program, GLint location, GLfloat x) { GET_CURRENT_CONTEXT(ctx); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1F, 3); if (n) { n[1].ui = program; + n[2].i = location; + n[3].f = x; } if (ctx->ExecuteFlag) { - CALL_ActiveProgramEXT(ctx->Exec, (program)); + CALL_ProgramUniform1f(ctx->Exec, (program, location, x)); } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) +save_ProgramUniform2f(GLuint program, 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_CLEARCOLOR_I, 4); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2F, 4); if (n) { - n[1].i = red; - n[2].i = green; - n[3].i = blue; - n[4].i = alpha; + n[1].ui = program; + n[2].i = location; + n[3].f = x; + n[4].f = y; } if (ctx->ExecuteFlag) { - CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); + CALL_ProgramUniform2f(ctx->Exec, (program, location, x, y)); } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) +save_ProgramUniform3f(GLuint program, 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_CLEARCOLOR_UI, 4); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3F, 5); if (n) { - n[1].ui = red; - n[2].ui = green; - n[3].ui = blue; - n[4].ui = alpha; + n[1].ui = program; + n[2].i = location; + n[3].f = x; + n[4].f = y; + n[5].f = z; } if (ctx->ExecuteFlag) { - CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); + CALL_ProgramUniform3f(ctx->Exec, (program, location, x, y, z)); } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +save_ProgramUniform4f(GLuint program, 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_TEXPARAMETER_I, 6); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4F, 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]; + n[1].ui = program; + n[2].i = location; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; } if (ctx->ExecuteFlag) { - CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); + CALL_ProgramUniform4f(ctx->Exec, (program, location, x, y, z, w)); } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +save_ProgramUniform1fv(GLuint program, 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_TEXPARAMETER_UI, 6); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1FV, 3 + POINTER_DWORDS); 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]; + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); + CALL_ProgramUniform1fv(ctx->Exec, (program, location, count, v)); } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +save_ProgramUniform2fv(GLuint program, GLint location, GLsizei count, + const GLfloat *v) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2FV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform2fv(ctx->Exec, (program, location, count, v)); + } } -/** GL_EXT_texture_integer */ static void GLAPIENTRY -exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +save_ProgramUniform3fv(GLuint program, GLint location, GLsizei count, + const GLfloat *v) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3FV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform3fv(ctx->Exec, (program, location, count, v)); + } } - -/* GL_ARB_instanced_arrays */ -static void -save_VertexAttribDivisor(GLuint index, GLuint divisor) +static void GLAPIENTRY +save_ProgramUniform4fv(GLuint program, 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_VERTEX_ATTRIB_DIVISOR, 2); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_4FV, 3 + POINTER_DWORDS); if (n) { - n[1].ui = index; - n[2].ui = divisor; + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLfloat))); } if (ctx->ExecuteFlag) { - CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor)); + CALL_ProgramUniform4fv(ctx->Exec, (program, location, count, v)); } } - -/* GL_NV_texture_barrier */ -static void -save_TextureBarrierNV() +static void GLAPIENTRY +save_ProgramUniform1i(GLuint program, GLint location, GLint x) { GET_CURRENT_CONTEXT(ctx); + Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1I, 3); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = x; + } if (ctx->ExecuteFlag) { - CALL_TextureBarrierNV(ctx->Exec, ()); + CALL_ProgramUniform1i(ctx->Exec, (program, location, x)); } } - -/** - * 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) +static void GLAPIENTRY +save_ProgramUniform2i(GLuint program, GLint location, GLint x, GLint y) { + GET_CURRENT_CONTEXT(ctx); Node *n; - n = alloc_instruction(ctx, OPCODE_ERROR, 2); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2I, 4); if (n) { - n[1].e = error; - n[2].data = (void *) s; + n[1].ui = program; + n[2].i = location; + n[3].i = x; + n[4].i = y; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform2i(ctx->Exec, (program, location, x, y)); } } - -/** - * Compile an error into current display list. - */ -void -_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) +static void GLAPIENTRY +save_ProgramUniform3i(GLuint program, GLint location, + GLint x, GLint y, GLint z) { - if (ctx->CompileFlag) - save_error(ctx, error, s); - if (ctx->ExecuteFlag) - _mesa_error(ctx, error, "%s", s); + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_3I, 5); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = x; + n[4].i = y; + n[5].i = z; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform3i(ctx->Exec, (program, location, x, y, z)); + } } +static void GLAPIENTRY +save_ProgramUniform4i(GLuint program, 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_PROGRAM_UNIFORM_4I, 6); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = x; + n[4].i = y; + n[5].i = z; + n[6].i = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform4i(ctx->Exec, (program, location, x, y, z, w)); + } +} -/** - * Test if ID names a display list. - */ -static GLboolean -islist(struct gl_context *ctx, GLuint list) +static void GLAPIENTRY +save_ProgramUniform1iv(GLuint program, GLint location, GLsizei count, + const GLint *v) { - if (list > 0 && lookup_list(ctx, list)) { - return GL_TRUE; + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1IV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLint))); } - else { - return GL_FALSE; + if (ctx->ExecuteFlag) { + CALL_ProgramUniform1iv(ctx->Exec, (program, location, count, v)); } } +static void GLAPIENTRY +save_ProgramUniform2iv(GLuint program, 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_PROGRAM_UNIFORM_2IV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform2iv(ctx->Exec, (program, location, count, v)); + } +} +static void GLAPIENTRY +save_ProgramUniform3iv(GLuint program, 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_PROGRAM_UNIFORM_3IV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform3iv(ctx->Exec, (program, location, count, v)); + } +} -/**********************************************************************/ -/* Display list execution */ -/**********************************************************************/ +static void GLAPIENTRY +save_ProgramUniform4iv(GLuint program, 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_PROGRAM_UNIFORM_4IV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform4iv(ctx->Exec, (program, location, count, v)); + } +} +static void GLAPIENTRY +save_ProgramUniform1ui(GLuint program, GLint location, GLuint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_1UI, 3); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].ui = x; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform1ui(ctx->Exec, (program, location, x)); + } +} -/* - * 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) +static void GLAPIENTRY +save_ProgramUniform2ui(GLuint program, GLint location, GLuint x, GLuint y) { - struct gl_display_list *dlist; + GET_CURRENT_CONTEXT(ctx); Node *n; - GLboolean done; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_2UI, 4); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].ui = x; + n[4].ui = y; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform2ui(ctx->Exec, (program, location, x, y)); + } +} - if (list == 0 || !islist(ctx, list)) - return; +static void GLAPIENTRY +save_ProgramUniform3ui(GLuint program, 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_PROGRAM_UNIFORM_3UI, 5); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].ui = x; + n[4].ui = y; + n[5].ui = z; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform3ui(ctx->Exec, (program, location, x, y, z)); + } +} - if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { - /* raise an error? */ - return; +static void GLAPIENTRY +save_ProgramUniform4ui(GLuint program, 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_PROGRAM_UNIFORM_4UI, 6); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].ui = x; + n[4].ui = y; + n[5].ui = z; + n[6].ui = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform4ui(ctx->Exec, (program, location, x, y, z, w)); } +} - dlist = lookup_list(ctx, list); - if (!dlist) - return; +static void GLAPIENTRY +save_ProgramUniform1uiv(GLuint program, 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_PROGRAM_UNIFORM_1UIV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 1 * sizeof(GLuint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform1uiv(ctx->Exec, (program, location, count, v)); + } +} - ctx->ListState.CallDepth++; +static void GLAPIENTRY +save_ProgramUniform2uiv(GLuint program, 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_PROGRAM_UNIFORM_2UIV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 2 * sizeof(GLuint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform2uiv(ctx->Exec, (program, location, count, v)); + } +} - if (ctx->Driver.BeginCallList) - ctx->Driver.BeginCallList(ctx, dlist); +static void GLAPIENTRY +save_ProgramUniform3uiv(GLuint program, 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_PROGRAM_UNIFORM_3UIV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 3 * sizeof(GLuint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform3uiv(ctx->Exec, (program, location, count, v)); + } +} - n = dlist->Head; +static void GLAPIENTRY +save_ProgramUniform4uiv(GLuint program, 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_PROGRAM_UNIFORM_4UIV, 3 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + save_pointer(&n[4], memdup(v, count * 4 * sizeof(GLuint))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniform4uiv(ctx->Exec, (program, location, count, v)); + } +} - done = GL_FALSE; - while (!done) { - const OpCode opcode = n[0].opcode; +static void GLAPIENTRY +save_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX22F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 2 * 2 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix2fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - 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; +static void GLAPIENTRY +save_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX23F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 2 * 3 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix2x3fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - 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; +static void GLAPIENTRY +save_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX24F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 2 * 4 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix2x4fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - 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; +static void GLAPIENTRY +save_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX32F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 3 * 2 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix3x2fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - case OPCODE_TEX_BUMP_PARAMETER_ATI: - { - GLfloat values[4]; - GLuint i, pname = n[1].ui; +static void GLAPIENTRY +save_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX33F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 3 * 3 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix3fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - 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; +static void GLAPIENTRY +save_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX34F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 3 * 4 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix3x4fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - 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; +static void GLAPIENTRY +save_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX42F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 4 * 2 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix4x2fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - /* 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; +static void GLAPIENTRY +save_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX43F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 4 * 3 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix4x3fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - case OPCODE_VERTEX_ATTRIB_DIVISOR: - /* GL_ARB_instanced_arrays */ - CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui)); - break; +static void GLAPIENTRY +save_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, + GLboolean transpose, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_UNIFORM_MATRIX44F, + 4 + POINTER_DWORDS); + if (n) { + n[1].ui = program; + n[2].i = location; + n[3].i = count; + n[4].b = transpose; + save_pointer(&n[5], memdup(v, count * 4 * 4 * sizeof(GLfloat))); + } + if (ctx->ExecuteFlag) { + CALL_ProgramUniformMatrix4fv(ctx->Exec, + (program, location, count, transpose, v)); + } +} - case OPCODE_TEXTURE_BARRIER_NV: - CALL_TextureBarrierNV(ctx->Exec, ()); - break; +static void GLAPIENTRY +save_ClipControl(GLenum origin, GLenum depth) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLIP_CONTROL, 2); + if (n) { + n[1].e = origin; + n[2].e = depth; + } + if (ctx->ExecuteFlag) { + CALL_ClipControl(ctx->Exec, (origin, depth)); + } +} - 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; - } +static void GLAPIENTRY +save_ClampColorARB(GLenum target, GLenum clamp) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2); + if (n) { + n[1].e = target; + n[2].e = clamp; + } + if (ctx->ExecuteFlag) { + CALL_ClampColor(ctx->Exec, (target, clamp)); + } +} - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } +/** 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)); } +} - if (ctx->Driver.EndCallList) - ctx->Driver.EndCallList(ctx); +/** 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)); + } +} - ctx->ListState.CallDepth--; +/** 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_TexParameterIiv(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_TexParameterIuiv(ctx->Exec, (target, pname, params)); + } +} +/* GL_ARB_instanced_arrays */ +static void GLAPIENTRY +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_VertexAttribDivisor(ctx->Exec, (index, divisor)); + } +} -/**********************************************************************/ -/* GL functions */ -/**********************************************************************/ -/** - * Test if a display list number is valid. - */ -static GLboolean GLAPIENTRY -_mesa_IsList(GLuint list) +/* GL_NV_texture_barrier */ +static void GLAPIENTRY +save_TextureBarrierNV(void) { 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); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0); + if (ctx->ExecuteFlag) { + CALL_TextureBarrierNV(ctx->Exec, ()); + } } -/** - * Delete a sequence of consecutive display lists. - */ +/* GL_ARB_sampler_objects */ static void GLAPIENTRY -_mesa_DeleteLists(GLuint list, GLsizei range) +save_BindSampler(GLuint unit, GLuint sampler) { + Node *n; GET_CURRENT_CONTEXT(ctx); - GLuint i; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2); + if (n) { + n[1].ui = unit; + n[2].ui = sampler; + } + if (ctx->ExecuteFlag) { + CALL_BindSampler(ctx->Exec, (unit, sampler)); + } +} - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); - return; +static void GLAPIENTRY +save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + 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; + } } - for (i = list; i < list + range; i++) { - destroy_list(ctx, i); + if (ctx->ExecuteFlag) { + CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params)); } } +static void GLAPIENTRY +save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_SamplerParameteriv(sampler, pname, parray); +} -/** - * Return a display list number, n, such that lists n through n+range-1 - * are free. - */ -static GLuint GLAPIENTRY -_mesa_GenLists(GLsizei range) +static void GLAPIENTRY +save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) { + Node *n; 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; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + 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 (range == 0) { - return 0; + if (ctx->ExecuteFlag) { + CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params)); } +} - /* - * Make this an atomic operation - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); +static void GLAPIENTRY +save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_SamplerParameterfv(sampler, pname, parray); +} - 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)); +static void GLAPIENTRY +save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + 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_SamplerParameterIiv(ctx->Exec, (sampler, pname, params)); + } +} + +static void GLAPIENTRY +save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].ui = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + n[4].ui = params[1]; + n[5].ui = params[2]; + n[6].ui = params[3]; + } + else { + n[4].ui = n[5].ui = n[6].ui = 0; } } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return base; + if (ctx->ExecuteFlag) { + CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params)); + } } - -/** - * Begin a new display list. - */ +/* GL_ARB_geometry_shader4 */ static void GLAPIENTRY -_mesa_NewList(GLuint name, GLenum mode) +save_ProgramParameteri(GLuint program, GLenum pname, GLint value) { + Node *n; 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; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_PARAMETERI, 3); + if (n) { + n[1].ui = program; + n[2].e = pname; + n[3].i = value; } - - if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); - return; + if (ctx->ExecuteFlag) { + CALL_ProgramParameteri(ctx->Exec, (program, pname, value)); } +} - if (ctx->ListState.CurrentList) { - /* already compiling a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - return; +static void GLAPIENTRY +save_FramebufferTexture(GLenum target, GLenum attachment, + GLuint texture, GLint level) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE, 4); + if (n) { + n[1].e = target; + n[2].e = attachment; + n[3].ui = texture; + n[4].i = level; + } + if (ctx->ExecuteFlag) { + CALL_FramebufferTexture(ctx->Exec, (target, attachment, texture, level)); } - - 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) +save_FramebufferTextureFace(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face) { + Node *n; 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; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE_FACE, 5); + if (n) { + n[1].e = target; + n[2].e = attachment; + n[3].ui = texture; + n[4].i = level; + n[5].e = face; + } + if (ctx->ExecuteFlag) { + CALL_FramebufferTextureFaceARB(ctx->Exec, (target, attachment, texture, + level, face)); } - - /* 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) + +static void GLAPIENTRY +save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) { - GLboolean save_compile_flag; + Node *n; 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; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4); + if (n) { + union uint64_pair p; + p.uint64 = timeout; + n[1].bf = flags; + n[2].ui = p.uint32[0]; + n[3].ui = p.uint32[1]; + save_pointer(&n[4], sync); } - - 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; + if (ctx->ExecuteFlag) { + CALL_WaitSync(ctx->Exec, (sync, flags, timeout)); } +} - 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); +/** GL_NV_conditional_render */ +static void GLAPIENTRY +save_BeginConditionalRender(GLuint queryId, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_CONDITIONAL_RENDER, 2); + if (n) { + n[1].i = queryId; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BeginConditionalRender(ctx->Exec, (queryId, mode)); } } - -/** - * Execute glCallLists: call multiple display lists. - */ -void GLAPIENTRY -_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) +static void GLAPIENTRY +save_EndConditionalRender(void) { 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; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + alloc_instruction(ctx, OPCODE_END_CONDITIONAL_RENDER, 0); + if (ctx->ExecuteFlag) { + CALL_EndConditionalRender(ctx->Exec, ()); } +} - /* 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); +static void GLAPIENTRY +save_UniformBlockBinding(GLuint prog, GLuint index, GLuint binding) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_BLOCK_BINDING, 3); + if (n) { + n[1].ui = prog; + n[2].ui = index; + n[3].ui = binding; } - - 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); + if (ctx->ExecuteFlag) { + CALL_UniformBlockBinding(ctx->Exec, (prog, index, binding)); } } /** - * Set the offset added to list numbers in glCallLists. + * 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 GLAPIENTRY -_mesa_ListBase(GLuint base) +static void +save_error(struct gl_context *ctx, GLenum error, const char *s) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - ctx->List.ListBase = base; + Node *n; + n = alloc_instruction(ctx, OPCODE_ERROR, 1 + POINTER_DWORDS); + if (n) { + n[1].e = error; + save_pointer(&n[2], (void *) s); + /* note: the data/string here doesn't have to be freed in + * _mesa_delete_list() since the string is never dynamically + * allocated. + */ + } } -/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. +/** + * Compile an error into current display list. */ -static void GLAPIENTRY -exec_Finish(void) +void +_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Finish(ctx->Exec, ()); + if (ctx->CompileFlag) + save_error(ctx, error, s); + if (ctx->ExecuteFlag) + _mesa_error(ctx, error, "%s", s); } -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) +/** + * Test if ID names a display list. + */ +static GLboolean +islist(struct gl_context *ctx, GLuint list) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetBooleanv(ctx->Exec, (pname, params)); + if (list > 0 && _mesa_lookup_list(ctx, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } } -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, ()); -} +/**********************************************************************/ +/* Display list execution */ +/**********************************************************************/ -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) +/* + * 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) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetIntegerv(ctx->Exec, (pname, params)); -} + struct gl_display_list *dlist; + Node *n; + GLboolean done; -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)); -} + if (list == 0 || !islist(ctx, list)) + return; -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)); -} + if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { + /* raise an error? */ + return; + } -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)); -} + dlist = _mesa_lookup_list(ctx, list); + if (!dlist) + return; -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)); -} + ctx->ListState.CallDepth++; -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)); -} + if (ctx->Driver.BeginCallList) + ctx->Driver.BeginCallList(ctx, dlist); -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)); -} + n = dlist->Head; -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)); -} + 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 *) get_pointer(&n[2])); + 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, + get_pointer(&n[7]))); + 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_BlendEquationSeparate(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE: + CALL_BlendFuncSeparate(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_ClearBufferuiv(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_ColorMaski(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_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_Disablei(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, + get_pointer(&n[5]))); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_ENABLE: + CALL_Enable(ctx->Exec, (n[1].e)); + break; + case OPCODE_ENABLE_INDEXED: + CALL_Enablei(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_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: + STATIC_ASSERT(sizeof(Node) == sizeof(GLfloat)); + CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); + 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 *) get_pointer(&n[6]))); + } + 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 *) get_pointer(&n[10]))); + } + 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_MULT_MATRIX: + CALL_MultMatrixf(ctx->Exec, (&n[1].f)); + 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, get_pointer(&n[3]))); + 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_PointParameterfv(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, (get_pointer(&n[1]))); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_POLYGON_OFFSET: + CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POLYGON_OFFSET_CLAMP: + CALL_PolygonOffsetClampEXT(ctx->Exec, (n[1].f, n[2].f, n[3].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_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_ProvokingVertex(ctx->Exec, (n[1].e)); + 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 */ + get_pointer(&n[8]))); + 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 */ + get_pointer(&n[9]))); + 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 */ + get_pointer(&n[10]))); + 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, get_pointer(&n[7]))); + 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, + get_pointer(&n[9]))); + 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, + get_pointer(&n[11]))); + 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_ActiveTexture(ctx->Exec, (n[1].e)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + get_pointer(&n[7]))); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, get_pointer(&n[8]))); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage3D(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, + get_pointer(&n[9]))); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage1D(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].e, n[6].i, + get_pointer(&n[7]))); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage2D(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, + get_pointer(&n[9]))); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage3D(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, + get_pointer(&n[11]))); + break; + case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ + CALL_SampleCoverage(ctx->Exec, (n[1].f, n[2].b)); + break; + case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ + CALL_WindowPos3f(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_BIND_PROGRAM_NV: /* GL_ARB_vertex_program */ + CALL_BindProgramARB(ctx->Exec, (n[1].e, n[2].ui)); + break; + 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_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; + case OPCODE_PROGRAM_STRING_ARB: + CALL_ProgramStringARB(ctx->Exec, + (n[1].e, n[2].e, n[3].i, + get_pointer(&n[4]))); + break; + 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; + case OPCODE_BEGIN_QUERY_ARB: + CALL_BeginQuery(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_END_QUERY_ARB: + CALL_EndQuery(ctx->Exec, (n[1].e)); + break; + case OPCODE_QUERY_COUNTER: + CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_BEGIN_QUERY_INDEXED: + CALL_BeginQueryIndexed(ctx->Exec, (n[1].e, n[2].ui, n[3].ui)); + break; + case OPCODE_END_QUERY_INDEXED: + CALL_EndQueryIndexed(ctx->Exec, (n[1].e, n[2].ui)); + break; + 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_DrawBuffers(ctx->Exec, (n[1].i, buffers)); + } + break; + case OPCODE_BLIT_FRAMEBUFFER: + CALL_BlitFramebuffer(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; + case OPCODE_USE_PROGRAM: + CALL_UseProgram(ctx->Exec, (n[1].ui)); + break; + case OPCODE_UNIFORM_1F: + CALL_Uniform1f(ctx->Exec, (n[1].i, n[2].f)); + break; + case OPCODE_UNIFORM_2F: + CALL_Uniform2f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_UNIFORM_3F: + CALL_Uniform3f(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_UNIFORM_4F: + CALL_Uniform4f(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); + break; + case OPCODE_UNIFORM_1FV: + CALL_Uniform1fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_2FV: + CALL_Uniform2fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_3FV: + CALL_Uniform3fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_4FV: + CALL_Uniform4fv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_1I: + CALL_Uniform1i(ctx->Exec, (n[1].i, n[2].i)); + break; + case OPCODE_UNIFORM_2I: + CALL_Uniform2i(ctx->Exec, (n[1].i, n[2].i, n[3].i)); + break; + case OPCODE_UNIFORM_3I: + CALL_Uniform3i(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_UNIFORM_4I: + CALL_Uniform4i(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_UNIFORM_1IV: + CALL_Uniform1iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_2IV: + CALL_Uniform2iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_3IV: + CALL_Uniform3iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + break; + case OPCODE_UNIFORM_4IV: + CALL_Uniform4iv(ctx->Exec, (n[1].i, n[2].i, get_pointer(&n[3]))); + 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, + get_pointer(&n[3])));*/ + break; + case OPCODE_UNIFORM_2UIV: + /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, + get_pointer(&n[3])));*/ + break; + case OPCODE_UNIFORM_3UIV: + /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, + get_pointer(&n[3])));*/ + break; + case OPCODE_UNIFORM_4UIV: + /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, + get_pointer(&n[3])));*/ + break; + case OPCODE_UNIFORM_MATRIX22: + CALL_UniformMatrix2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX33: + CALL_UniformMatrix3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX44: + CALL_UniformMatrix4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX23: + CALL_UniformMatrix2x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX32: + CALL_UniformMatrix3x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX24: + CALL_UniformMatrix2x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX42: + CALL_UniformMatrix4x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX34: + CALL_UniformMatrix3x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; + case OPCODE_UNIFORM_MATRIX43: + CALL_UniformMatrix4x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, get_pointer(&n[4]))); + break; -static void GLAPIENTRY -exec_GetPixelMapfv(GLenum map, GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapfv(ctx->Exec, (map, values)); -} + case OPCODE_USE_PROGRAM_STAGES: + CALL_UseProgramStages(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui)); + break; + case OPCODE_PROGRAM_UNIFORM_1F: + CALL_ProgramUniform1f(ctx->Exec, (n[1].ui, n[2].i, n[3].f)); + break; + case OPCODE_PROGRAM_UNIFORM_2F: + CALL_ProgramUniform2f(ctx->Exec, (n[1].ui, n[2].i, n[3].f, n[4].f)); + break; + case OPCODE_PROGRAM_UNIFORM_3F: + CALL_ProgramUniform3f(ctx->Exec, (n[1].ui, n[2].i, + n[3].f, n[4].f, n[5].f)); + break; + case OPCODE_PROGRAM_UNIFORM_4F: + CALL_ProgramUniform4f(ctx->Exec, (n[1].ui, n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_PROGRAM_UNIFORM_1FV: + CALL_ProgramUniform1fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_2FV: + CALL_ProgramUniform2fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_3FV: + CALL_ProgramUniform3fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_4FV: + CALL_ProgramUniform4fv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_1I: + CALL_ProgramUniform1i(ctx->Exec, (n[1].ui, n[2].i, n[3].i)); + break; + case OPCODE_PROGRAM_UNIFORM_2I: + CALL_ProgramUniform2i(ctx->Exec, (n[1].ui, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_PROGRAM_UNIFORM_3I: + CALL_ProgramUniform3i(ctx->Exec, (n[1].ui, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_PROGRAM_UNIFORM_4I: + CALL_ProgramUniform4i(ctx->Exec, (n[1].ui, n[2].i, + n[3].i, n[4].i, n[5].i, n[6].i)); + break; + case OPCODE_PROGRAM_UNIFORM_1IV: + CALL_ProgramUniform1iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_2IV: + CALL_ProgramUniform2iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_3IV: + CALL_ProgramUniform3iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_4IV: + CALL_ProgramUniform4iv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_1UI: + CALL_ProgramUniform1ui(ctx->Exec, (n[1].ui, n[2].i, n[3].ui)); + break; + case OPCODE_PROGRAM_UNIFORM_2UI: + CALL_ProgramUniform2ui(ctx->Exec, (n[1].ui, n[2].i, + n[3].ui, n[4].ui)); + break; + case OPCODE_PROGRAM_UNIFORM_3UI: + CALL_ProgramUniform3ui(ctx->Exec, (n[1].ui, n[2].i, + n[3].ui, n[4].ui, n[5].ui)); + break; + case OPCODE_PROGRAM_UNIFORM_4UI: + CALL_ProgramUniform4ui(ctx->Exec, (n[1].ui, n[2].i, + n[3].ui, + n[4].ui, n[5].ui, n[6].ui)); + break; + case OPCODE_PROGRAM_UNIFORM_1UIV: + CALL_ProgramUniform1uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_2UIV: + CALL_ProgramUniform2uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_3UIV: + CALL_ProgramUniform3uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_4UIV: + CALL_ProgramUniform4uiv(ctx->Exec, (n[1].ui, n[2].i, n[3].i, + get_pointer(&n[4]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX22F: + CALL_ProgramUniformMatrix2fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX23F: + CALL_ProgramUniformMatrix2x3fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX24F: + CALL_ProgramUniformMatrix2x4fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX32F: + CALL_ProgramUniformMatrix3x2fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX33F: + CALL_ProgramUniformMatrix3fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX34F: + CALL_ProgramUniformMatrix3x4fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX42F: + CALL_ProgramUniformMatrix4x2fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX43F: + CALL_ProgramUniformMatrix4x3fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; + case OPCODE_PROGRAM_UNIFORM_MATRIX44F: + CALL_ProgramUniformMatrix4fv(ctx->Exec, + (n[1].ui, n[2].i, n[3].i, n[4].b, + get_pointer(&n[5]))); + break; -static void GLAPIENTRY -exec_GetPixelMapuiv(GLenum map, GLuint *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapuiv(ctx->Exec, (map, values)); -} + case OPCODE_CLIP_CONTROL: + CALL_ClipControl(ctx->Exec, (n[1].e, n[2].e)); + break; -static void GLAPIENTRY -exec_GetPixelMapusv(GLenum map, GLushort *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapusv(ctx->Exec, (map, values)); -} + case OPCODE_CLAMP_COLOR: + CALL_ClampColor(ctx->Exec, (n[1].e, n[2].e)); + break; -static void GLAPIENTRY -exec_GetPolygonStipple(GLubyte * dest) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPolygonStipple(ctx->Exec, (dest)); -} + case OPCODE_BIND_FRAGMENT_SHADER_ATI: + CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); + break; + case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: + CALL_SetFragmentShaderConstantATI(ctx->Exec, (n[1].ui, &n[2].f)); + break; + case OPCODE_ATTR_1F_NV: + CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_NV: + CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_ATTR_3F_NV: + CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_ATTR_4F_NV: + CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_ATTR_1F_ARB: + CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_ARB: + CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_ATTR_3F_ARB: + CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_ATTR_4F_ARB: + CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); + break; + case OPCODE_MATERIAL: + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].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; -static const GLubyte *GLAPIENTRY -exec_GetString(GLenum name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetString(ctx->Exec, (name)); -} + /* 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_TexParameterIiv(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_TexParameterIuiv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; -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)); -} + case OPCODE_VERTEX_ATTRIB_DIVISOR: + /* GL_ARB_instanced_arrays */ + CALL_VertexAttribDivisor(ctx->Exec, (n[1].ui, n[2].ui)); + break; -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)); -} + case OPCODE_TEXTURE_BARRIER_NV: + CALL_TextureBarrierNV(ctx->Exec, ()); + break; -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)); -} + /* GL_EXT/ARB_transform_feedback */ + case OPCODE_BEGIN_TRANSFORM_FEEDBACK: + CALL_BeginTransformFeedback(ctx->Exec, (n[1].e)); + break; + case OPCODE_END_TRANSFORM_FEEDBACK: + CALL_EndTransformFeedback(ctx->Exec, ()); + break; + case OPCODE_BIND_TRANSFORM_FEEDBACK: + CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_PAUSE_TRANSFORM_FEEDBACK: + CALL_PauseTransformFeedback(ctx->Exec, ()); + break; + case OPCODE_RESUME_TRANSFORM_FEEDBACK: + CALL_ResumeTransformFeedback(ctx->Exec, ()); + break; + case OPCODE_DRAW_TRANSFORM_FEEDBACK: + CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM: + CALL_DrawTransformFeedbackStream(ctx->Exec, + (n[1].e, n[2].ui, n[3].ui)); + break; + case OPCODE_DRAW_TRANSFORM_FEEDBACK_INSTANCED: + CALL_DrawTransformFeedbackInstanced(ctx->Exec, + (n[1].e, n[2].ui, n[3].si)); + break; + case OPCODE_DRAW_TRANSFORM_FEEDBACK_STREAM_INSTANCED: + CALL_DrawTransformFeedbackStreamInstanced(ctx->Exec, + (n[1].e, n[2].ui, n[3].ui, n[4].si)); + break; -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)); -} + case OPCODE_BIND_SAMPLER: + CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui)); + break; + case OPCODE_SAMPLER_PARAMETERIV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERFV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERIIV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERUIV: + { + GLuint params[4]; + params[0] = n[3].ui; + params[1] = n[4].ui; + params[2] = n[5].ui; + params[3] = n[6].ui; + CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; -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)); -} + /* GL_ARB_geometry_shader4 */ + case OPCODE_PROGRAM_PARAMETERI: + CALL_ProgramParameteri(ctx->Exec, (n[1].ui, n[2].e, n[3].i)); + break; + case OPCODE_FRAMEBUFFER_TEXTURE: + CALL_FramebufferTexture(ctx->Exec, (n[1].e, n[2].e, + n[3].ui, n[4].i)); + break; + case OPCODE_FRAMEBUFFER_TEXTURE_FACE: + CALL_FramebufferTextureFaceARB(ctx->Exec, (n[1].e, n[2].e, + n[3].ui, n[4].i, n[5].e)); + break; -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)); -} + /* GL_ARB_sync */ + case OPCODE_WAIT_SYNC: + { + union uint64_pair p; + p.uint32[0] = n[2].ui; + p.uint32[1] = n[3].ui; + CALL_WaitSync(ctx->Exec, + (get_pointer(&n[4]), n[1].bf, p.uint64)); + } + break; -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)); -} + /* GL_NV_conditional_render */ + case OPCODE_BEGIN_CONDITIONAL_RENDER: + CALL_BeginConditionalRender(ctx->Exec, (n[1].i, n[2].e)); + break; + case OPCODE_END_CONDITIONAL_RENDER: + CALL_EndConditionalRender(ctx->Exec, ()); + break; -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)); -} + case OPCODE_UNIFORM_BLOCK_BINDING: + CALL_UniformBlockBinding(ctx->Exec, (n[1].ui, n[2].ui, n[3].ui)); + break; -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)); -} + case OPCODE_CONTINUE: + n = (Node *) get_pointer(&n[1]); + break; + case OPCODE_NOP: + /* no-op */ + 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; + } -static GLboolean GLAPIENTRY -exec_IsEnabled(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsEnabled(ctx->Exec, (cap)); -} + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } -static void GLAPIENTRY -exec_PixelStoref(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStoref(ctx->Exec, (pname, param)); -} + if (ctx->Driver.EndCallList) + ctx->Driver.EndCallList(ctx); -static void GLAPIENTRY -exec_PixelStorei(GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStorei(ctx->Exec, (pname, param)); + ctx->ListState.CallDepth--; } -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)); -} +/**********************************************************************/ +/* GL functions */ +/**********************************************************************/ -static void GLAPIENTRY -exec_SelectBuffer(GLsizei size, GLuint * buffer) +/** + * Test if a display list number is valid. + */ +GLboolean GLAPIENTRY +_mesa_IsList(GLuint list) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SelectBuffer(ctx->Exec, (size, buffer)); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + return islist(ctx, list); } -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) +/** + * Delete a sequence of consecutive display lists. + */ +void GLAPIENTRY +_mesa_DeleteLists(GLuint list, GLsizei range) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); -} + GLuint i; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); -static void GLAPIENTRY -exec_DeleteTextures(GLsizei n, const GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DeleteTextures(ctx->Exec, (n, texName)); + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); + return; + } + for (i = list; i < list + range; i++) { + destroy_list(ctx, i); + } } -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) +/** + * Return a display list number, n, such that lists n through n+range-1 + * are free. + */ +GLuint GLAPIENTRY +_mesa_GenLists(GLsizei range) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); -} + GLuint base; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); -static void GLAPIENTRY -exec_EnableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EnableClientState(ctx->Exec, (cap)); -} + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); + return 0; + } + if (range == 0) { + return 0; + } -static void GLAPIENTRY -exec_GenTextures(GLsizei n, GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GenTextures(ctx->Exec, (n, texName)); -} + /* + * Make this an atomic operation + */ + mtx_lock(&ctx->Shared->Mutex); -static void GLAPIENTRY -exec_GetPointerv(GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPointerv(ctx->Exec, (pname, params)); -} + 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)); + } + } -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)); -} + mtx_unlock(&ctx->Shared->Mutex); -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)); + return base; } -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) +/** + * Begin a new display list. + */ +void GLAPIENTRY +_mesa_NewList(GLuint name, GLenum mode) { 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, ()); -} + FLUSH_CURRENT(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); -static void GLAPIENTRY -exec_PushClientAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PushClientAttrib(ctx->Exec, (mask)); -} + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glNewList %u %s\n", name, + _mesa_lookup_enum_by_nr(mode)); -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)); -} + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); + return; + } -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)); -} + if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); + return; + } -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)); -} + if (ctx->ListState.CurrentList) { + /* already compiling a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + return; + } -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)); -} + ctx->CompileFlag = GL_TRUE; + ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); -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)); -} + /* Reset accumulated list state */ + invalidate_saved_current_state( ctx ); -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)); -} + /* Allocate new display list */ + ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); + ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; + ctx->ListState.CurrentPos = 0; -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)); -} + ctx->Driver.NewList(ctx, name, mode); -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)); + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); } -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) +/** + * End definition of current display list. + */ +void GLAPIENTRY +_mesa_EndList(void) { GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(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)); -} + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndList\n"); -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)); -} + if (ctx->ExecuteFlag && _mesa_inside_dlist_begin_end(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndList() called inside glBegin/End"); + } + + /* 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); + + trim_list(ctx); + + /* 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); -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)); -} + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) + mesa_print_display_list(ctx->ListState.CurrentList->Name); -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)); -} + ctx->ListState.CurrentList = NULL; + ctx->ListState.CurrentBlock = NULL; + ctx->ListState.CurrentPos = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; -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)); + ctx->CurrentDispatch = ctx->Exec; + _glapi_set_dispatch(ctx->CurrentDispatch); } -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) +void GLAPIENTRY +_mesa_CallList(GLuint list) { + GLboolean save_compile_flag; GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetSeparableFilter(ctx->Exec, - (target, format, type, row, column, span)); -} + FLUSH_CURRENT(ctx, 0); -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)); -} + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallList %d\n", list); -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)); -} + if (list == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); + return; + } -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)); -} + if (0) + mesa_print_display_list( list ); -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)); -} + /* 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; + } -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)); -} + execute_list(ctx, list); + ctx->CompileFlag = save_compile_flag; -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)); + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } } -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) +/** + * Execute glCallLists: call multiple display lists. + */ +void GLAPIENTRY +_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_LockArraysEXT(ctx->Exec, (first, count)); -} + GLint i; + GLboolean save_compile_flag; -static void GLAPIENTRY -exec_UnlockArraysEXT(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_UnlockArraysEXT(ctx->Exec, ()); -} + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallLists %d\n", n); -static void GLAPIENTRY -exec_ClientActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ClientActiveTextureARB(ctx->Exec, (target)); -} + 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; + } -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)); -} + /* Save the CompileFlag status, turn it off, execute display list, + * and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; -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)); -} + for (i = 0; i < n; i++) { + GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); + execute_list(ctx, list); + } -/* 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)); -} + ctx->CompileFlag = save_compile_flag; -/* 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)); + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } } -/* 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) + +/** + * Set the offset added to list numbers in glCallLists. + */ +void GLAPIENTRY +_mesa_ListBase(GLuint base) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawElementsIBM(ctx->Exec, - (mode, count, type, indices, primcount, - modestride)); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + ctx->List.ListBase = base; } - - /** * Setup the given dispatch table to point to Mesa's display list * building functions. @@ -9259,16 +9228,22 @@ exec_MultiModeDrawElementsIBM(const GLenum * mode, * initialized from _mesa_init_api_defaults and from the active vtxfmt * struct. */ -struct _glapi_table * -_mesa_create_save_table(void) +void +_mesa_initialize_save_table(const struct gl_context *ctx) { - struct _glapi_table *table; + struct _glapi_table *table = ctx->Save; + int numEntries = MAX2(_gloffset_COUNT, _glapi_get_dispatch_table_size()); - table = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (table == NULL) - return NULL; + /* Initially populate the dispatch table with the contents of the + * normal-execution dispatch table. This lets us skip populating functions + * that should be called directly instead of compiled into display lists. + */ + memcpy(table, ctx->Exec, numEntries * sizeof(_glapi_proc)); + + _mesa_loopback_init_api_table(ctx, table); - _mesa_loopback_init_api_table(table); + /* VBO functions */ + vbo_initialize_save_dispatch(ctx, table); /* GL 1.0 */ SET_Accum(table, save_Accum); @@ -9285,65 +9260,30 @@ _mesa_create_save_table(void) SET_ClearStencil(table, save_ClearStencil); SET_ClipPlane(table, save_ClipPlane); SET_ColorMask(table, save_ColorMask); - SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); + SET_ColorMaski(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_Disablei(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_Enablei(table, save_EnableIndexed); 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); @@ -9377,8 +9317,6 @@ _mesa_create_save_table(void) 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); @@ -9417,15 +9355,12 @@ _mesa_create_save_table(void) 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_Rectf(table, save_Rectf); 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); @@ -9451,30 +9386,14 @@ _mesa_create_save_table(void) 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); @@ -9493,38 +9412,6 @@ _mesa_create_save_table(void) /* 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 @@ -9541,68 +9428,35 @@ _mesa_create_save_table(void) 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); + SET_PointParameterf(table, save_PointParameterfEXT); + SET_PointParameterfv(table, save_PointParameterfvEXT); /* 173. GL_EXT_blend_func_separate */ - SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); - - /* 196. GL_MESA_resize_buffers */ - SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); + SET_BlendFuncSeparate(table, save_BlendFuncSeparateEXT); /* 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_WindowPos2d(table, save_WindowPos2dMESA); + SET_WindowPos2dv(table, save_WindowPos2dvMESA); + SET_WindowPos2f(table, save_WindowPos2fMESA); + SET_WindowPos2fv(table, save_WindowPos2fvMESA); + SET_WindowPos2i(table, save_WindowPos2iMESA); + SET_WindowPos2iv(table, save_WindowPos2ivMESA); + SET_WindowPos2s(table, save_WindowPos2sMESA); + SET_WindowPos2sv(table, save_WindowPos2svMESA); + SET_WindowPos3d(table, save_WindowPos3dMESA); + SET_WindowPos3dv(table, save_WindowPos3dvMESA); + SET_WindowPos3f(table, save_WindowPos3fMESA); + SET_WindowPos3fv(table, save_WindowPos3fvMESA); + SET_WindowPos3i(table, save_WindowPos3iMESA); + SET_WindowPos3iv(table, save_WindowPos3ivMESA); + SET_WindowPos3s(table, save_WindowPos3sMESA); + SET_WindowPos3sv(table, save_WindowPos3svMESA); SET_WindowPos4dMESA(table, save_WindowPos4dMESA); SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); SET_WindowPos4fMESA(table, save_WindowPos4fMESA); @@ -9612,110 +9466,46 @@ _mesa_create_save_table(void) 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); + SET_BindProgramARB(table, save_BindProgramNV); /* 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); + SET_PointParameteri(table, save_PointParameteriNV); + SET_PointParameteriv(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); + SET_ActiveTexture(table, save_ActiveTextureARB); /* 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); + SET_LoadTransposeMatrixd(table, save_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixf(table, save_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixd(table, save_MultTransposeMatrixdARB); + SET_MultTransposeMatrixf(table, save_MultTransposeMatrixfARB); /* ARB 5. GL_ARB_multisample */ - SET_SampleCoverageARB(table, save_SampleCoverageARB); + SET_SampleCoverage(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); + SET_CompressedTexImage3D(table, save_CompressedTexImage3DARB); + SET_CompressedTexImage2D(table, save_CompressedTexImage2DARB); + SET_CompressedTexImage1D(table, save_CompressedTexImage1DARB); + SET_CompressedTexSubImage3D(table, save_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2D(table, save_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1D(table, save_CompressedTexSubImage1DARB); /* ARB 14. GL_ARB_point_parameters */ /* aliased with EXT_point_parameters functions */ @@ -9725,20 +9515,9 @@ _mesa_create_save_table(void) /* 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_BindProgramARB(table, save_BindProgramNV); SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); @@ -9747,69 +9526,35 @@ _mesa_create_save_table(void) 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_BeginQuery(table, save_BeginQueryARB); + SET_EndQuery(table, save_EndQueryARB); + SET_QueryCounter(table, save_QueryCounter); + + SET_DrawBuffers(table, save_DrawBuffersARB); + + SET_BlitFramebuffer(table, save_BlitFramebufferEXT); + + SET_UseProgram(table, save_UseProgramObjectARB); + SET_Uniform1f(table, save_Uniform1fARB); + SET_Uniform2f(table, save_Uniform2fARB); + SET_Uniform3f(table, save_Uniform3fARB); + SET_Uniform4f(table, save_Uniform4fARB); + SET_Uniform1fv(table, save_Uniform1fvARB); + SET_Uniform2fv(table, save_Uniform2fvARB); + SET_Uniform3fv(table, save_Uniform3fvARB); + SET_Uniform4fv(table, save_Uniform4fvARB); + SET_Uniform1i(table, save_Uniform1iARB); + SET_Uniform2i(table, save_Uniform2iARB); + SET_Uniform3i(table, save_Uniform3iARB); + SET_Uniform4i(table, save_Uniform4iARB); + SET_Uniform1iv(table, save_Uniform1ivARB); + SET_Uniform2iv(table, save_Uniform2ivARB); + SET_Uniform3iv(table, save_Uniform3ivARB); + SET_Uniform4iv(table, save_Uniform4ivARB); + SET_UniformMatrix2fv(table, save_UniformMatrix2fvARB); + SET_UniformMatrix3fv(table, save_UniformMatrix3fvARB); + SET_UniformMatrix4fv(table, save_UniformMatrix4fvARB); SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); @@ -9817,63 +9562,34 @@ _mesa_create_save_table(void) 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); + SET_BlendEquationSeparate(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 + SET_ProvokingVertex(table, save_ProvokingVertexEXT); /* 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); + SET_TexParameterIiv(table, save_TexParameterIiv); + SET_TexParameterIuiv(table, save_TexParameterIuiv); + + /* GL_ARB_clip_control */ + SET_ClipControl(table, save_ClipControl); - /* 377. GL_EXT_separate_shader_objects */ - SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); - SET_ActiveProgramEXT(table, save_ActiveProgramEXT); + /* GL_ARB_color_buffer_float */ + SET_ClampColor(table, save_ClampColorARB); /* 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); +#if 0 SET_Uniform1ui(table, save_Uniform1ui); SET_Uniform2ui(table, save_Uniform2ui); SET_Uniform3ui(table, save_Uniform3ui); @@ -9883,10 +9599,6 @@ _mesa_create_save_table(void) 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; @@ -9897,19 +9609,106 @@ _mesa_create_save_table(void) (void) save_Uniform4uiv; #endif + /* These are: */ + SET_BeginTransformFeedback(table, save_BeginTransformFeedback); + SET_EndTransformFeedback(table, save_EndTransformFeedback); + SET_BindTransformFeedback(table, save_BindTransformFeedback); + SET_PauseTransformFeedback(table, save_PauseTransformFeedback); + SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback); + SET_DrawTransformFeedback(table, save_DrawTransformFeedback); + SET_DrawTransformFeedbackStream(table, save_DrawTransformFeedbackStream); + SET_DrawTransformFeedbackInstanced(table, + save_DrawTransformFeedbackInstanced); + SET_DrawTransformFeedbackStreamInstanced(table, + save_DrawTransformFeedbackStreamInstanced); + SET_BeginQueryIndexed(table, save_BeginQueryIndexed); + SET_EndQueryIndexed(table, save_EndQueryIndexed); + /* GL_ARB_instanced_arrays */ - SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor); + SET_VertexAttribDivisor(table, save_VertexAttribDivisor); /* GL_NV_texture_barrier */ SET_TextureBarrierNV(table, save_TextureBarrierNV); + SET_BindSampler(table, save_BindSampler); + SET_SamplerParameteri(table, save_SamplerParameteri); + SET_SamplerParameterf(table, save_SamplerParameterf); + SET_SamplerParameteriv(table, save_SamplerParameteriv); + SET_SamplerParameterfv(table, save_SamplerParameterfv); + SET_SamplerParameterIiv(table, save_SamplerParameterIiv); + SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv); + /* 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; + /* GL_ARB_geometry_shader4 */ + SET_ProgramParameteri(table, save_ProgramParameteri); + SET_FramebufferTexture(table, save_FramebufferTexture); + SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace); + + /* GL_NV_conditional_render */ + SET_BeginConditionalRender(table, save_BeginConditionalRender); + SET_EndConditionalRender(table, save_EndConditionalRender); + + /* GL_ARB_sync */ + SET_WaitSync(table, save_WaitSync); + + /* GL_ARB_uniform_buffer_object */ + SET_UniformBlockBinding(table, save_UniformBlockBinding); + + /* GL_ARB_draw_instanced */ + SET_DrawArraysInstancedARB(table, save_DrawArraysInstancedARB); + SET_DrawElementsInstancedARB(table, save_DrawElementsInstancedARB); + + /* GL_ARB_draw_elements_base_vertex */ + SET_DrawElementsInstancedBaseVertex(table, save_DrawElementsInstancedBaseVertexARB); + + /* GL_ARB_base_instance */ + SET_DrawArraysInstancedBaseInstance(table, save_DrawArraysInstancedBaseInstance); + SET_DrawElementsInstancedBaseInstance(table, save_DrawElementsInstancedBaseInstance); + SET_DrawElementsInstancedBaseVertexBaseInstance(table, save_DrawElementsInstancedBaseVertexBaseInstance); + + /* OpenGL 4.2 / GL_ARB_separate_shader_objects */ + SET_UseProgramStages(table, save_UseProgramStages); + SET_ProgramUniform1f(table, save_ProgramUniform1f); + SET_ProgramUniform2f(table, save_ProgramUniform2f); + SET_ProgramUniform3f(table, save_ProgramUniform3f); + SET_ProgramUniform4f(table, save_ProgramUniform4f); + SET_ProgramUniform1fv(table, save_ProgramUniform1fv); + SET_ProgramUniform2fv(table, save_ProgramUniform2fv); + SET_ProgramUniform3fv(table, save_ProgramUniform3fv); + SET_ProgramUniform4fv(table, save_ProgramUniform4fv); + SET_ProgramUniform1i(table, save_ProgramUniform1i); + SET_ProgramUniform2i(table, save_ProgramUniform2i); + SET_ProgramUniform3i(table, save_ProgramUniform3i); + SET_ProgramUniform4i(table, save_ProgramUniform4i); + SET_ProgramUniform1iv(table, save_ProgramUniform1iv); + SET_ProgramUniform2iv(table, save_ProgramUniform2iv); + SET_ProgramUniform3iv(table, save_ProgramUniform3iv); + SET_ProgramUniform4iv(table, save_ProgramUniform4iv); + SET_ProgramUniform1ui(table, save_ProgramUniform1ui); + SET_ProgramUniform2ui(table, save_ProgramUniform2ui); + SET_ProgramUniform3ui(table, save_ProgramUniform3ui); + SET_ProgramUniform4ui(table, save_ProgramUniform4ui); + SET_ProgramUniform1uiv(table, save_ProgramUniform1uiv); + SET_ProgramUniform2uiv(table, save_ProgramUniform2uiv); + SET_ProgramUniform3uiv(table, save_ProgramUniform3uiv); + SET_ProgramUniform4uiv(table, save_ProgramUniform4uiv); + SET_ProgramUniformMatrix2fv(table, save_ProgramUniformMatrix2fv); + SET_ProgramUniformMatrix3fv(table, save_ProgramUniformMatrix3fv); + SET_ProgramUniformMatrix4fv(table, save_ProgramUniformMatrix4fv); + SET_ProgramUniformMatrix2x3fv(table, save_ProgramUniformMatrix2x3fv); + SET_ProgramUniformMatrix3x2fv(table, save_ProgramUniformMatrix3x2fv); + SET_ProgramUniformMatrix2x4fv(table, save_ProgramUniformMatrix2x4fv); + SET_ProgramUniformMatrix4x2fv(table, save_ProgramUniformMatrix4x2fv); + SET_ProgramUniformMatrix3x4fv(table, save_ProgramUniformMatrix3x4fv); + SET_ProgramUniformMatrix4x3fv(table, save_ProgramUniformMatrix4x3fv); + + /* GL_EXT_polygon_offset_clamp */ + SET_PolygonOffsetClampEXT(table, save_PolygonOffsetClampEXT); } @@ -9924,227 +9723,229 @@ enum_string(GLenum k) /** * Print the commands in a display list. For debugging only. * TODO: many commands aren't handled yet. + * \param fname filename to write display list to. If null, use stdout. */ static void GLAPIENTRY -print_list(struct gl_context *ctx, GLuint list) +print_list(struct gl_context *ctx, GLuint list, const char *fname) { struct gl_display_list *dlist; Node *n; GLboolean done; + FILE *f = stdout; + + if (fname) { + f = fopen(fname, "w"); + if (!f) + return; + } if (!islist(ctx, list)) { - printf("%u is not a display list ID\n", list); + fprintf(f, "%u is not a display list ID\n", list); return; } - dlist = lookup_list(ctx, list); + dlist = _mesa_lookup_list(ctx, list); if (!dlist) return; n = dlist->Head; - printf("START-LIST %u, address %p\n", list, (void *) n); + fprintf(f, "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); + n += ext_opcode_print(ctx, n, f); } else { switch (opcode) { case OPCODE_ACCUM: - printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); + fprintf(f, "Accum %s %g\n", enum_string(n[1].e), n[2].f); + break; + case OPCODE_ACTIVE_TEXTURE: + fprintf(f, "ActiveTexture(%s)\n", enum_string(n[1].e)); 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); + fprintf(f, "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, + get_pointer(&n[7])); break; case OPCODE_CALL_LIST: - printf("CallList %d\n", (int) n[1].ui); + fprintf(f, "CallList %d\n", (int) n[1].ui); break; case OPCODE_CALL_LIST_OFFSET: - printf("CallList %d + offset %u = %u\n", (int) n[1].ui, + fprintf(f, "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)); + fprintf(f, "Disable %s\n", enum_string(n[1].e)); break; case OPCODE_ENABLE: - printf("Enable %s\n", enum_string(n[1].e)); + fprintf(f, "Enable %s\n", enum_string(n[1].e)); break; case OPCODE_FRUSTUM: - printf("Frustum %g %g %g %g %g %g\n", + fprintf(f, "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); + fprintf(f, "LineStipple %d %x\n", n[1].i, (int) n[2].us); break; case OPCODE_LOAD_IDENTITY: - printf("LoadIdentity\n"); + fprintf(f, "LoadIdentity\n"); break; case OPCODE_LOAD_MATRIX: - printf("LoadMatrix\n"); - printf(" %8f %8f %8f %8f\n", + fprintf(f, "LoadMatrix\n"); + fprintf(f, " %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %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", + fprintf(f, "MultMatrix (or Rotate)\n"); + fprintf(f, " %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", + fprintf(f, " %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", + fprintf(f, "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"); + fprintf(f, "PopAttrib\n"); break; case OPCODE_POP_MATRIX: - printf("PopMatrix\n"); + fprintf(f, "PopMatrix\n"); break; case OPCODE_POP_NAME: - printf("PopName\n"); + fprintf(f, "PopName\n"); break; case OPCODE_PUSH_ATTRIB: - printf("PushAttrib %x\n", n[1].bf); + fprintf(f, "PushAttrib %x\n", n[1].bf); break; case OPCODE_PUSH_MATRIX: - printf("PushMatrix\n"); + fprintf(f, "PushMatrix\n"); break; case OPCODE_PUSH_NAME: - printf("PushName %d\n", (int) n[1].ui); + fprintf(f, "PushName %d\n", (int) n[1].ui); break; case OPCODE_RASTER_POS: - printf("RasterPos %g %g %g %g\n", + fprintf(f, "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", + fprintf(f, "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); + fprintf(f, "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); + fprintf(f, "Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); break; case OPCODE_BIND_TEXTURE: - printf("BindTexture %s %d\n", + fprintf(f, "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)); + fprintf(f, "ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); break; case OPCODE_MAP1: - printf("Map1 %s %.3f %.3f %d %d\n", + fprintf(f, "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", + fprintf(f, "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); + fprintf(f, "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", + fprintf(f, "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); + fprintf(f, "EvalMesh1 %d %d\n", n[1].i, n[2].i); break; case OPCODE_EVALMESH2: - printf("EvalMesh2 %d %d %d %d\n", + fprintf(f, "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); + fprintf(f, "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", + fprintf(f, "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", + fprintf(f, "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", + fprintf(f, "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); + fprintf(f, "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", + fprintf(f, "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", + fprintf(f, "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", + fprintf(f, "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", + fprintf(f, "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); + fprintf(f, "BEGIN %x\n", n[1].i); break; case OPCODE_END: - printf("END\n"); + fprintf(f, "END\n"); break; case OPCODE_RECTF: - printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, + fprintf(f, "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); + fprintf(f, "EVAL_C1 %f\n", n[1].f); break; case OPCODE_EVAL_C2: - printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); + fprintf(f, "EVAL_C2 %f %f\n", n[1].f, n[2].f); break; case OPCODE_EVAL_P1: - printf("EVAL_P1 %d\n", n[1].i); + fprintf(f, "EVAL_P1 %d\n", n[1].i); break; case OPCODE_EVAL_P2: - printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); + fprintf(f, "EVAL_P2 %d %d\n", n[1].i, n[2].i); break; case OPCODE_PROVOKING_VERTEX: - printf("ProvokingVertex %s\n", + fprintf(f, "ProvokingVertex %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); break; @@ -10152,15 +9953,18 @@ print_list(struct gl_context *ctx, GLuint list) * meta opcodes/commands */ case OPCODE_ERROR: - printf("Error: %s %s\n", - enum_string(n[1].e), (const char *) n[2].data); + fprintf(f, "Error: %s %s\n", enum_string(n[1].e), + (const char *) get_pointer(&n[2])); break; case OPCODE_CONTINUE: - printf("DISPLAY-LIST-CONTINUE\n"); - n = (Node *) n[1].next; + fprintf(f, "DISPLAY-LIST-CONTINUE\n"); + n = (Node *) get_pointer(&n[1]); + break; + case OPCODE_NOP: + fprintf(f, "NOP\n"); break; case OPCODE_END_OF_LIST: - printf("END-LIST %u\n", list); + fprintf(f, "END-LIST %u\n", list); done = GL_TRUE; break; default: @@ -10171,7 +9975,7 @@ print_list(struct gl_context *ctx, GLuint list) return; } else { - printf("command %d, %u operands\n", opcode, + fprintf(f, "command %d, %u operands\n", opcode, InstSize[opcode]); } } @@ -10181,6 +9985,10 @@ print_list(struct gl_context *ctx, GLuint list) } } } + + fflush(f); + if (fname) + fclose(f); } @@ -10194,7 +10002,7 @@ void mesa_print_display_list(GLuint list) { GET_CURRENT_CONTEXT(ctx); - print_list(ctx, list); + print_list(ctx, list, NULL); } @@ -10202,14 +10010,15 @@ mesa_print_display_list(GLuint list) /***** Initialization *****/ /**********************************************************************/ -void -_mesa_save_vtxfmt_init(GLvertexformat * vfmt) +static void +save_vtxfmt_init(GLvertexformat * vfmt) { - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + vfmt->ArrayElement = _ae_ArrayElement; vfmt->Begin = save_Begin; - _MESA_INIT_DLIST_VTXFMT(vfmt, save_); + vfmt->CallList = save_CallList; + vfmt->CallLists = save_CallLists; vfmt->Color3f = save_Color3f; vfmt->Color3fv = save_Color3fv; @@ -10218,7 +10027,12 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) vfmt->EdgeFlag = save_EdgeFlag; vfmt->End = save_End; - _MESA_INIT_EVAL_VTXFMT(vfmt, save_); + vfmt->EvalCoord1f = save_EvalCoord1f; + vfmt->EvalCoord1fv = save_EvalCoord1fv; + vfmt->EvalCoord2f = save_EvalCoord2f; + vfmt->EvalCoord2fv = save_EvalCoord2fv; + vfmt->EvalPoint1 = save_EvalPoint1; + vfmt->EvalPoint2 = save_EvalPoint2; vfmt->FogCoordfEXT = save_FogCoordfEXT; vfmt->FogCoordfvEXT = save_FogCoordfvEXT; @@ -10251,14 +10065,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) 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; @@ -10267,24 +10073,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) 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 } @@ -10297,23 +10085,6 @@ _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, } -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. */ @@ -10341,9 +10112,9 @@ _mesa_init_display_list(struct gl_context *ctx) /* Display List group */ ctx->List.ListBase = 0; -#if FEATURE_dlist - _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); -#endif + save_vtxfmt_init(&ctx->ListState.ListVtxfmt); + + InstSize[OPCODE_NOP] = 1; }